/* Shared styling for the marketing page and both dashboards.
   --brand is overwritten at runtime from the admin-configurable setting. */

:root {
    --brand: #00a884;
    --brand-dark: #008f6f;
    --brand-soft: #e7f7f2;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #111b21;
    --muted: #667781;
    --border: #e4e7eb;
    --danger: #d92d20;
    --danger-soft: #fdf1f0;
    --warn: #b54708;
    --warn-soft: #fff8ea;
    --info: #175cd3;
    --info-soft: #eff4ff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(11, 20, 26, .08);
    --shadow-lg: 0 12px 32px rgba(11, 20, 26, .16);
}

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

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* --- layout --------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 244px;
    flex-shrink: 0;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar .brand .mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--brand); color: #fff;
    display: grid; place-items: center; font-size: 15px;
}

/* align-content keeps the items packed at the top instead of the grid
   stretching them across the full sidebar height. */
.nav { padding: 12px 10px; display: grid; gap: 2px; align-content: start; flex: 1; overflow-y: auto; }
.nav button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 12px;
    background: none; border: none; border-radius: 8px;
    font: inherit; color: var(--muted); text-align: start; cursor: pointer;
}
.nav button:hover { background: var(--bg); color: var(--text); }
.nav button.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav .count {
    margin-inline-start: auto; background: var(--danger); color: #fff;
    border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}

.sidebar .who {
    border-top: 1px solid var(--border);
    padding: 14px 16px;
    display: grid; gap: 8px;
}
.sidebar .who .name { font-weight: 600; }
.sidebar .who .email { color: var(--muted); font-size: 12px; word-break: break-all; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }

.content { padding: 24px 28px 60px; display: grid; gap: 20px; align-content: start; }
.view[hidden] { display: none; }
.view { display: grid; gap: 20px; align-content: start; }

/* --- surfaces ------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card > header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card > header h2 { font-size: 15px; }
.card > header .hint { color: var(--muted); font-size: 12.5px; }
.card > header .spacer { flex: 1; }
.card .body { padding: 20px; display: grid; gap: 14px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --- controls ------------------------------------------------------------- */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field { display: grid; }
.field + .field { margin-top: 12px; }

