/* ============================================================
   VelticAI Dashboard  —  app.css
   Design: dark sidebar + clean white canvas
   Type:   Inter (UI) + JetBrains Mono (data/code)
   Accent: deep indigo #1B4FD8, with slate-50 canvas
   ============================================================ */

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

:root {
    --brand:       #1B4FD8;
    --brand-dark:  #1440B0;
    --brand-light: #EEF3FF;
    --brand-mid:   #3B6FFF;

    --sidebar-bg:  #0F172A;
    --sidebar-fg:  #94A3B8;
    --sidebar-active-bg: rgba(59,111,255,0.15);
    --sidebar-active-fg: #93C5FD;

    --canvas:      #F8FAFC;
    --surface:     #FFFFFF;
    --border:      #E2E8F0;
    --border-dark: #CBD5E1;

    --text-primary:   #0F172A;
    --text-secondary: #475569;
    --text-muted:     #94A3B8;

    --green:  #16A34A;
    --green-light: #DCFCE7;
    --amber:  #D97706;
    --amber-light: #FEF3C7;
    --red:    #DC2626;
    --red-light: #FEE2E2;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);

    --font-ui:   'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --sidebar-w: 224px;
}

html, body { height: 100%; }
body {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--canvas);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Shell layout ─────────────────────────────────────────── */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 0 0 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
}

.logo-mark {
    width: 30px; height: 30px;
    background: var(--brand);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
    font-family: var(--font-ui);
    flex-shrink: 0;
}

.logo-text {
    font-size: 15px;
    font-weight: 600;
    color: #F1F5F9;
    letter-spacing: -0.01em;
}

/* Bot switcher */
.bot-switcher {
    padding: 6px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 8px;
}
.switcher-label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.switcher-select {
    width: 100%;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    color: #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    font-family: var(--font-ui);
    cursor: pointer;
}

/* Nav items */
.sidebar-nav {
    flex: 1;
    padding: 4px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 14px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #E2E8F0; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); }
.nav-item.sub { padding-left: 20px; font-size: 13px; }
.nav-item .ti { font-size: 16px; flex-shrink: 0; }

.badge-count {
    margin-left: auto;
    background: var(--brand);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    font-family: var(--font-mono);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 14px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 12px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: #E2E8F0; }
.user-plan { font-size: 11px; color: var(--text-muted); }
.btn-logout {
    background: none; border: none;
    color: var(--text-muted); font-size: 12px;
    cursor: pointer; display: flex; align-items: center; gap: 5px;
    padding: 4px 0;
    font-family: var(--font-ui);
}
.btn-logout:hover { color: #E2E8F0; }

/* ── Main area ────────────────────────────────────────────── */
.main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 28px 32px; flex: 1; }

/* ── Flash messages ───────────────────────────────────────── */
.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    font-size: 13.5px;
    font-weight: 500;
}
.flash-success { background: var(--green-light); color: var(--green); }
.flash-error   { background: var(--red-light);   color: var(--red); }

/* ── Stat cards ───────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    line-height: 1;
}
.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.stat-card.accent { border-left: 3px solid var(--brand); }
.stat-card.green  { border-left: 3px solid var(--green); }
.stat-card.amber  { border-left: 3px solid var(--amber); }
.stat-card.red    { border-left: 3px solid var(--red); }

/* ── Cards / panels ───────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 18px 22px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-body { padding: 0 22px 22px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--canvas);
}
table.data-table tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover td { background: var(--brand-light); }

/* ── Badges / status pills ────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-ready    { background: var(--green-light);  color: var(--green); }
.badge-draft    { background: #F1F5F9; color: var(--text-secondary); }
.badge-training { background: var(--amber-light);  color: var(--amber); }
.badge-paused   { background: var(--red-light);    color: var(--red); }
.badge-approved { background: var(--green-light);  color: var(--green); }
.badge-incorrect{ background: var(--red-light);    color: var(--red); }
.badge-pending  { background: var(--amber-light);  color: var(--amber); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: var(--font-ui);
    transition: background 0.12s, box-shadow 0.12s;
    text-decoration: none;
}
.btn-primary  { background: var(--brand);  color: #fff; }
.btn-primary:hover  { background: var(--brand-dark); box-shadow: 0 2px 8px rgba(27,79,216,0.3); text-decoration: none; color: #fff; }
.btn-outline  { background: transparent; color: var(--text-primary); border: 1px solid var(--border-dark); }
.btn-outline:hover  { background: var(--canvas); text-decoration: none; color: var(--text-primary); }
.btn-danger   { background: var(--red-light); color: var(--red); }
.btn-danger:hover   { background: #fecaca; text-decoration: none; color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-icon { padding: 7px; }
.btn .ti { font-size: 15px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 5px;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-family: var(--font-ui);
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(27,79,216,0.12);
}
.form-control-mono { font-family: var(--font-mono); font-size: 13px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }

.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
    position: relative; width: 38px; height: 22px;
    display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--border-dark);
    border-radius: 22px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Confidence bar ───────────────────────────────────────── */
.conf-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.conf-track {
    flex: 1;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.conf-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.conf-high  .conf-fill { background: var(--green); }
.conf-mid   .conf-fill { background: var(--amber); }
.conf-low   .conf-fill { background: var(--red); }
.conf-label { font-size: 12px; font-family: var(--font-mono); color: var(--text-muted); width: 34px; text-align: right; }

/* ── Review answer block ──────────────────────────────────── */
.review-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 14px;
    overflow: hidden;
    background: var(--surface);
}
.review-card-header {
    background: var(--canvas);
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.review-q { font-size: 13px; font-weight: 500; color: var(--text-secondary); flex: 1; }
.review-card-body { padding: 14px 18px; }
.review-answer { font-size: 13.5px; color: var(--text-primary); line-height: 1.65; }
.review-sources { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.review-sources a { color: var(--brand); }
.review-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 56px 32px;
    color: var(--text-muted);
}
.empty-state .ti { font-size: 40px; display: block; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; max-width: 280px; margin: 0 auto 18px; line-height: 1.6; }

/* ── Progress / status indicator ─────────────────────────── */
.status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 5px;
}
.dot-green  { background: var(--green); box-shadow: 0 0 0 2px var(--green-light); }
.dot-amber  { background: var(--amber); box-shadow: 0 0 0 2px var(--amber-light); animation: pulse 1.5s infinite; }
.dot-gray   { background: var(--text-muted); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Page-level grids ─────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Section header ───────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { opacity: 0.4; }

/* ── Knowledge source chips ───────────────────────────────── */
.source-grid { display: flex; flex-direction: column; gap: 8px; }
.source-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--canvas);
}
.source-icon { font-size: 18px; color: var(--brand); flex-shrink: 0; }
.source-info { flex: 1; min-width: 0; }
.source-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-meta  { font-size: 11.5px; color: var(--text-muted); }
.source-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; padding-top: 18px; }
.pagination a, .pagination span {
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Utility ──────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }
