/* ══════════════════════════════════════════════════════════
   VESUVIUS INDUSTRIAL AI ASSISTANT — Professional UI
   Fonts: Sora (UI) + IBM Plex Mono (data/code)
   Theme: Industrial dark-navy sidebar, clean white chat
   ══════════════════════════════════════════════════════════ */

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

:root {
    --navy:       #0A1628;
    --navy-mid:   #0F2040;
    --navy-light: #1A304F;
    --blue:       #1D4ED8;
    --blue-l:     #DBEAFE;
    --green:      #15803D;
    --green-l:    #DCFCE7;
    --purple:     #6D28D9;
    --purple-l:   #EDE9FE;
    --red:        #B91C1C;
    --red-l:      #FEF2F2;
    --surface:    #FFFFFF;
    --surface2:   #F8FAFC;
    --surface3:   #F1F5F9;
    --border:     #E2E8F0;
    --border2:    #CBD5E1;
    --text1:      #0F172A;
    --text2:      #475569;
    --text3:      #94A3B8;
    --sans:       'Sora', system-ui, sans-serif;
    --mono:       'IBM Plex Mono', monospace;
    --r:          10px;
    --r-sm:       6px;
    --sidebar-w:  220px;
    --rp-w:       210px;
    --topbar-h:   58px;
    --input-h:    66px;
}

html, body { height: 100%; background: var(--surface2); }

body {
    font-family: var(--sans);
    color: var(--text1);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ── SHELL ──────────────────────────────────────────────── */
.shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.brand-mark {
    width: 36px; height: 36px;
    background: var(--blue);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-name {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    letter-spacing: 0.1em;
}

.brand-sub {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    font-family: var(--mono);
}

.sidebar-section-label {
    font-size: 9.5px;
    font-family: var(--mono);
    font-weight: 500;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.12em;
    padding: 16px 16px 8px;
}

/* Persona list */
.persona-list {
    display: flex;
    flex-direction: column;
    padding: 0 8px;
    gap: 2px;
}

.persona-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s;
    position: relative;
}

.persona-btn:hover { background: rgba(255,255,255,0.06); }

.persona-btn.active {
    background: rgba(255,255,255,0.1);
}

.persona-btn.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 2.5px;
    border-radius: 2px;
    background: var(--accent, #1D4ED8);
}

.persona-icon {
    width: 30px; height: 30px;
    border-radius: 6px;
    background: var(--il);
    color: var(--ic);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.persona-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.persona-name {
    font-size: 11.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-meta {
    font-size: 9.5px;
    color: rgba(255,255,255,0.38);
    font-family: var(--mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.persona-btn.active .persona-dot { opacity: 1; }

.persona-divider {
    padding: 10px 10px 4px;
    font-size: 9px;
    font-family: var(--mono);
    color: rgba(255,255,255,0.22);
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.persona-divider::before, .persona-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

.sidebar-gap { flex: 1; }

/* Analytics mini card */
.analytics-card {
    margin: 0 12px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-sm);
    padding: 12px;
}

.analytics-title {
    font-size: 9px;
    font-family: var(--mono);
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.analytics-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.al { font-size: 10px; color: rgba(255,255,255,0.45); }
.av { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.85); font-family: var(--mono); }

.sidebar-footer {
    padding: 10px 16px;
    font-size: 9.5px;
    font-family: var(--mono);
    color: rgba(255,255,255,0.2);
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── MAIN ───────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    min-width: 0;
    border-right: 1px solid var(--border);
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-badge {
    font-size: 10px;
    font-family: var(--mono);
    padding: 3px 9px;
    border-radius: 4px;
    border: 1px solid currentColor;
    color: var(--blue);
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s, border-color 0.2s;
}

.topbar-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.kb-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.kb-tag {
    font-size: 9.5px;
    font-family: var(--mono);
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--surface3);
    border: 1px solid var(--border);
    color: var(--text3);
    white-space: nowrap;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text3);
    white-space: nowrap;
}

.status-dot-live {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #22C55E;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%,100% { opacity:1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { opacity:0.7; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

/* Chat box */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 24px 22px 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar { width: 4px; }
.chat-box::-webkit-scrollbar-track { background: transparent; }
.chat-box::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Welcome card */
.welcome-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 20px;
    border-left: 3px solid var(--accent-col, var(--blue));
    animation: msgIn 0.22s ease;
}

.welcome-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text1);
    margin-bottom: 6px;
}

.welcome-card-body {
    font-size: 12.5px;
    color: var(--text2);
    line-height: 1.6;
    margin-bottom: 12px;
}

.welcome-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.welcome-pill {
    font-size: 10px;
    font-family: var(--mono);
    padding: 3px 9px;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text3);
}

/* Messages */
.msg {
    display: flex;
    gap: 10px;
    animation: msgIn 0.22s ease;
}

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

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

.msg-avatar {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9.5px;
    font-family: var(--mono);
    font-weight: 500;
    flex-shrink: 0;
    margin-top: 2px;
}

.msg-body { max-width: 82%; display: flex; flex-direction: column; gap: 5px; }
.msg.user .msg-body { align-items: flex-end; }

.msg-meta {
    font-size: 9.5px;
    font-family: var(--mono);
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: 5px;
}

.msg-meta-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
}

