/* Main Layout */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.main-wrapper {
    display: flex;
    height: 100vh;
    position: relative;
}

.content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    transition: margin-right 0.3s ease;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* App Header */
.app-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid #e1e4e8;
    margin-bottom: 1rem;
}

.logo-image {
    height: 36px;
    width: auto;
}

/* Chat Interface */
.chat-container {
    display: flex;
    height: calc(100% - 70px);
}

.chat-layout {
    display: flex;
    gap: 1.25rem;
    width: 100%;
}

.conversation-sidebar {
    width: 240px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.sidebar-header {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    color: #4a4a4a;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.conversation-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background-color: #f5f7fa;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.conversation-button:hover {
    background-color: #e9f1ff;
}

.conversation-item.is-active .conversation-button {
    border-color: #3273dc;
    background-color: #e3ecff;
}

.conversation-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #363636;
    word-break: break-all;
    width: 100%;
}

.conversation-preview {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #7a7a7a;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.conversation-delete {
    margin: auto 0;
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
}

.conversation-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.85rem;
    color: #7a7a7a;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-wrapper {
    display: flex;
    margin-bottom: 0.5rem;
    width: 100%;
}

.message-content {
    display: flex;
    max-width: 85%;
    animation: fade-in 0.3s ease-out;
}

.user-message {
    justify-content: flex-end;
}

.assistant-message {
    justify-content: flex-start;
}

.debug-message {
    justify-content: flex-start;
    width: 100%;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.user-avatar {
    background-color: #4a76a8;
    color: white;
}

.assistant-avatar {
    background-color: #4caf50;
    color: white;
}

.debug-avatar {
    background-color: #ff9800;
    color: white;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    white-space: pre-wrap;
    word-break: break-word;
    max-width: calc(100% - 46px);
    line-height: 1.4;
}

.user-message .message-bubble {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
}

.assistant-message .message-bubble {
    background-color: #f1f1f1;
    border: 1px solid #e0e0e0;
}

.debug-message .message-bubble {
    background-color: #fff3e0;
    border: 1px solid #ffe0b2;
    width: calc(100% - 46px);
    font-family: monospace;
    font-size: 14px;
    overflow-x: auto;
}

.debug-trace {
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    color: #795548;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-sources-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4a4a4a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.message-source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.message-source-button {
    font-size: 0.75rem;
}

.share-banner {
    padding: 1.5rem 1.5rem 0;
}

.share-banner .notification {
    margin-bottom: 1rem;
    width: 100%;
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid #e1e4e8;
}

.chat-input-container .textarea {
    resize: none;
    min-height: 3.5rem;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    margin-left: 46px;
    padding: 10px 15px;
    background-color: #f1f1f1;
    border-radius: 18px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #9e9ea1;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.4;
    animation: typing 1.3s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing {
    0% {
        transform: translateY(0px);
    }

    25% {
        transform: translateY(-5px);
    }

    50% {
        transform: translateY(0px);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Side panel */
.side-panel {
    width: 300px;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    background-color: white;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    transform: translateX(300px);
    transition: transform 0.3s ease;
    z-index: 10;
}

.side-panel.active {
    transform: translateX(0);
}

.toggle-handle {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background-color: white;
    border-radius: 5px 0 0 5px;
    border: 1px solid #e1e4e8;
    border-right: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.1);
}

.panel-content {
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

/* Form elements and layout adjustments */
.field {
    margin-bottom: 1.5rem;
}

.select.is-fullwidth {
    width: 100%;
}

/* Document management */
.document-preview {
    background-color: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow-y: auto;
    font-family: "Fira Code", "Source Code Pro", monospace;
}

.document-preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.document-modal {
    width: min(900px, 90vw);
}

.document-modal .modal-card-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Mobile responsiveness */
@media screen and (max-width: 768px) {
    .content-wrapper {
        padding: 1rem;
    }

    .chat-layout {
        flex-direction: column;
    }

    .conversation-sidebar {
        width: 100%;
        order: 2;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    .conversation-list {
        max-height: 220px;
    }

    .chat-main {
        order: 1;
    }

    .side-panel {
        width: 100%;
        transform: translateX(100%);
    }

    .message-content {
        max-width: 95%;
    }

    .toggle-handle {
        width: 24px;
        height: 40px;
        left: -24px;
    }
}

.content-area {
    flex: 1;
    position: relative;
    overflow-y: auto;

}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
}

.content-wrapper.chat-page {
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    min-height: auto;
}
