/* ============== CSS VARIABLES ============== */
:root {
    /* Warm White/Beige Premium Palette */
    --primary-orange: #E85D04;
    /* Slightly darker orange for contrast on light bg */
    --primary-orange-light: #FF8c42;
    /* Soft orange */
    --primary-orange-dark: #D00000;
    /* Deep red-orange */
    --accent-amber: #FFB703;

    --bg-black: #FAF9F6;
    /* Off-White/Warm White background */
    --bg-dark: #F5F5F0;
    /* Light Beige for main chat area */
    --bg-panel: #FFFFFF;
    /* Pure White for panels/cards */
    --bg-card: #FDFDFD;
    /* Near White for smaller cards */
    --bg-hover: #F0EFEB;
    /* Warm Grey for hover states */

    --text-white: #1A1A1A;
    /* Dark Grey (almost black) for main text */
    --text-light: #333333;
    /* Dark Grey for secondary text */
    --text-muted: #6B7280;
    /* Medium Grey for muted text */
    --text-dark: #9CA3AF;
    /* Lighter Grey for placeholders */

    --border-color: #E5E5E5;
    --border-light: #D4D4D4;

    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;

    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(232, 93, 4, 0.15);
}

/* ============== RESET & BASE ============== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-black);
    color: var(--text-white);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* ============== LOGIN OVERLAY ============== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FAF9F6 0%, #F0EFEB 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-card {
    background: var(--bg-panel);
    padding: 3rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    width: 420px;
    text-align: center;
}

.login-logo {
    margin-bottom: 1.5rem;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-orange), var(--accent-amber));
    border-radius: 12px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: var(--bg-black);
    font-weight: 700;
    font-family: var(--font-head);
    box-shadow: var(--shadow-glow);
}

.brand-text {
    font-family: var(--font-head);
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-orange), var(--accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* ============== FORM INPUTS ============== */
.input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.input-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-white);
    border-radius: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

.input-group input::placeholder {
    color: var(--text-dark);
}

/* ============== LOGO ============== */
/* ============== LOGO ============== */
.logo-img {
    width: 65px;
    height: 65px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(255, 107, 53, 0.4));
}

.login-logo .logo-img {
    width: 100px;
    height: 100px;
    margin-bottom: 1rem;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: var(--text-light);
}

.welcome-screen .logo-img {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.welcome-greeting {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-white);
}

.welcome-model-indicator {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    background: var(--bg-hover);
    border-radius: 20px;
}

/* ============== 3D BORDES & BUTTONS ============== */
/* ============== 3D BORDES & BUTTONS ============== */
.primary-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 1px solid var(--border-color);
    border-bottom: 3px solid #D4D4D4;
    /* Lighter 3D effect for light mode */
    color: var(--primary-orange);
    font-weight: 600;
    font-family: var(--font-head);
    font-size: 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    text-shadow: none;
    /* No text glow in light mode */
}

.primary-btn:hover {
    background: #fdfdfd;
    border-bottom: 3px solid var(--primary-orange);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1),
        0 0 10px rgba(232, 93, 4, 0.1);
    color: var(--primary-orange);
}

.primary-btn:active {
    transform: translateY(2px);
    border-bottom: 1px solid var(--primary-orange);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Update Input Fields with similar subtle 3D border */
.input-group input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom: 2px solid #E5E5E5;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.input-group input:focus {
    border-color: var(--primary-orange);
    border-bottom-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1);
}

/* Update Send Button */
/* Update Send Button */
.send-btn {
    background: linear-gradient(145deg, var(--bg-card), var(--bg-hover));
    border: 1px solid var(--border-light);
    border-bottom: 3px solid #D4D4D4;
    color: var(--primary-orange);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.send-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-bottom-color: var(--primary-orange);
    box-shadow: 0 0 10px rgba(232, 93, 4, 0.15);
}

.send-btn:active:not(:disabled) {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

.error-msg {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 1rem;
    min-height: 1.2rem;
}

.hidden {
    display: none !important;
}

/* ============== APP CONTAINER ============== */
.app-container {
    display: flex;
    height: 100vh;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* ============== SIDEBAR ============== */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
}

.sidebar-top {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
}

.brand-name {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--primary-orange), var(--accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    width: 100%;
    background: #FFFFFF;
    border: 1px dashed var(--border-light);
    padding: 0.75rem;
    border-radius: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-orange);
    color: var(--primary-orange);
}

/* ============== SIDEBAR MIDDLE ============== */
.sidebar-middle {
    flex: 1;
    padding-top: 1.25rem;
    overflow-y: auto;
}

