@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* The design system ships Cormorant/Lora; the product overrides them here, as the
   original mockups did. Everything else comes from the DS tokens. */
.bash-app {
    --font-heading: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    /* The DS scale skips 5 and 7 — the mockups referenced --space-5 and silently got
       nothing. Defining them keeps that markup honest rather than collapsing. */
    --space-5: 20px;
    --space-7: 40px;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
}

a { color: var(--color-accent-700); }
a:hover { color: var(--color-accent-900); }

[data-theme="dark"] {
    --color-bg: #1b1815;
    --color-surface: #262220;
    --color-text: #ece8e4;
    --color-accent: #d1a052;
    --color-divider: color-mix(in srgb, #ece8e4 18%, transparent);
    --color-neutral-100: #2d2b2b; --color-neutral-200: #444141; --color-neutral-300: #605d5d;
    --color-neutral-400: #7d7979; --color-neutral-500: #9b9797; --color-neutral-600: #bab6b6;
    --color-neutral-700: #d7d3d3; --color-neutral-800: #eae7e7; --color-neutral-900: #f8f4f4;
    --color-accent-100: #3a270d; --color-accent-200: #5a3b0a; --color-accent-300: #7d5411;
    --color-accent-400: #a06f24; --color-accent-500: #c28d41; --color-accent-600: #e1ad66;
    --color-accent-700: #facb8d; --color-accent-800: #ffe3bf; --color-accent-900: #fff3e4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow-md: 0 3px 12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 14px 34px rgba(0, 0, 0, .6);
}

/* ── shell ──────────────────────────────────────────────────────────────── */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
}

.app-centre {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.nav { background: var(--color-bg); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    flex: none;
}
.status-dot[data-state="off"] { background: var(--color-neutral-500); }
.status-dot[data-state="warn"] { background: var(--color-neutral-400); animation: pulse 1.4s infinite; }

@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.muted { color: var(--color-neutral-600); font-size: 12px; }

/* ── gate ───────────────────────────────────────────────────────────────── */

.otp-row { display: flex; gap: var(--space-2); justify-content: center; }

.otp-box {
    width: 42px;
    height: 52px;
    text-align: center;
    font-size: 20px;
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
    padding: 0;
}

.error-text { color: var(--color-accent-700); font-size: 14px; margin: var(--space-2) 0 0; }

/* ── two-pane layout (chat + admin console) ─────────────────────────────── */

.panes { flex: 1; display: flex; min-height: 0; }

.pane-side {
    width: 300px;
    flex: none;
    border-right: 1px solid var(--color-divider);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pane-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.side-head {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.row-item {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider);
    cursor: pointer;
    border-left: 2px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    display: block;
}
.row-item:hover { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.row-item[aria-selected="true"] {
    background: color-mix(in srgb, var(--color-accent) 11%, transparent);
    border-left-color: var(--color-accent);
}
.row-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }

.row-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 4px;
}

.row-preview {
    font-size: 12px;
    color: var(--color-neutral-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-accent);
    margin-left: auto;
    flex: none;
}

/* ── messages ───────────────────────────────────────────────────────────── */

.thread { flex: 1; overflow-y: auto; padding: var(--space-6) var(--space-4); }

.thread-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.msg-row { display: flex; }
.msg-row[data-role="visitor"] { justify-content: flex-end; }
.msg-row[data-role="assistant"] { justify-content: flex-start; }

.msg-stack { max-width: 75%; display: flex; flex-direction: column; gap: 4px; }
.msg-row[data-role="visitor"] .msg-stack { align-items: flex-end; }

.bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-divider);
    background: var(--color-surface);
    white-space: pre-wrap;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.msg-row[data-role="visitor"] .bubble { background: var(--color-accent-100); }

.msg-time { font-size: 11px; color: var(--color-neutral-500); }

.typing { display: flex; gap: 5px; padding: 12px 16px; border-radius: var(--radius-lg); border: 1px solid var(--color-divider); width: fit-content; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--color-neutral-600); animation: typingDot 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typingDot {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* ── composer ───────────────────────────────────────────────────────────── */

.composer { border-top: 1px solid var(--color-divider); padding: var(--space-4); background: var(--color-bg); }
.composer-inner { max-width: 640px; margin: 0 auto; display: flex; gap: var(--space-2); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; }

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--color-neutral-500);
    padding: var(--space-8);
    text-align: center;
}

/* ── misc ───────────────────────────────────────────────────────────────── */

.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }

.toast {
    position: fixed;
    left: 50%;
    bottom: var(--space-6);
    transform: translateX(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-size: 14px;
    z-index: 60;
    max-width: min(90vw, 460px);
}
.toast[hidden] { display: none; }
.toast[data-kind="error"] { border-color: var(--color-accent-500); }

.tabular { font-variant-numeric: tabular-nums; }

.actions-cell { display: flex; gap: var(--space-1); justify-content: flex-end; flex-wrap: wrap; }

.danger { color: var(--color-accent-700); }

[hidden] { display: none !important; }

@media (max-width: 720px) {
    .pane-side { width: 100%; }
    .panes { flex-direction: column; }
    .pane-side { max-height: 38vh; border-right: none; border-bottom: 1px solid var(--color-divider); }
}
