:root {
    --bg-base: #131314;
    --bg-sidebar: #1e1f20;
    --bg-input: #1e1f20;
    --bg-user-bubble: #282a2c;
    --text-primary: #e3e3e3;
    --text-secondary: #c4c7c5;
    --border-color: #444746;
    --accent: #4E8BFE;
    --accent: #4E8BFE;
    --font-main: 'Google Sans', sans-serif;
}

[data-theme="light"] {
    --bg-base: #ffffff;
    --bg-sidebar: #f8f9fa;
    --bg-input: #f1f3f4;
    --bg-user-bubble: #e8f0fe;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --accent: #1a73e8;
}

[data-theme="light"] .bot-response pre {
    background: #f8f9fa;
    border-color: #dadce0;
}
[data-theme="light"] .bot-response code {
    color: #202124;
}
[data-theme="light"] .session-item:hover,
[data-theme="light"] .session-item.active {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .info-group,
[data-theme="light"] .session-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .settings-readonly {
    background: rgba(0,0,0,0.05);
}
[data-theme="light"] .revoke-btn {
    background: rgba(231, 76, 60, 0.05);
}
[data-theme="light"] .dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .sun-icon {
    display: block !important;
}
[data-theme="light"] .moon-icon {
    display: none !important;
}
[data-theme="light"] .empty-state {
    background: -webkit-linear-gradient(45deg, #FF671F, #000000, #046A38);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
}

html {
    height: 100%;
    /* Webkit-fill-available fixes some iOS specific bugs */
    height: -webkit-fill-available;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    height: 100%;
    height: 100dvh; /* Modern fix for mobile browser UI */
    min-height: -webkit-fill-available;
    overflow: hidden;
    display: flex;
}

.auth-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-box {
    background-color: var(--bg-input);
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.auth-box input,
.auth-box select {
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
}

.auth-box button {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.session-item:hover,
.session-item.active {
    background: rgba(255, 255, 255, 0.08);
}

.session-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 10px;
}

.session-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
}

.session-item:hover .session-actions {
    opacity: 1;
}

.action-icon {
    color: var(--text-secondary);
    text-decoration: none;
}

.action-icon:hover {
    color: var(--text-primary);
}

.pinned-icon {
    color: #F2A45C !important;
    opacity: 1 !important;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    align-items: center;
}

.credits-badge {
    background: rgba(78, 139, 254, 0.1);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid rgba(78, 139, 254, 0.3);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-content {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 40px;
}

.empty-state {
    margin-top: 20vh;
    text-align: center;
    font-size: 2.5rem;
    font-weight: 500;
    background: -webkit-linear-gradient(45deg, #FF671F, #FFFFFF, #046A38);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.message-row {
    display: flex;
    gap: 16px;
    width: 100%;
}

.message-row.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-bubble {
    max-width: 85%;
    font-size: 1rem;
    line-height: 1.6;
}

.user .message-bubble {
    background-color: var(--bg-user-bubble);
    border-radius: 24px 8px 24px 24px;
    padding: 12px 20px;
}

.bot-response pre {
    background: #0d1117;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
}

.bot-response code {
    font-family: monospace;
    color: #c9d1d9;
}

.input-wrapper {
    background-color: var(--bg-base);
    padding: 16px 20px 32px 20px;
    display: flex;
    justify-content: center;
}

.input-container {
    width: 100%;
    max-width: 820px;
    background-color: var(--bg-input);
    border-radius: 32px;
    display: flex;
    align-items: flex-end;
    padding: 8px 16px;
}

.input-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px 8px;
    outline: none;
    font-size: 1rem;
}

.send-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    margin-bottom: 4px;
}

.send-btn svg {
    fill: var(--text-secondary);
    width: 24px;
    height: 24px;
}

.cursor::after {
    content: '▋';
    animation: blink 1s infinite;
    color: var(--text-secondary);
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ========================================== */
/* MODAL STYLES                               */
/* ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 380px;
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-icon svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
}

.modal-content h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    font-weight: 500;
}

.modal-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.modal-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    font-weight: 500;
    transition: background 0.2s;
}

.modal-btn:hover {
    background: #3b74e6;
}

/* ========================================== */
/* TOAST NOTIFICATIONS & COLORS               */
/* ========================================== */

.toast-container {
    position: fixed;
    top: 30px;
    /* Changed to Top */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

/* Base Pill Shape */
.toast {
    background-color: var(--bg-user-bubble);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    /* Start slightly above the screen */
    transform: translateY(-20px);
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.hide {
    animation: toast-out 0.3s ease-in forwards;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Success: Vibrant Green */
.toast.toast-success {
    background-color: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.5);
    color: #e3e3e3;
}

/* Error: Vibrant Red */
.toast.toast-error {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.5);
    color: #e3e3e3;
}

/* Dynamic Animation Keyframes - Coming from the TOP */
@keyframes toast-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {

    /* Slide back up slightly as it fades */
    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

/* ========================================== */
/* SETTINGS MODAL STYLES                      */
/* ========================================== */

.settings-content {
    max-width: 500px;
    width: 90%;
    padding: 0;
    text-align: left;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.settings-body {
    padding: 32px;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h4 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.profile-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.info-group {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-group div {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.settings-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    margin-top: 4px;
    outline: none;
}

.settings-input:focus {
    border-color: var(--accent);
}

.settings-readonly {
    padding: 10px 12px;
    font-size: 1rem;
    color: var(--text-secondary) !important;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-top: 4px;
}

.session-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-session {
    border-color: rgba(46, 204, 113, 0.3);
    background: rgba(46, 204, 113, 0.05);
}

.session-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-info strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.session-info span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.revoke-btn {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.revoke-btn:hover {
    background: #e74c3c;
    color: white;
}

/* ========================================== */
/* HEADER ACTIONS & PROFILE DROPDOWN          */
/* ========================================== */

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.desktop-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.mobile-profile {
    display: none;
    position: relative;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.2s;
}

.theme-toggle:hover {
    color: var(--text-primary);
}

.profile-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    min-width: 160px;
    margin-top: 8px;
    z-index: 100;
}

.profile-dropdown.show {
    display: flex;
}

.dropdown-item {
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ========================================== */
/* RESPONSIVE STYLES                          */
/* ========================================== */

.name-fields {
    display: flex;
    gap: 10px;
}

.hamburger-btn {
    display: none;
}


.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .desktop-actions { display: none; }
    .mobile-profile { display: block; }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .message-bubble {
        max-width: 95%;
    }

    .input-container {
        border-radius: 20px;
        padding: 4px 12px;
    }

    .input-wrapper {
        padding: 10px;
    }
    
    .auth-box {
        padding: 24px;
        margin: 20px;
        width: 90%;
        max-width: none;
    }
    
    .header {
        padding: 12px 16px;
    }
    
    .empty-state {
        font-size: 1.8rem;
    }

    .name-fields {
        flex-direction: column;
        gap: 0;
    }

    .profile-info {
        grid-template-columns: 1fr;
    }

    .session-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .revoke-btn {
        width: 100%;
        text-align: center;
        padding: 10px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .settings-body {
        padding: 20px;
    }
}