/* AI Call Agent — Customer UI
 *
 * Shared CSS, derived from poi-billing's checkout.html design tokens
 * (Source Sans 3 + Source Code Pro, monochrome palette, 8 px radius).
 * Single source of truth so all pages look like one product.
 */

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

:root {
    --text: #1a1a1a;
    --text-secondary: #6e6e73;
    --text-tertiary: #9a9a9f;
    --border: #e8e8ed;
    --border-strong: #ccc;
    --bg: #fff;
    --bg-page: #fafafa;
    --bg-input: #fff;
    --bg-hover: #f5f5f7;
    --accent: #1a1a1a;
    --accent-hover: #333;
    --green: #1a7f37;
    --green-bg: #f0fdf0;
    --red: #cf222e;
    --red-bg: #fff5f5;
    --amber: #9a6700;
    --amber-bg: #fff8c5;
    --blue: #0969da;
    --blue-bg: #ddf4ff;

    --font: 'Source Sans 3', -apple-system, system-ui, sans-serif;
    --mono: 'Source Code Pro', ui-monospace, monospace;
    --radius: 8px;
    --radius-sm: 6px;
}

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

a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--text-tertiary); }

/* ── Single-column "centered" layouts (landing, login) ───────── */
.page {
    max-width: 520px;
    margin: 0 auto;
    padding: 64px 24px 80px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}
.page-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.section { margin-bottom: 40px; }
.section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

/* ── Card surface (the only structural container we use) ─────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.card.dense { padding: 16px; }

/* ── Form elements ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 20px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--text-tertiary); }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-tertiary); }
.field input.mono,
.field textarea.mono { font-family: var(--mono); font-size: 13px; letter-spacing: -0.01em; }
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.field-help { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.btn-dark {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-dark:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-dark:disabled { opacity: 0.35; cursor: default; }
.btn-dark:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn-block { display: flex; width: 100%; }
.btn-sm { height: 32px; font-size: 13px; padding: 0 12px; }
.btn-link {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border);
    height: auto;
    padding: 0;
}
.btn-link:hover { color: var(--text); background: transparent; border-color: transparent; }

/* ── Inline status messages ──────────────────────────────────── */
.msg {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-top: 14px;
}
.msg-ok { background: var(--green-bg); color: var(--green); }
.msg-err { background: var(--red-bg); color: var(--red); }
.msg-warn { background: var(--amber-bg); color: var(--amber); }
.msg-info { background: var(--blue-bg); color: var(--blue); }
.msg.hide { display: none; }

/* ── Pills & badges ──────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.pill-ok    { background: var(--green-bg); color: var(--green); }
.pill-err   { background: var(--red-bg);   color: var(--red); }
.pill-warn  { background: var(--amber-bg); color: var(--amber); }
.pill-info  { background: var(--blue-bg);  color: var(--blue); }

/* ── App shell (sidebar + main) ──────────────────────────────── */
.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 32px;
    text-decoration: none;
    color: var(--text);
}
.brand .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active {
    background: var(--bg-hover);
    color: var(--text);
    font-weight: 500;
}

.main {
    padding: 40px 48px;
    max-width: 980px;
    width: 100%;
}
.main-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}
.main-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.main-sub {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Stats grid (dashboard) ─────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 32px; }
.stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.stat-hint  { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 16px; }
.table th {
    font-weight: 600;
    color: var(--text-tertiary);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
}
.table td { border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: var(--bg-page); }

/* ── Chat surface ───────────────────────────────────────────── */
.chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.bubble-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bubble-bot {
    align-self: flex-start;
    background: var(--bg-hover);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.bubble-event {
    align-self: center;
    background: var(--blue-bg);
    color: var(--blue);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
}
.chat-input {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input textarea {
    flex: 1;
    min-height: 40px;
    max-height: 200px;
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    resize: none;
    line-height: 1.5;
}
.chat-input textarea:focus { border-color: var(--text-tertiary); }
.chat-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    margin-top: 80px;
}

/* ── Helpers ────────────────────────────────────────────────── */
.row { display: flex; gap: 8px; align-items: center; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; }
.spacer { flex: 1; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-mono { font-family: var(--mono); font-size: 13px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.muted { color: var(--text-secondary); }
.code-block {
    background: #f6f8fa;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-mask.hide { display: none; }
.modal {
    background: var(--bg);
    border-radius: var(--radius);
    width: 90%; max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 720px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-item { white-space: nowrap; }
    .main { padding: 24px 16px; }
}
