/* DigiRett AI — Prototype Styles (Dark Theme) */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #111827;
    --bg-card: #1f2937;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --border: #334155;
    --radius: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ========== Auth Page ========== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.auth-container { width: 100%; max-width: 420px; padding: 20px; }

.auth-box {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
}

.brand { text-align: center; margin-bottom: 32px; }
.brand .logo {
    width: 48px; height: 48px;
    background: var(--accent);
    color: white;
    font-size: 24px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    margin: 0 auto 16px;
}
.brand h1 { font-size: 1.5rem; margin-bottom: 4px; }
.brand p { color: var(--text-secondary); font-size: 0.9rem; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-secondary); }
.form-group input {
    width: 100%; padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.btn-primary {
    width: 100%; padding: 12px;
    background: var(--accent);
    color: white; border: none;
    border-radius: 8px;
    font-size: 0.95rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 12px; text-align: center; min-height: 1.2em; }

.beta-notice {
    margin-top: 24px; padding: 12px;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 8px;
    font-size: 0.8rem; color: #eab308;
    text-align: center;
}
.beta-notice span { margin-right: 4px; }

/* ========== App Layout ========== */
.app { display: flex; height: 100vh; }

.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: transform 0.3s;
}
.sidebar.collapsed { transform: translateX(-100%); position: absolute; z-index: 100; height: 100vh; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header .brand { display: flex; align-items: center; gap: 10px; margin: 0; }
.sidebar-header .logo { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; margin: 0; }
.sidebar-header .brand-name { font-weight: 700; font-size: 1.1rem; }

.menu-toggle {
    background: none; border: none; color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}

.btn-new-chat {
    margin: 12px 16px;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s;
}
.btn-new-chat:hover { background: var(--border); }

.sidebar-nav { padding: 0 12px; }
.nav-section {
    padding: 8px 12px;
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-top: 8px;
}
.nav-item {
    display: block; padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-secondary); text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
    cursor: pointer;
}
.nav-item:hover, .nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.conversation-list {
    flex: 1; overflow-y: auto;
    padding: 0 12px 12px;
}
.conversation-item {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: all 0.15s;
}
.conversation-item:hover, .conversation-item.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.conversation-item::before {
    content: '💬'; margin-right: 8px; opacity: 0.6;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.beta-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-weight: 700; color: #eab308;
    margin-bottom: 6px;
}

/* ========== Main Content ========== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.topbar-title { font-weight: 600; font-size: 1rem; }
.user-menu { display: flex; align-items: center; gap: 16px; }
.user-menu span { color: var(--text-secondary); font-size: 0.9rem; }
.btn-logout {
    background: none; border: 1px solid var(--border);
    color: var(--text-secondary); padding: 6px 14px;
    border-radius: 6px; font-size: 0.85rem; cursor: pointer;
    transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.content { flex: 1; overflow-y: auto; position: relative; }

/* ========== Views ========== */
.view { display: none; padding: 24px; min-height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* Chat View */
.view-chat { padding: 0; }

.welcome {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 40px 20px;
}
.welcome h1 { font-size: 1.8rem; margin-bottom: 8px; }
.welcome p { color: var(--text-secondary); margin-bottom: 32px; }

.quick-prompts {
    display: flex; flex-wrap: wrap; gap: 10px;
    justify-content: center; max-width: 600px;
}
.prompt-chip {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem; cursor: pointer;
    transition: all 0.2s;
}
.prompt-chip:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.messages {
    flex: 1; overflow-y: auto;
    padding: 24px; max-width: 800px;
    margin: 0 auto; width: 100%;
    display: flex; flex-direction: column; gap: 20px;
}

.message {
    display: flex; gap: 12px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-avatar {
    width: 32px; height: 32px;
    border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}
.message.user .message-avatar { background: var(--accent); color: white; }
.message.assistant .message-avatar { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); }

.message-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    max-width: 100%;
    line-height: 1.6;
}
.message.user .message-body { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.3); }

.message-body h1, .message-body h2, .message-body h3 {
    font-size: 1.05rem; margin: 16px 0 8px; color: var(--text-primary);
}
.message-body h1:first-child, .message-body h2:first-child, .message-body h3:first-child { margin-top: 0; }
.message-body p { margin-bottom: 10px; color: var(--text-secondary); }
.message-body ul, .message-body ol { margin: 10px 0 10px 20px; color: var(--text-secondary); }
.message-body li { margin-bottom: 6px; }
.message-body strong { color: var(--text-primary); }

.message-sources {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border);
}
.message-sources-title {
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.source-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.8rem; color: var(--accent);
    text-decoration: none; margin-right: 6px; margin-bottom: 6px;
}
.source-link:hover { text-decoration: underline; }

.input-area {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    background: var(--bg-sidebar);
}
.input-box {
    display: flex; align-items: flex-end; gap: 10px;
    max-width: 800px; margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
}
.input-box textarea {
    flex: 1; background: none; border: none;
    color: var(--text-primary); font-size: 0.95rem;
    resize: none; max-height: 120px;
    outline: none; font-family: inherit;
}
.send-btn {
    width: 36px; height: 36px;
    background: var(--accent); color: white;
    border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem;
    transition: background 0.2s; flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

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

/* Typing indicator */
.typing-indicator {
    display: flex; gap: 4px; padding: 12px 16px;
}
.typing-indicator span {
    width: 8px; height: 8px; background: var(--text-secondary);
    border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Taxonomy View */
.taxonomy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px; margin-top: 20px;
}
.taxonomy-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.taxonomy-card h3 {
    font-size: 1rem; margin-bottom: 4px;
    display: flex; align-items: center; gap: 8px;
}
.taxonomy-card .domain-id {
    font-size: 0.75rem; color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px; border-radius: 4px;
}
.taxonomy-card p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 12px; }
.taxonomy-card ul { list-style: none; }
.taxonomy-card li {
    padding: 6px 0; border-bottom: 1px solid var(--border);
    font-size: 0.85rem; color: var(--text-secondary);
    display: flex; justify-content: space-between;
}
.taxonomy-card li:last-child { border-bottom: none; }
.taxonomy-card .sub-meta {
    font-size: 0.7rem; color: var(--text-secondary); opacity: 0.7;
}

/* Placeholder views */
.placeholder {
    color: var(--text-secondary); text-align: center;
    margin-top: 60px; font-size: 0.95rem;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { position: absolute; z-index: 100; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .messages, .input-area { padding-left: 16px; padding-right: 16px; }
}