.msg-bubble {
    padding: 11px 14px;
    border-radius: var(--r);
    line-height: 1.65;
    font-size: 13.5px;
    border: 1px solid var(--border);
}

.msg.user .msg-bubble {
    background: var(--surface2);
    color: var(--text1);
    border-color: var(--border2);
}

.msg.bot .msg-bubble {
    background: var(--surface);
    color: var(--text1);
}

.msg-source {
    font-size: 10px;
    font-family: var(--mono);
    color: var(--text3);
    padding: 5px 10px;
    background: var(--surface2);
    border-radius: 4px;
    border-left: 2px solid var(--accent-col, var(--blue));
}

/* Loader */
.loader-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 11px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 12px;
    color: var(--text3);
    font-family: var(--mono);
}

.dot-pulse {
    display: flex;
    gap: 4px;
}

.dot-pulse span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text3);
    animation: dotBounce 1s infinite;
}
.dot-pulse span:nth-child(2) { animation-delay: 0.15s; }
.dot-pulse span:nth-child(3) { animation-delay: 0.3s; }

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

/* Quick prompts */
.quick-row {
    padding: 0 22px 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.quick-btn {
    font-size: 11px;
    font-family: var(--mono);
    padding: 5px 11px;
    border-radius: 5px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quick-btn:hover {
    background: var(--surface3);
    color: var(--text1);
    border-color: var(--accent-col, var(--blue));
}

/* Input bar */
.input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.input-wrap {
    flex: 1;
    position: relative;
}

#userInput {
    width: 100%;
    padding: 11px 52px 11px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border2);
    background: var(--surface2);
    font-family: var(--sans);
    font-size: 13.5px;
    color: var(--text1);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#userInput::placeholder { color: var(--text3); }

#userInput:focus {
    border-color: var(--accent-col, var(--blue));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-col, var(--blue)) 12%, transparent);
}

.input-lang {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    font-family: var(--mono);
    color: var(--text3);
    background: var(--surface);
    padding: 2px 5px;
    border-radius: 3px;
    pointer-events: none;
    border: 1px solid var(--border);
}

.send-btn {
    width: 40px; height: 40px;
    border-radius: var(--r);
    border: none;
    background: var(--accent-col, var(--blue));
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}

.send-btn:hover { opacity: 0.88; }
.send-btn:active { transform: scale(0.95); }

/* ── RIGHT PANEL ────────────────────────────────────────── */
.right-panel {
    width: var(--rp-w);
    background: var(--surface2);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.rp-section-label {
    font-size: 9.5px;
    font-family: var(--mono);
    font-weight: 500;
    color: var(--text3);
    letter-spacing: 0.1em;
    padding: 14px 14px 10px;
}

.rp-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 10px 10px;
}

.rp-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px 10px 8px;
}

.rp-stat-val {
    font-size: 22px;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--text1);
    line-height: 1;
    margin-bottom: 3px;
}

.rp-stat-label {
    font-size: 9.5px;
    color: var(--text3);
    font-family: var(--mono);
}

.conf-bar-wrap {
    height: 3px;
    background: var(--border);
    margin: 0 10px 12px;
    border-radius: 2px;
}

.conf-bar-fill {
    height: 3px;
    background: #22C55E;
    border-radius: 2px;
    transition: width 0.4s;
}

/* Log */
.rp-log {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.rp-log::-webkit-scrollbar { width: 3px; }
.rp-log::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.rp-empty {
    font-size: 11px;
    color: var(--text3);
    font-family: var(--mono);
    text-align: center;
    padding: 24px 8px;
    line-height: 1.6;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.log-time {
    font-size: 9px;
    font-family: var(--mono);
    color: var(--text3);
    margin-bottom: 2px;
}

.log-q {
    font-size: 10.5px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.log-badge {
    font-size: 9px;
    font-family: var(--mono);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

/* KB status */
.rp-gap-section {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.kb-status-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 0;
}

.kb-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kb-status-name {
    font-size: 10.5px;
    color: var(--text2);
    flex: 1;
}

.kb-status-val {
    font-size: 9.5px;
    font-family: var(--mono);
    color: #22C55E;
}

/* ── MARKDOWN-LIKE response formatting ───── */
.msg-bubble b, .msg-bubble strong { font-weight: 600; }
.msg-bubble br + br { display: block; content: ''; margin-top: 6px; }

/* Responsive: hide right panel on narrow screens */
@media (max-width: 900px) {
    .right-panel { display: none; }
    :root { --rp-w: 0px; }
}

@media (max-width: 680px) {
    :root { --sidebar-w: 0px; }
    .sidebar { display: none; }
}
