:root {
    --primary-color: #508cbf;
    --secondary-color: #b388ff;
    --text-primary: #333;
    --text-secondary: #666;
    --background-primary: #fff;
    --background-secondary: #f5f7fb;
    --background-tertiary: #edf0f7;
    --ai-message-bg: #f0f4ff;
    --user-message-bg: #7c4dff;
    --user-message-text: #fff;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --animation-speed: 0.3s;
    --border-radius: 12px;
    --typing-indicator-color: var(--primary-color);
    --admin-sidebar-width: 280px;
    --admin-mobile-header-height: 3.25rem;
}

.dark-mode {
    --primary-color: #9d74ff;
    --secondary-color: #b388ff;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --background-primary: #1a1a1a;
    --background-secondary: #252525;
    --background-tertiary: #333333;
    --ai-message-bg: #2d2d3d;
    --user-message-bg: #9d74ff;
    --user-message-text: #fff;
    --border-color: #444;
    --shadow-color: rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    transition: background-color var(--animation-speed), color var(--animation-speed);
}

body {
    background-color: var(--background-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.container {
    /* display: flex; */
    justify-content: center;
    align-items: center;
    height: 100vh;
    min-height: 0;
    padding: 0;
    max-width: 100% !important;
    overflow: hidden;
}

.code-copy-container {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.code-copy-button {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ddd;
    border: none;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

    .code-copy-button:hover {
        background-color: rgba(255, 255, 255, 0.2);
        color: white;
    }

    .code-copy-button.copied {
        background-color: #4caf50;
        color: white;
    }

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    background-color: var(--background-primary);
    overflow: hidden;
    position: relative;
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* Mobile header — visible only on small screens */
.admin-mobile-header {
    display: none;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    height: var(--admin-mobile-header-height);
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-primary);
    z-index: 1020;
}

.admin-mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--background-secondary);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-mobile-menu-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.admin-mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #508cbf;
}

.admin-mobile-header-logo {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
    flex-shrink: 0;
}

/* Sidebar overlay for mobile offcanvas */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--animation-speed) ease;
}

body.admin-sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Styles */
.sidebar {
    width: var(--admin-sidebar-width) !important;
    flex-shrink: 0;
    min-height: 0;
    background-color: var(--background-tertiary);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    background-image: none !important;
    overflow: hidden;
    z-index: 1050;
}

    .sidebar nav.settings {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--background-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-close-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.sidebar-logo {
    width: 48px;
    height: auto;
    flex-shrink: 0;
}

.sidebar-brand-text {
    line-height: 1.2;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0;
    color: #508cbf;
    min-width: 0;
}

    .logo i {
        margin-right: 10px;
        font-size: 24px;
    }

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
}

    .new-chat-btn:hover {
        background-color: var(--secondary-color);
        transform: translateY(-2px);
    }

    .new-chat-btn i {
        margin-right: 8px;
    }

.history-container {
    /* flex: 1; */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

    .history-container h3 {
        font-size: 14px;
        color: var(--text-secondary);
        margin-bottom: 10px;
        padding-left: 5px;
    }

.chat-history-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
    overflow: visible;
}

#chat-history span {
    white-space: nowrap;
    width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background-color: var(--background-secondary);
}

.chat-history-item.active {
    background-color: rgba(124, 77, 255, 0.1);
    font-weight: 500;
}

.chat-history-item i {
    margin-right: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.settings {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

    .settings button {
        display: flex;
        align-items: center;
        background: none;
        border: none;
        color: var(--text-secondary);
        padding: 10px 5px;
        width: 100%;
        text-align: left;
        cursor: pointer;
        border-radius: var(--border-radius);
        font-size: 14px;
        transition: background-color 0.2s;
    }

        .settings button:hover {
            background-color: var(--background-secondary);
            color: var(--text-primary);
        }

        .settings button i {
            margin-right: 10px;
            width: 16px;
        }

/* Chat Container Styles */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background-color: var(--background-primary);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.admin-main .chat-container {
    flex: 1;
    min-height: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
}

.current-chat-title {
    font-weight: 600;
    font-size: 16px;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    border-radius: 5px;
    transition: color 0.2s, background-color 0.2s;
}

    .header-actions button:hover {
        color: var(--primary-color);
        background-color: var(--background-tertiary);
    }

    /* Added regenerate, stop, and export button styling */
    .header-actions button#regenerate-response {
        margin-right: 5px;
    }

/* Chat messages */
.messages {
    flex: 1;
    overflow-y: auto;
    /* padding: 20px 0; */
}

.message {
    display: flex;
    margin: 25px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 15px;
    line-height: 1.5;
}

.message.ai {
    justify-content: flex-start;
    /* flex-direction: column; */
}

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

.message.ai .message-content {
    background-color: var(--ai-message-bg);
    color: var(--text-primary);
    border-radius: var(--border-radius);
}

.message.user .message-content {
    background-color: var(--user-message-bg);
    color: var(--user-message-text);
    border-radius: var(--border-radius);
}

.message.ai .message-content h1 {
    font-size: 22px;
    margin: 16px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
}

.message.ai .message-content h2 {
    font-size: 18px;
    margin: 14px 0 8px;
    color: var(--text-primary);
}

.message.ai .message-content h3 {
    font-size: 16px;
    margin: 12px 0 6px;
    color: var(--text-primary);
}

/* List styles for better readability */
.message.ai .message-content ul,
.message.ai .message-content ol {
    margin: 8px 0;
    padding-left: 25px;
}

.message.ai .message-content li {
    margin-bottom: 5px;
}

/* Block quote styling */
.message.ai .message-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 0 0 0 15px;
    margin: 10px 0;
    color: var(--text-secondary);
}