.section-label {
    font-size: 0.7rem;
    color: #000000;
    margin-bottom: 0.75rem;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.usage-widget {
    background: linear-gradient(135deg, rgba(232, 93, 4, 0.03), rgba(255, 183, 3, 0.03));
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.usage-widget:hover {
    box-shadow: 0 4px 12px rgba(232, 93, 4, 0.1);
    border-color: rgba(232, 93, 4, 0.3);
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.usage-info {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

#usage-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-orange);
    text-shadow: 0 1px 2px rgba(232, 93, 4, 0.2);
}

#limit-val {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.usage-percentage {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-orange);
    background: rgba(232, 93, 4, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.progress-bg {
    height: 10px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-orange), var(--accent-amber));
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s ease,
                box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Animated shine effect */
.progress-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 100%;
    }
}

/* Color states based on usage */
.progress-fill.low {
    background: linear-gradient(90deg, #10b981, #34d399);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.progress-fill.medium {
    background: linear-gradient(90deg, var(--primary-orange), var(--accent-amber));
    box-shadow: 0 0 10px rgba(232, 93, 4, 0.4);
}

.progress-fill.high {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    animation: pulse-warning 2s infinite;
}

.progress-fill.critical {
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    animation: pulse-critical 1.5s infinite;
}

@keyframes pulse-warning {
    0%, 100% {
        box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
    }
}

@keyframes pulse-critical {
    0%, 100% {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    }
    50% {
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.9);
    }
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ============== SIDEBAR BOTTOM ============== */
.sidebar-bottom {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Admin/Settings Buttons */
.settings-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.75rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    /* Bold */
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    /* For shine effect */
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-orange);
}

/* Shine Effect for Settings/Admin (Same as history items) */
.settings-btn:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    transform: skewX(-20deg);
    animation: shine 1s infinite;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-orange), var(--accent-amber));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.user-email {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    text-align: left;
    transition: color 0.2s;
    width: fit-content;
}

.logout-btn:hover {
    color: var(--error);
    text-decoration: underline;
}

/* ============== HISTORY ITEMS SHINE & HOVER ============== */
.history-item {
    padding: 0.7rem 0.75rem;
    padding-right: 32px;
    /* Space for menu button */
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    margin-right: 4px;
    /* Gradient fade-out for long text */
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

.history-item:hover {
    background: linear-gradient(90deg, #FFF0E6 0%, #FFF5EB 50%, #FFF0E6 100%);
    color: var(--primary-orange);
    position: relative;
    overflow: hidden;
}

/* Moving Shine Effect */
.history-item:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    transform: skewX(-20deg);
    animation: shine 1s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.history-item.active {
    background: #FFF0E6;
    color: var(--primary-orange);
    border-left: 3px solid var(--primary-orange);
    font-weight: 500;
}

/* Chat Menu (3-dots) */
.chat-menu-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1.1rem;
    z-index: 10;
    transition: all 0.2s;
    opacity: 0.7;
}

.history-item:hover .chat-menu-btn,
.chat-menu-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary-orange);
}

.chat-menu-btn:hover {
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-menu-dropdown {
    position: absolute;
    right: 10px;
    top: 30px;
    /* Below the dots */
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    z-index: 20;
    min-width: 120px;
    overflow: hidden;
    animation: fadeIn 0.1s ease;
}

.chat-menu-dropdown.hidden {
    display: none;
}

.chat-menu-item {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    cursor: pointer;
    transition: background 0.1s;
}

.chat-menu-item:hover {
    background: var(--bg-hover);
}

.chat-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.chat-menu-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}

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

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

/* ============== CHAT HEADER ============== */
.chat-header {
    padding: 0.75rem 1.5rem;
    /* Reduced padding */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    flex-shrink: 0;
    min-height: 60px;
    /* Reduced min-height */
}

.header-controls {
    display: flex;
    gap: 10px;
    /* Reduced gap */
    align-items: center;
}

/* Custom Select Styling - Compact Button */
.custom-select {
    position: relative;
    user-select: none;
    min-width: unset;
    /* Remove large min-width */
    max-width: 200px;
    /* Limit main expansion */
}

.select-trigger {
    background: var(--bg-card);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
}

.select-trigger:hover {
    background: var(--bg-hover);
    border-color: var(--primary-orange);
}

.truncated-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    /* Force truncation for long names */
}

.select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    /* Options can be wider */
    z-index: 1000;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    max-height: 400px;
    overflow-y: auto;
}

