/* =============================================
   UXPm - Your AI Gateway
   Dark theme | Teal primary | Purple accent
   ============================================= */

/* --- CSS Variables --- */
:root {
    --bg-primary: #080c14;
    --bg-secondary: #0d1225;
    --bg-surface: #111827;
    --bg-surface-2: #1a2035;
    --bg-input: #1e293b;
    --bg-hover: #243044;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #00d4aa;
    --accent-hover: #00e8bb;
    --accent-dim: rgba(0, 212, 170, 0.12);
    --accent-glow: rgba(0, 212, 170, 0.25);

    --purple: #7c3aed;
    --purple-hover: #8b5cf6;
    --purple-dim: rgba(124, 58, 237, 0.12);

    --border: #1e293b;
    --border-light: #2a3045;

    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.15);

    --sidebar-w: 280px;
    --header-h: 64px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition: 0.2s ease;
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* === LOGIN PAGE === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #0d1225 0%, #080c14 70%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.6s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 36px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    font-size: 40px;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-glow);
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-group label {
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.input-group input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 14px 14px 14px 0;
    font-family: var(--font);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #00a885);
    color: #080c14;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #00d4aa);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

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

.btn-block { width: 100%; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 12px;
}

.login-footer i { margin-right: 4px; }

/* === CHAT PAGE === */
.chat-page {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent);
}

.sidebar-logo i { font-size: 24px; }

.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-new-chat:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

/* Session list */
.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.session-list::-webkit-scrollbar {
    width: 4px;
}

.session-list::-webkit-scrollbar-track {
    background: transparent;
}

.session-list::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    position: relative;
}

.session-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.session-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-del-session {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition);
    font-size: 12px;
}

.session-item:hover .btn-del-session {
    opacity: 1;
}

.btn-del-session:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-badge i { font-size: 20px; color: var(--text-muted); }

.btn-logout {
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* --- Main Area --- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
}

/* --- Header --- */
.chat-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    gap: 16px;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: none;
    transition: all var(--transition);
}

.btn-toggle-sidebar:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-info {
    flex: 1;
    min-width: 0;
}

.header-info h2 {
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.model-badge i { font-size: 10px; }

.token-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.token-badge i {
    font-size: 10px;
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-selector {
    position: relative;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
    white-space: nowrap;
    max-width: 200px;
}

.model-selector-btn:hover {
    border-color: var(--accent);
}

.model-selector-btn i {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.model-selector-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Model dropdown --- */
.model-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 280px;
    max-height: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 150;
    overflow: hidden;
    flex-direction: column;
}

.model-dropdown.open {
    display: flex;
}

.model-dropdown-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.model-dropdown-search i {
    color: var(--text-muted);
    font-size: 13px;
    flex-shrink: 0;
}

.model-dropdown-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    min-width: 0;
}

.model-dropdown-search input::placeholder {
    color: var(--text-muted);
}

.model-dropdown-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
    max-height: 280px;
}

.model-dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.model-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.model-dropdown-list::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

.model-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
}

.model-dropdown-item:hover,
.model-dropdown-item.hovered {
    background: var(--bg-hover);
}

.model-dropdown-item.selected {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
}

.model-dropdown-item.selected::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: 8px;
    font-size: 10px;
}

/* --- Messages --- */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

#messageList {
    padding: 24px 0;
}

/* Welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 60px;
    color: var(--accent);
    margin-bottom: 20px;
    opacity: 0.6;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-hints {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
}

.welcome-hints span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.welcome-hints span:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* Message bubbles */
.message {
    display: flex;
    padding: 16px 24px;
    gap: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.message.user {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.message.assistant {
    background: transparent;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.message.user .message-avatar {
    background: var(--purple-dim);
    color: var(--purple);
}

.message.assistant .message-avatar {
    background: var(--accent-dim);
    color: var(--accent);
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-body p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
}

.message-body p + p {
    margin-top: 12px;
}

/* Code blocks in messages */
.message-body pre {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.message-body code {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.message-body :not(pre) > code {
    background: var(--bg-surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--accent);
}

.message-body a {
    color: var(--accent);
    text-decoration: underline;
}

/* File chips in messages */
.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 4px 10px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.file-chip i {
    font-size: 11px;
    color: var(--accent);
}

/* File preview above input */
.file-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 10px 0;
}

.file-preview.has-files {
    display: flex;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    min-width: 0;
    max-width: 200px;
    animation: fadeIn 0.2s ease;
}

.file-preview-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.file-preview-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.file-preview-name {
    display: block;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-size {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}

.file-preview-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    font-size: 11px;
    flex-shrink: 0;
    transition: all var(--transition);
}

.file-preview-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Attach button */
.btn-attach {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 4px 8px 8px;
    font-size: 16px;
    transition: color var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.btn-attach:hover {
    color: var(--accent);
}

/* Tokens info */
.tokens-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Typing Indicator --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 24px 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Input Area --- */
.input-area {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font);
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    min-height: 24px;
    padding: 8px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #080c14;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

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

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 100;
    }

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

    .sidebar-overlay.open {
        display: block;
    }

    .btn-toggle-sidebar {
        display: block;
    }

    .message {
        padding: 12px 16px;
    }

    .input-area {
        padding: 12px 12px 20px;
    }

    .welcome-hints span {
        font-size: 12px;
        padding: 8px 14px;
    }
}

/* === UTILITY === */
.hidden { display: none !important; }
.ml-auto { margin-left: auto; }
.text-center { text-align: center; }

/* ===================================
   PROFILE PAGE
   =================================== */
.profile-page {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    padding: 0;
    margin: 0;
}

.profile-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.profile-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.profile-header h1 i {
    color: var(--accent);
    margin-right: 8px;
}

.btn-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-back:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--accent);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-full {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header i {
    color: var(--accent);
    font-size: 16px;
}

.card-body {
    padding: 20px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-row .label {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-row .value {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.badge-role {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--purple-dim);
    color: var(--purple-hover);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    text-align: center;
}

.stat-item {
    padding: 16px 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Settings form */
.settings-form {
    max-width: 400px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-msg {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.form-msg.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-msg.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.card-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.card-danger .card-header {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.card-danger .card-header i {
    color: var(--danger);
}

.card-danger .card-body p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    font-family: var(--font);
}

.btn-primary {
    background: var(--accent);
    color: #080c14;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* Sidebar profile button */
.btn-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    flex: 1;
    transition: var(--transition);
}

.btn-profile:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-profile i {
    font-size: 20px;
    color: var(--accent);
}

.btn-profile span {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

/* === ADMIN PANEL === */
.admin-page {
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    flex-shrink: 0;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    padding: 8px 12px 24px;
    color: var(--accent);
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    transition: var(--transition);
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-nav-item.active {
    color: var(--accent);
}

.admin-sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.admin-main {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.admin-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.admin-user-badge {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.admin-tab {
    display: none;
}

.admin-tab.active {
    display: block;
}

.admin-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.admin-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-search {
    flex: 1;
    max-width: 320px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    cursor: pointer;
    color: var(--text-primary);
}

.toggle-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.admin-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.btn-danger-icon:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.admin-settings-form {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.code-block {
    background: var(--bg-input);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border);
}

.badge-ok {
    color: var(--success);
    font-weight: 600;
}

.badge-warn {
    color: var(--warning);
    font-weight: 600;
}

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

.btn-admin {
    color: var(--purple);
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-admin:hover {
    background: var(--purple-dim);
    color: var(--purple-hover);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
    }
    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }
    .admin-sidebar-footer {
        flex-direction: row;
        width: 100%;
    }
    .admin-main {
        padding: 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 480px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
    .stat-grid {
        grid-template-columns: 1fr;
    }
    .profile-container {
        padding: 20px 12px;
    }
    .profile-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .profile-header h1 {
        font-size: 20px;
    }
    .settings-form {
        max-width: 100%;
    }

    /* Keep sidebar off-screen by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar-overlay.open {
        display: block;
    }
    .chat-header .btn-toggle-sidebar {
        display: block !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }
    .sidebar-overlay.open {
        display: block;
    }
}

/* Mobile sidebar toggle button always visible on small screens */
.btn-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

/* === SIDEBAR ACTIONS === */
.sidebar-actions {
    display: flex;
    gap: 6px;
}

.sidebar-actions .btn-new-chat {
    flex: 1;
}

.btn-new-folder {
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-new-folder:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* === FOLDER GROUPS === */
.folder-group {
    margin-bottom: 4px;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition);
    user-select: none;
}

.folder-header:hover {
    background: var(--bg-hover);
}

.folder-header.muted {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.folder-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.folder-header i.fa-folder,
.folder-header i.fa-inbox {
    font-size: 14px;
    flex-shrink: 0;
}

.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-surface-2);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.btn-del-folder {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition);
    font-size: 11px;
}

.folder-header:hover .btn-del-folder {
    opacity: 1;
}

.btn-del-folder:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.folder-sessions {
    padding-left: 4px;
}

.collapsed .folder-sessions {
    display: none;
}

/* === RENAME INPUT === */
.rename-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    padding: 2px 6px;
    outline: none;
    min-width: 0;
}

/* === MOVE SESSION BUTTON === */
.btn-move-session {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition);
    font-size: 11px;
}

.session-item:hover .btn-move-session {
    opacity: 1;
}

.btn-move-session:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* === FOLDER PICKER OVERLAY === */
.folder-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.15s ease;
}

.folder-picker {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    min-width: 260px;
    max-width: 320px;
    box-shadow: var(--shadow);
}

.folder-picker-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.folder-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    max-height: 280px;
    overflow-y: auto;
}

.folder-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
}

.folder-picker-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.folder-picker-item i {
    color: var(--accent);
    width: 16px;
    text-align: center;
}