input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d7db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }
input[type="checkbox"] { width: auto; }
/* A full-width colour well reads as a stray horizontal rule — keep it a swatch. */
input[type="color"] { width: 64px; height: 40px; padding: 4px; cursor: pointer; }
textarea { resize: vertical; min-height: 76px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px;
    border: 1px solid transparent; border-radius: 8px;
    background: var(--brand); color: #fff;
    font-size: 13.5px; font-weight: 600; font-family: inherit;
    cursor: pointer; white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, .btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
button.ghost:hover { background: var(--bg); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b42318; }
button.danger-ghost { background: #fff; color: var(--danger); border-color: #f3c3bf; }
button.danger-ghost:hover { background: var(--danger-soft); }
button.sm, .btn.sm { padding: 6px 11px; font-size: 12.5px; }
button.link { background: none; color: var(--brand-dark); padding: 0; font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

/* --- tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: start; padding: 11px 20px;
    color: var(--muted); font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    background: #fafbfc; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td .stack { display: grid; gap: 2px; }
td .muted, .muted { color: var(--muted); font-size: 12.5px; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.num { font-variant-numeric: tabular-nums; }

/* --- badges --------------------------------------------------------------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: #eef1f3; color: var(--muted); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--brand-soft); color: #05704f; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }

code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 5px;
    word-break: break-all;
}

/* --- feedback ------------------------------------------------------------- */

.notice {
    padding: 12px 14px; border-radius: 9px; font-size: 13px;
    background: var(--info-soft); color: var(--info); border: 1px solid #cddffb;
}
.notice.ok { background: var(--brand-soft); color: #05704f; border-color: #b6e6d6; }
.notice.bad { background: var(--danger-soft); color: var(--danger); border-color: #f3c3bf; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: #f5d9a8; }
.notice[hidden] { display: none; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* --- code blocks & API integration --------------------------------------- */

.codeblock { position: relative; background: #0f1b22; border-radius: 10px; overflow: hidden; }
.codeblock pre { margin: 0; padding: 15px 16px; overflow-x: auto; }
.codeblock pre code {
    display: block; background: none; padding: 0;
    color: #e6edf3; font-size: 12.5px; line-height: 1.65;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre;
}
.codeblock .copy-btn {
    position: absolute; top: 8px; right: 8px;
    padding: 4px 10px; font-size: 12px;
    background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2);
}
.codeblock .copy-btn:hover { background: rgba(255,255,255,.24); }

.lang-tabs { display: inline-flex; gap: 3px; background: var(--bg); padding: 4px; border-radius: 9px; }
.lang-tabs button { background: none; color: var(--muted); padding: 6px 14px; font-size: 13px; font-weight: 600; }
.lang-tabs button:hover { background: none; color: var(--text); }
.lang-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.step { display: grid; grid-template-columns: 32px 1fr; gap: 14px; }
.step .n {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand-dark);
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.step .step-body { display: grid; gap: 10px; min-width: 0; }
.step .endpoint { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }

.method {
    font-family: ui-monospace, monospace; font-weight: 700; font-size: 11px;
    padding: 2px 7px; border-radius: 5px; letter-spacing: .3px;
    background: var(--info-soft); color: var(--info);
}
.method.post { background: #e7f7f2; color: #05704f; }
.method.get { background: var(--info-soft); color: var(--info); }
.method.delete { background: var(--danger-soft); color: var(--danger); }
.method.patch { background: var(--warn-soft); color: var(--warn); }

/* --- direction helpers ---------------------------------------------------- */

/* Pushes an element to the inline end (right in LTR, left in RTL). Replaces
   inline margin-left:auto so it flips with the page direction. */
.push-end { margin-inline-start: auto; }

/* Code, API keys, phone numbers and endpoint paths are always Latin/LTR —
   isolate them so they read correctly inside an RTL page. */
code, .mono { direction: ltr; unicode-bidi: isolate; text-align: start; }
.codeblock { direction: ltr; }

/* --- language switcher ---------------------------------------------------- */

.lang-switch { display: inline-flex; gap: 4px; }
.lang-opt {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 8px;
    background: var(--bg); color: var(--muted);
    border: 1px solid transparent; font-size: 12.5px; font-weight: 600;
}
.lang-opt:hover { background: var(--border); color: var(--text); }
.lang-opt.active { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }
.lang-opt .lang-ico { font-size: 15px; line-height: 1; }
/* In the sidebar the switcher fills the row; each option shares the space. */
.who .lang-switch { display: flex; }
.who .lang-opt { flex: 1; justify-content: center; }

/* Per-language field group in the plan editor. */
.lang-group { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: grid; gap: 10px; background: #fafbfc; }
.lang-group-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.lang-group-title span:first-child { font-size: 16px; }

.toasts { position: fixed; inset-inline-end: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; }
.toast {
    background: #1f2b33; color: #fff;
    padding: 12px 16px; border-radius: 9px;
    box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 380px;
    animation: rise .18s ease-out;
}
.toast.bad { background: var(--danger); }
.toast.ok { background: #05704f; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: rgba(17,27,33,.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- modal ---------------------------------------------------------------- */

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(11, 20, 26, .5);
    display: grid; place-items: center; padding: 20px; z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
    width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
}
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal header h3 { font-size: 16px; }
.modal header .close {
    margin-inline-start: auto; background: none; color: var(--muted);
    font-size: 20px; line-height: 1; padding: 2px 8px;
}
.modal header .close:hover { background: var(--bg); }
.modal .body { padding: 22px; display: grid; gap: 14px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* --- session / qr --------------------------------------------------------- */

.session-card { display: grid; gap: 14px; }
.session-card .head { display: flex; align-items: flex-start; gap: 12px; }
.session-card .head .title { font-weight: 600; font-size: 15px; }
.qr-box { display: grid; place-items: center; gap: 12px; padding: 18px; background: var(--bg); border-radius: 10px; }
.qr-box img { width: 232px; height: 232px; background: #fff; padding: 8px; border-radius: 8px; }
.qr-steps { color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.7; }

.meter { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.meter.high > span { background: var(--warn); }
.meter.full > span { background: var(--danger); }

/* --- plan cards ----------------------------------------------------------- */

/* Flex column rather than grid so the call-to-action can be pushed to the
   bottom edge, keeping buttons aligned across cards of different heights. */
.plan {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.plan > :last-child { margin-top: auto; }
.plan.current { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan h3 { font-size: 17px; }
.plan .price { font-size: 30px; font-weight: 700; }
.plan .price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; display: grid; gap: 8px; font-size: 13.5px; }
.plan li { display: flex; gap: 9px; align-items: flex-start; }
.plan li::before { content: "✓"; color: var(--brand); font-weight: 700; }

/* --- auth pages ----------------------------------------------------------- */

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; }
.auth-card .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.auth-card .logo .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.auth-card .lede { color: var(--muted); margin-bottom: 22px; }
.auth-card button[type="submit"] { width: 100%; margin-top: 6px; padding: 11px; }
.auth-card .alt { text-align: center; margin-top: 18px; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
    .sidebar .who { order: -1; }
    .nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
    .content { padding: 18px 16px 48px; }
    .topbar { padding: 14px 16px; }
}