.select-options.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-option {
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-light);
    border-bottom: 1px solid var(--bg-hover);
    transition: background 0.1s;
    white-space: nowrap;
}

.select-option:last-child {
    border-bottom: none;
}

.select-option:hover {
    background-color: var(--bg-hover);
    color: var(--primary-orange);
}

.select-option.selected {
    background-color: #FFF0E6;
    color: var(--primary-orange);
    font-weight: 500;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    background: var(--bg-hover);
    border-radius: 2rem;
}

/* LED Status Indicator */
.status-led {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #D1D5DB;
    /* Inactive light gray - more visible */
    border-radius: 50%;
    margin-left: 10px;
    transition: all 0.3s ease;
    border: 2px solid #E5E7EB;
    /* Border to make it stand out */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.status-led.active {
    background: #10B981;
    /* Active green */
    border-color: #10B981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.9),
        0 0 24px rgba(16, 185, 129, 0.6),
        0 0 36px rgba(16, 185, 129, 0.4);
    /* Bright glowing effect */
    animation: pulse-led 2s ease-in-out infinite;
}

@keyframes pulse-led {
    0%, 100% {
        box-shadow: 0 0 12px rgba(16, 185, 129, 0.9),
            0 0 24px rgba(16, 185, 129, 0.6),
            0 0 36px rgba(16, 185, 129, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 18px rgba(16, 185, 129, 1),
            0 0 30px rgba(16, 185, 129, 0.8),
            0 0 42px rgba(16, 185, 129, 0.5);
        transform: scale(1.1);
    }
}

/* Delete Confirmation Modal */
.delete-modal-content {
    max-width: 450px;
    text-align: center;
}

.delete-modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.delete-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #DC2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
    animation: pulse-delete 2s ease-in-out infinite;
}

@keyframes pulse-delete {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(220, 38, 38, 0.25);
    }
}

.delete-modal-header h3 {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
}

.delete-warning {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 0.5rem;
}

.delete-subtext {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cancel-btn {
    padding: 0.625rem 1.5rem;
    background: var(--bg-hover);
    color: var(--text-white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: var(--bg-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.delete-btn {
    padding: 0.625rem 1.5rem;
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.delete-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent);
    transition: left 0.5s ease;
}

.delete-btn:hover::before {
    left: 100%;
}

.delete-btn:hover {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

.delete-btn:active {
    transform: translateY(0);
}

/* Bolder Labels for Key/Model */
.dropdown-mini-label {
    font-size: 0.75rem !important;
    color: var(--text-light) !important;
    font-weight: 800 !important;
    /* Extra Bold */
    margin-left: 4px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============== MESSAGES RE-STYLING (ChatGPT Style) ============== */
.message {
    display: flex;
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem 0;
}

/* User Bubble Style */
.message.user {
    flex-direction: row-reverse;
}

.message.user .msg-content {
    background: var(--bg-card);
    /* Changed to card background for bubble look */
    padding: 0.8rem 1.25rem;
    border-radius: 1.25rem;
    border-top-right-radius: 0.25rem;
    background: var(--bg-hover);
    /* Light grey bubble */
    color: var(--text-white);
    max-width: 70%;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Bot Full Width Style */
.message.assistant {
    flex-direction: row;
}

.message.assistant .msg-content {
    background: transparent;
    padding: 0;
    border: none;
    max-width: 100%;
    color: var(--text-white);
    line-height: 1.6;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 0.5rem;
    /* Square-ish */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 5px;
    /* Visual alignment with bubble top */
}

/* Hide user avatar in bubble mode if desired, or keep it */
.message.user .msg-avatar {
    display: none;
}


/* ============== STOP GENERATION BUTTON ============== */
.stop-btn {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
    color: var(--text-light);
    z-index: 100;
    transition: all 0.2s ease;
    animation: slideUp 0.3s ease;
}

.stop-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-orange);
    border-color: var(--primary-orange);
}

.stop-btn svg {
    width: 16px;
    height: 16px;
    animation: pulse 2s infinite;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.input-area {
    padding: 1.5rem 2rem;
    background: linear-gradient(transparent, var(--bg-dark) 20%);
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 1000px;
    /* Wider input */
    margin: 0 auto;
    /* Center the input area */
}

.input-container {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    /* More padding */
    display: flex;
    align-items: flex-end;
    /* Align bottom so it grows up */
    gap: 12px;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
    /* Limit to ~6 lines */
    overflow-y: auto;
    padding: 0;
    margin: 0;
    min-height: 24px;
}

#chat-input:focus {
    outline: none;
}

/* Custom scrollbar for input */
#chat-input::-webkit-scrollbar {
    width: 4px;
}

#chat-input::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

#chat-input::placeholder {
    color: var(--text-dark);
}

.send-btn {
    background: var(--primary-orange);
    color: white;
    border: none;
    padding: 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    transition: all 0.2s ease;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-orange-light);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: not-allowed;
}

/* ============== MODAL ============== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-panel);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    width: 420px;
    max-width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-family: var(--font-head);
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-white);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 500;
}

.message-text {
    margin-top: 1rem;
    font-size: 0.85rem;
    text-align: center;
}

.message-text.success {
    color: var(--success);
}

.message-text.error {
    color: var(--error);
}

/* ============== SCROLLBAR ============== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============== TYPING INDICATOR ============== */
.typing {
    display: inline-flex;
    gap: 4px;
}

.typing::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    100% {
        content: '...';
    }
}