/* Table styling */
.message.ai .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
}

.message.ai .message-content th,
.message.ai .message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message.ai .message-content th {
    background-color: var(--background-tertiary);
    font-weight: 600;
}

/* Links styling */
.message.ai .message-content a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

    .message.ai .message-content a:hover {
        text-decoration: underline;
    }

.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
    color: #c792ea;
}

.hljs-number,
.hljs-string,
.hljs-doctag,
.hljs-regexp {
    color: #89ca78;
}

.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-name {
    color: #e2b93d;
}

.hljs-variable,
.hljs-template-variable,
.hljs-selector-id,
.hljs-class .hljs-title {
    color: #7fdbca;
}

.hljs-type,
.hljs-tag {
    color: #e06c75;
}

/* Language badge for code blocks */
pre::before {
    content: attr(class);
    position: absolute;
    top: 5px;
    left: 12px;
    font-size: 12px;
    color: #aaa;
    display: none;
}

/* Horizontal rule */
.message.ai .message-content hr {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 15px 0;
}

.typing-indicator {
    display: flex;
    padding: 15px 25px;
    justify-content: center;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: var(--typing-indicator-color);
    border-radius: 50%;
    opacity: 0.6;
    animation: typingAnimation 0.9s infinite;
}

    .typing-dot:nth-child(2) {
        animation-delay: 0.2s;
    }

    .typing-dot:nth-child(3) {
        animation-delay: 0.4s;
    }

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

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

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

.input-area {
    padding: 15px 25px 20px;
    border-top: 1px solid var(--border-color);
}

    .input-area > div {
        display: flex;
        justify-content: space-between;
        /* align-items: end; */
        font-size: 14px;
    }

        .input-area > div > div {
            flex-basis: content;
            align-items: baseline;
            display: flex;
            flex-direction: row;
        }

        .input-area > div select {
            font-size: 14px;
        }

.input-container {
    display: flex;
    position: relative;
    background-color: var(--background-tertiary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* Style for file upload button */
#file-upload-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 15px;
    cursor: pointer;
}

    #file-upload-button:hover {
        color: var(--primary-color);
    }

textarea {
    flex: 1;
    border: none;
    background: none;
    padding: 15px;
    font-size: 15px;
    resize: none;
    max-height: 150px;
    color: var(--text-primary);
    outline: none;
    align-items: center;
    justify-content: center;
    align-content: center;
}

    textarea::placeholder {
        color: var(--text-secondary);
    }

#send-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

    #send-button:hover {
        background-color: var(--secondary-color);
    }

.disclaimer {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
}

/* Pending file preview (for selected file before send) */
#pending-file-preview {
    display: none;
    margin: 10px 0;
}

/* Intro Message Styles */
.intro-message {
    text-align: center;
    /* max-width: 600px; */
    margin: 40px auto;
    padding: 30px;
    background-color: var(--background-primary);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.5s ease-out;
}

    .intro-message h1 {
        color: var(--primary-color);
        font-size: 28px;
        margin-bottom: 15px;
    }

    .intro-message p {
        color: var(--text-secondary);
        margin-bottom: 25px;
        font-size: 16px;
    }

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.suggestion-chip {
    background-color: var(--background-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

    .suggestion-chip:hover {
        background-color: var(--background-secondary);
        color: var(--primary-color);
        transform: translateY(-2px);
    }

/* Code block styling */
pre {
    position: relative;
    background-color: #282c34;
    border-radius: 8px;
    padding: 12px;
    padding-top: 35px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #3e4451;
    color: #edf0f7;
}

code {
    font-family: "Fira Code", "Courier New", Courier, monospace;
    font-size: 14px;
}

pre code {
    white-space: pre;
    font-size: 14px;
    line-height: 1.5;
}

:not(pre) > code {
    background-color: rgba(125, 125, 125, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--primary-color);
}

/* New CSS for chat options button and menu */
.chat-options-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.chat-options-menu {
    position: absolute;
    right: 10px;
    top: 100%;
    background-color: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px var(--shadow-color);
    z-index: 100;
}

.chat-options-item {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
}

    .chat-options-item:hover {
        background-color: var(--background-secondary);
    }

/* ── Responsive layout ── */
@media (max-width: 991.98px) {
    .admin-mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(var(--admin-sidebar-width), 85vw) !important;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform var(--animation-speed) ease;
        box-shadow: 8px 0 32px var(--shadow-color);
    }

    body.admin-sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .sidebar .logo {
        font-size: 1.1rem;
    }

    .sidebar-logo {
        width: 40px;
    }

    .sidebar {
        padding: 1rem;
    }
}

@media (max-width: 575.98px) {
    :root {
        --admin-sidebar-width: 260px;
    }

    .sidebar-brand-text {
        font-size: 0.95rem;
    }
}

@media (min-width: 992px) {
    body.admin-sidebar-open .sidebar-overlay {
        display: none !important;
    }
}
