/* ═══════════════════════════════════════════════════════════════════════
   TamanKhoe AI – Knowledge Base Chatbot Design System
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
    --bg: #0f1117;
    --bg-raised: #1a1d27;
    --bg-surface: #222639;
    --bg-hover: #2a2e42;
    --bg-input: #181b25;
    --border: #2e3348;
    --border-focus: #6366f1;

    --text: #e8eaf0;
    --text-secondary: #9ca3b4;
    --text-muted: #6b7280;

    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-glow: rgba(99,102,241,.25);
    --accent: #22d3ee;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,.35);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.2);
    --transition: .2s cubic-bezier(.4,0,.2,1);

    --sidebar-w: 240px;
    --header-h: 56px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ── Utilities ── */
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); }

/* ── Views ── */
.view { display: none; }
.view.active { display: flex; width: 100%; min-height: 100vh; }

/* ══════════════════ LOGIN ══════════════════ */
#login-view {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,.12) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 80%, rgba(34,211,238,.08) 0%, transparent 60%),
                var(--bg);
}

.login-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 12px;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-brand p {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-top: 4px;
}

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

/* ══════════════════ FORM ELEMENTS ══════════════════ */
.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: .9rem;
    transition: border var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-field textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: flex;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary-glow); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 14px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    padding: 6px 10px;
    font-size: .8rem;
}
.btn-danger:hover { background: rgba(248,113,113,.1); }

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

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
    font-size: 1rem;
    transition: all var(--transition);
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

.btn-xs { font-size: .75rem; padding: 3px 5px; }

.btn-sm { font-size: .8rem; padding: 6px 12px; }

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: .85rem;
    transition: color var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-text:hover { color: var(--danger); }

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-info { background: rgba(96,165,250,.12); color: var(--info); border-color: rgba(96,165,250,.25); }
.badge-success { background: rgba(52,211,153,.12); color: var(--success); border-color: rgba(52,211,153,.25); }
.badge-warning { background: rgba(251,191,36,.12); color: var(--warning); border-color: rgba(251,191,36,.25); }
.badge-danger { background: rgba(248,113,113,.12); color: var(--danger); border-color: rgba(248,113,113,.25); }
.badge-tag {
    background: rgba(99,102,241,.1);
    color: var(--primary-hover);
    border-color: rgba(99,102,241,.2);
    font-size: .7rem;
    padding: 2px 8px;
}

/* ══════════════════ SIDEBAR ══════════════════ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.sidebar-brand i {
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 10px;
    flex: 1;
}

.sidebar-nav li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
    font-size: .9rem;
    margin-bottom: 2px;
}

.sidebar-nav li:hover { color: var(--text); background: var(--bg-hover); }

.sidebar-nav li.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), rgba(99,102,241,.7));
    box-shadow: 0 2px 12px var(--primary-glow);
}

.sidebar-nav li i { width: 20px; text-align: center; font-size: .95rem; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

/* ══════════════════ MAIN ══════════════════ */
.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mobile-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-bar h2 { font-size: 1rem; font-weight: 600; }

/* ── Pages ── */
.page { display: none; flex-direction: column; flex: 1; padding: 24px; gap: 20px; }
.page.active { display: flex; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i { color: var(--primary); }

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

/* ══════════════════ CARDS ══════════════════ */
.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i { color: var(--primary); font-size: .9rem; }

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

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.settings-grid .card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ══════════════════ UPLOAD / DROP ZONE ══════════════════ */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 16px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.drop-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.drop-title { font-weight: 600; margin-bottom: 4px; }
.drop-subtitle { font-size: .82rem; color: var(--text-muted); }

.selected-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: .88rem;
}

.selected-file i { color: var(--accent); }
.selected-file span { flex: 1; font-weight: 500; }

.upload-meta .form-row { margin-bottom: 12px; }

/* ══════════════════ DOCUMENT LIST ══════════════════ */
.doc-list { display: flex; flex-direction: column; gap: 8px; }

.doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--transition);
}

.doc-item:hover { border-color: var(--border); background: var(--bg-hover); }

.doc-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.doc-icon.txt { background: rgba(96,165,250,.15); color: var(--info); }
.doc-icon.md { background: rgba(52,211,153,.15); color: var(--success); }
.doc-icon.csv { background: rgba(251,191,36,.15); color: var(--warning); }
.doc-icon.xlsx { background: rgba(52,211,153,.15); color: var(--success); }
.doc-icon.pdf { background: rgba(248,113,113,.15); color: var(--danger); }
.doc-icon.docx { background: rgba(99,102,241,.15); color: var(--primary); }

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

.doc-title {
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.doc-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.doc-actions { display: flex; gap: 4px; flex-shrink: 0; }

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; }

/* ══════════════════ CHAT ══════════════════ */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 0;
    max-height: calc(100vh - 160px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-msg {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    width: 64px; height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 16px;
}

.welcome-msg h3 { font-size: 1.2rem; color: var(--text); margin-bottom: 6px; }
.welcome-msg p { font-size: .9rem; max-width: 400px; margin: 0 auto; }

/* Message bubbles */
.msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: msgIn .3s ease;
}

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

.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    flex-shrink: 0;
}

