/* ═══════════════════════════════════════════════════════
   MiMo AI Chat — AMOLED Black Theme
   Production CSS • Fully Responsive
   ═══════════════════════════════════════════════════════ */

/* ─── CSS VARIABLES ─────────────────────────────────── */
:root {
    --bg-primary:       #000000;
    --bg-secondary:     #0a0a0a;
    --bg-tertiary:      #111111;
    --bg-surface:       #161616;
    --bg-hover:         #1a1a1a;
    --bg-active:        #222222;
    
    --border-color:     #1e1e1e;
    --border-light:     #2a2a2a;
    
    --text-primary:     #e8e8e8;
    --text-secondary:   #a0a0a0;
    --text-tertiary:    #666666;
    --text-inverse:     #000000;
    
    --accent:           #7c4dff;
    --accent-hover:     #9c6fff;
    --accent-subtle:    rgba(124, 77, 255, 0.15);
    --accent-glow:      rgba(124, 77, 255, 0.3);
    
    --success:          #00e676;
    --success-subtle:   rgba(0, 230, 118, 0.15);
    --error:            #ff5252;
    --error-subtle:     rgba(255, 82, 82, 0.15);
    --warning:          #ffab40;
    --warning-subtle:   rgba(255, 171, 64, 0.15);
    
    --user-bubble:      #1a1a2e;
    --assistant-bubble: transparent;
    
    --sidebar-width:    280px;
    --header-height:    56px;
    --input-max-height: 200px;
    
    --radius-sm:        6px;
    --radius-md:        12px;
    --radius-lg:        16px;
    --radius-xl:        20px;
    --radius-full:      9999px;
    
    --shadow-sm:        0 1px 2px rgba(0,0,0,0.5);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.6);
    --shadow-lg:        0 8px 32px rgba(0,0,0,0.8);
    --shadow-glow:      0 0 20px var(--accent-glow);
    
    --transition:       0.2s ease;
    --transition-slow:  0.3s ease;
    
    --font-main:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono:        'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ─── RESET & BASE ──────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: white;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-hover);
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
}

/* ─── APP LAYOUT ────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── SIDEBAR ───────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: transform var(--transition-slow);
    z-index: 100;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search {
    padding: 8px 16px;
}
.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}
.sidebar-search input:focus {
    border-color: var(--accent);
}
.sidebar-search input::placeholder {
    color: var(--text-tertiary);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
}
.conversation-item:hover {
    background: var(--bg-hover);
}
.conversation-item.active {
    background: var(--accent-subtle);
    border: 1px solid rgba(124, 77, 255, 0.2);
}

.conv-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
}
.conversation-item.active .conv-info {
    color: var(--text-primary);
}
.conv-info svg {
    flex-shrink: 0;
    opacity: 0.5;
}
.conv-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.conv-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}
.conversation-item:hover .conv-actions {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-link {
    color: var(--warning) !important;
}

.logout-btn {
    color: var(--text-tertiary) !important;
    transition: color var(--transition);
}
.logout-btn:hover {
    color: var(--error) !important;
}

/* ─── SIDEBAR TOGGLE (Mobile) ───────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 8px;
    cursor: pointer;
}

/* ─── CHAT MAIN ─────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ─── WELCOME SCREEN ────────────────────────────────── */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.welcome-content {
    text-align: center;
    max-width: 600px;
}
.welcome-content h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--accent), #e040fb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}
.welcome-content code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--accent);
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.suggestion-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    padding: 16px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: all var(--transition);
}
.suggestion-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* ─── MESSAGES ──────────────────────────────────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.messages {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}
.message.user .message-avatar {
    background: var(--accent);
}
.message.assistant .message-avatar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.message-role {
    font-weight: 600;
    font-size: 14px;
}
.message.user .message-role { color: var(--accent); }
.message.assistant .message-role { color: var(--success); }
.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.message-body {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-body {
    background: var(--user-bubble);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border-top-left-radius: var(--radius-sm);
}

/* ─── MARKDOWN STYLING ──────────────────────────────── */
.message-body h1, .message-body h2, .message-body h3,
.message-body h4, .message-body h5, .message-body h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}
.message-body h1 { font-size: 1.5em; }
.message-body h2 { font-size: 1.3em; }
.message-body h3 { font-size: 1.15em; }

.message-body p {
    margin-bottom: 12px;
}
.message-body p:last-child {
    margin-bottom: 0;
}

.message-body ul, .message-body ol {
    margin: 8px 0;
    padding-left: 24px;
}
.message-body li {
    margin-bottom: 4px;
}

.message-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--accent-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.message-body code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: #e040fb;
}