/* ============== STOP GENERATION BUTTON ============== */
.stop-btn-container {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding-bottom: 1rem;
    pointer-events: none;
}

/* === New Stop/Send Button & Chat Menu === */

/* Stop Mode for Send Button */
.send-btn.stop {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.send-btn.stop:hover {
    background: #dc2626;
    /* Darker red */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

/* Chat History Menu (3 Dots) - Always Visible */
.history-item .chat-menu-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.2s;
    background: transparent;
    opacity: 0.6;
}

.history-item:hover .chat-menu-btn,
.chat-menu-btn.active {
    opacity: 1;
    color: var(--primary-orange);
    background: rgba(232, 93, 4, 0.1);
}

.chat-menu-btn:hover {
    background: rgba(232, 93, 4, 0.15);
    color: var(--primary-orange);
}

.chat-menu-dropdown {
    position: absolute;
    /* Reverted to absolute here? NO, script uses fixed inline style which overrides this unless !important */
    /* Script sets position: fixed, top, left inline. */
    margin-top: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    width: auto;
    min-width: 100px;
    max-width: 120px;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.chat-menu-item {
    padding: 10px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-white);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.chat-menu-item:hover {
    background: var(--bg-hover);
}

.chat-menu-item.delete {
    color: var(--error);
}

.chat-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

.chat-menu-item.download {
    color: var(--primary-orange);
}

.chat-menu-item.download:hover {
    background: rgba(232, 93, 4, 0.1);
}

.chat-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Stop Generation Button - Improved */
.stop-icon-square {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 2px;
}

.send-btn.stop {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    border-bottom: 3px solid #b91c1c;
    color: white;
    animation: pulse-stop 1.5s ease-in-out infinite;
}

.send-btn.stop:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}

@keyframes pulse-stop {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Welcome Screen Enhancements */
.welcome-greeting {
    font-family: var(--font-head);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.welcome-model-indicator {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    display: inline-block;
    margin-top: 0.5rem;
}

.welcome-model-indicator strong {
    color: var(--primary-orange);
}

/* Model Switch Notice - Persistent Style */
.model-switch-notice {
    text-align: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0.5rem auto;
    max-width: 400px;
}

.model-switch-notice span {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.model-switch-notice .model-icon {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, var(--primary-orange), var(--accent-amber));
    border-radius: 4px;
}

/* Improved Assistant Message Styling */
.message.assistant .msg-content {
    background: transparent;
    padding: 0;
    border: none;
    max-width: 100%;
    color: var(--text-white);
    line-height: 1.7;
    font-size: 0.95rem;
}

.message.assistant .msg-content p {
    margin-bottom: 1rem;
}

.message.assistant .msg-content p:last-child {
    margin-bottom: 0;
}

.message.assistant .msg-content code {
    background: var(--bg-hover);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message.assistant .msg-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}


.message.assistant .msg-content h1 {
    font-size: 1.5em;
    font-weight: 700;
    margin-top: 1em;
    margin-bottom: 0.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.message.assistant .msg-content h2 {
    font-size: 1.3em;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.message.assistant .msg-content h3 {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 0.8em;
    margin-bottom: 0.4em;
}

.message.assistant .msg-content ul,
.message.assistant .msg-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.message.assistant .msg-content li {
    margin-bottom: 0.25em;
}

.message.assistant .msg-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
    /* Space for eye icon */
}

.eye-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 0;
    transition: color 0.2s;
}

.eye-toggle:hover {
    color: var(--primary-orange);
}

.eye-toggle svg {
    pointer-events: none;
}

.hidden {
    display: none !important;
}