.msg.user .msg-avatar { background: var(--primary); color: #fff; }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--primary)); color: #fff; }

.msg-body {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 12px 16px;
    border: 1px solid var(--border);
    min-width: 0;
}

.msg.user .msg-body {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

.msg-body p { margin-bottom: 8px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { padding-left: 20px; margin-bottom: 8px; }
.msg-body li { margin-bottom: 4px; }
.msg-body strong { font-weight: 600; }
.msg-body code {
    background: rgba(0,0,0,.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .85em;
}
.msg-body pre {
    background: var(--bg);
    border-radius: var(--radius-xs);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}
.msg-body pre code { background: none; padding: 0; }

/* Sources */
.msg-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.msg-sources-title {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(99,102,241,.1);
    border: 1px solid rgba(99,102,241,.2);
    border-radius: 6px;
    font-size: .75rem;
    color: var(--primary-hover);
    margin-right: 6px;
    margin-bottom: 4px;
}

.source-chip i { font-size: .65rem; }

/* Chat input */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.chat-input-bar input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text);
    font-family: var(--font);
    font-size: .9rem;
    outline: none;
    transition: border var(--transition), box-shadow var(--transition);
}

.chat-input-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-send {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-send:hover { background: var(--primary-hover); transform: scale(1.05); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce .8s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ══════════════════ HEALTH GRID ══════════════════ */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.health-card {
    padding: 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.health-card .provider-name {
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.health-card .status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.health-card .status-dot.ok { background: var(--success); }
.health-card .status-dot.error { background: var(--danger); }
.health-card .status-dot.unknown { background: var(--text-muted); }

.health-card .status-text {
    font-size: .8rem;
    color: var(--text-secondary);
}

/* ══════════════════ LOADING ══════════════════ */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15,17,23,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
}

/* ══════════════════ SCROLLBAR ══════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════ RESPONSIVE ══════════════════ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }

    .main { margin-left: 0; }
    .mobile-bar { display: flex; }

    .page { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .header-actions { width: 100%; }

    .chat-container { max-height: calc(100vh - 120px); border-radius: 0; border-left: none; border-right: none; }

    .msg { max-width: 92%; }

    .settings-grid { grid-template-columns: 1fr; }

    .form-row { flex-direction: column; gap: 0; }

    .doc-item { flex-wrap: wrap; }
    .doc-meta { flex-direction: column; gap: 4px; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .login-card { margin: 16px; padding: 28px 24px; }
    .drop-zone { padding: 24px 16px; }
    .drop-icon { font-size: 2rem; }
}

/* ══════════════════ ATTACHMENT UPLOAD (chat) ══════════════════ */
.btn-attach {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
    font-size: 1rem;
    margin-right: 4px;
}

.btn-attach:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-attach:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.msg-attachment .att-image {
    max-width: 240px;
    max-height: 320px;
    border-radius: 10px;
    display: block;
    object-fit: cover;
    cursor: zoom-in;
    border: 1px solid var(--border);
}

.msg-attachment .att-caption {
    margin-top: 4px;
    font-size: .72rem;
    color: var(--text-muted);
}

.msg-attachment .att-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .88rem;
}

.msg-attachment .att-file a {
    color: var(--text);
    text-decoration: underline;
}

/* ══════════════════ VOICE CLIPS (chat) ══════════════════ */

/* Voice-only assistant message — strip the bubble chrome and just show audio */
.msg.msg-voice-only .msg-body {
    background: transparent;
    border: none;
    padding: 0;
}

.msg.msg-voice-only .voice-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 240px;
}

audio.voice-message {
    width: 100%;
    max-width: 320px;
    height: 40px;
    border-radius: 999px;
    background: var(--bg-surface);
}

/* ══════════════════ PRODUCT GALLERY (chat) ══════════════════ */
.prod-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.prod-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform .15s ease, border-color .15s ease;
}

.prod-card:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.prod-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prod-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.prod-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
}

.prod-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}

.prod-price {
    font-size: .78rem;
    color: var(--accent, #34d399);
    font-weight: 600;
}

.prod-benefit {
    font-size: .72rem;
    color: var(--text-muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 480px) {
    .prod-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .prod-name { font-size: .78rem; }
    .prod-price { font-size: .74rem; }
    .prod-benefit { font-size: .68rem; }
}

/* ══════════════════ FULL-VIEWPORT LAYOUT FIX ══════════════════ */
/* Ensure the app fills the viewport vertically and only the inner
   scrollable areas (chat messages, knowledge list, settings grid)
   actually scroll — the page chrome (header, input bar, sidebar)
   stays put. Uses 100dvh for mobile address-bar correctness. */

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

#app-root {
    height: 100%;
}

.view {
    height: 100dvh;
    height: 100vh; /* fallback */
}

.view.active {
    display: flex;
    width: 100%;
    height: 100dvh;
    height: 100vh;
    min-height: 0;
}

#login-view.active {
    /* Login is the only screen that's allowed to scroll */
    overflow-y: auto;
    height: 100dvh;
}

.main {
    min-height: 0;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
}

.page {
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* Pages other than chat scroll their content area, not the page itself */
#knowledge-page,
#settings-page,
#prompts-page {
    overflow-y: auto;
}

/* Chat fills the remaining vertical space exactly */
.chat-container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-input-bar {
    flex: 0 0 auto;
}

/* Mobile: account for sticky mobile bar height (~52px) */
@media (max-width: 768px) {
    .main {
        height: 100dvh;
        height: 100vh;
    }

    .page {
        height: calc(100dvh - 52px);
        height: calc(100vh - 52px);
        padding: 12px 16px;
    }

    .chat-container {
        max-height: none;
    }
}