.message-body pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 12px 0;
    overflow: hidden;
    position: relative;
}

.message-body pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-tertiary);
}
.copy-code-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    transition: all var(--transition);
}
.copy-code-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

.message-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}
.message-body th, .message-body td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.message-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.message-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 8px 0;
}

.message-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-body em {
    color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s ease infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ─── CHAT INPUT ────────────────────────────────────── */
.chat-input-area {
    padding: 0 16px 16px;
    background: var(--bg-primary);
}

.input-wrapper {
    max-width: 860px;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
}
.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.input-wrapper textarea {
    width: 100%;
    padding: 16px 16px 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: var(--input-max-height);
    overflow-y: auto;
}
.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.input-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 8px 8px;
    gap: 8px;
}

.char-count {
    font-size: 11px;
    color: var(--text-tertiary);
    flex: 1;
    padding-left: 8px;
}

.send-btn {
    background: var(--accent) !important;
    color: white !important;
    border-radius: var(--radius-full) !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.send-btn:hover {
    background: var(--accent-hover) !important;
    transform: scale(1.05);
}
.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.stop-btn {
    background: var(--error) !important;
    color: white !important;
    border-radius: var(--radius-full) !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* ─── SETTINGS FAB ──────────────────────────────────── */
.settings-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    z-index: 50;
}
.settings-fab:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: rotate(90deg);
    box-shadow: var(--shadow-glow);
}

/* ─── MODAL ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    font-size: 24px !important;
    color: var(--text-tertiary) !important;
    width: 32px !important;
    height: 32px !important;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* ─── SETTINGS TABS ─────────────────────────────────── */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    gap: 0;
}
.tab-btn {
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    padding: 20px 24px;
}
.tab-content.active {
    display: block;
}

/* ─── FORM ELEMENTS ─────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}
.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-mono);
    font-size: 13px;
}

/* Range Slider */
.form-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    outline: none;
    margin: 8px 0;
}
.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 8px var(--accent-glow);
}
.form-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

/* Toggle Switch */
.toggle-label {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.toggle-label input[type="checkbox"] {
    display: none;
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: background var(--transition);
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition);
}
.toggle-label input:checked + .toggle-switch {
    background: var(--accent);
}
.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* Input with toggle (password) */
.input-with-toggle {
    position: relative;
}
.input-with-toggle input {
    padding-right: 40px;
}
.input-with-toggle .toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

/* Preset Buttons */
.preset-models {
    margin-top: 16px;
}
.preset-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}
.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.preset-btn {
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.preset-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.preset-btn-sm {
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    margin: 0 4px 4px 0;
}
.preset-btn-sm:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.system-presets {
    margin-top: 12px;
}

/* ─── BUTTONS ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
}
.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.btn-danger {
    background: var(--error);
    color: white;
}
.btn-danger:hover {
    background: #ff1744;
}
.btn-full {
    width: 100%;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ─── ALERTS ────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid;
}
.alert-error {
    background: var(--error-subtle);
    border-color: rgba(255,82,82,0.3);
    color: var(--error);
}
.alert-success {
    background: var(--success-subtle);
    border-color: rgba(0,230,118,0.3);
    color: var(--success);
}
.alert-warning {
    background: var(--warning-subtle);
    border-color: rgba(255,171,64,0.3);
    color: var(--warning);
}

/* ─── BADGES ────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.badge-admin {
    background: var(--warning-subtle);
    color: var(--warning);
}

/* ─── AUTH PAGES ────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-container {
    width: 100%;
    max-width: 420px;
}
.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
.auth-header {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo {
    font-size: 48px;
    margin-bottom: 12px;
}
.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}
.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form .form-group {
    margin-bottom: 16px;
}
.auth-form input {
    width: 100%;
    padding: 12px 16px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ─── ADMIN PAGE ────────────────────────────────────── */
.admin-page {
    overflow: auto;
}
.admin-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.admin-header-left h1 {
    font-size: 24px;
}
.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}
.stat-icon {
    font-size: 28px;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.admin-section {
    margin-bottom: 32px;
}
.admin-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table tr:hover td {
    background: var(--bg-hover);
}

/* ─── TOAST NOTIFICATIONS ───────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--error); }
.toast.toast-info { border-left: 3px solid var(--accent); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ─── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .welcome-suggestions {
        grid-template-columns: 1fr;
    }
    .welcome-content h1 {
        font-size: 1.8rem;
    }
    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .modal {
        width: 95%;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .messages {
        padding: 16px 8px;
    }
    .chat-input-area {
        padding: 0 8px 8px;
    }
    .auth-card {
        padding: 24px 16px;
    }
}