/* ============================================================
   WhatsApp Hub — console styles
   Layout is a literal 25% / 75% split as specified.
   ============================================================ */

:root {
    --bg: #0b141a;
    --bg-soft: #111b21;
    --panel: #15202b;
    --panel-2: #1c2b36;
    --line: #22303c;
    --text: #e9edef;
    --muted: #8696a0;
    --green: #00a884;
    --green-dark: #008069;
    --red: #ef697a;
    --amber: #f5a623;
    --blue: #53bdeb;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

/* ------------------------------- login */

.login-wrap {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 50% -10%, #16332c 0%, var(--bg) 60%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--green), var(--green-dark));
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 20px;
    color: #06231d;
}

.login-card h1 { font-size: 20px; }

/* ------------------------------- shell */

.shell {
    display: grid;
    grid-template-columns: 25% 75%;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand-title { font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: #1a2733; color: var(--text); }

.nav-item.active {
    background: #12312a;
    color: var(--green);
    box-shadow: inset 3px 0 0 var(--green);
}

.nav-icon { width: 18px; text-align: center; font-size: 15px; }
.nav-text { flex: 1; }

.nav-badge {
    font-size: 11px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #22303c;
    color: var(--muted);
    display: none;
    align-items: center;
    justify-content: center;
}

.nav-badge.show { display: inline-flex; }
.nav-badge.alert { background: var(--green); color: #06231d; font-weight: 600; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

.totals {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.totals div { display: flex; justify-content: space-between; }
.totals b { font-weight: 600; }

/* ------------------------------- content */

.content { padding: 26px 30px 60px; min-width: 0; }

.content-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.content-head h2 { font-size: 22px; }
.content-head .muted { font-size: 13px; margin-top: 4px; }

/* ------------------------------- primitives */

.btn {
    font: inherit;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 9px 15px;
    cursor: pointer;
    background: #22303c;
    color: var(--text);
    transition: filter .15s, background .15s;
}

.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #06231d; font-weight: 600; }
.btn-danger { background: transparent; border-color: #5a2a33; color: var(--red); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }

input[type=text], input[type=password], input[type=tel], select, textarea {
    font: inherit;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text);
    padding: 10px 12px;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green);
}

textarea { min-height: 110px; resize: vertical; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-head h3 { font-size: 16px; }
.card-head .muted { font-size: 13px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 6px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.pill::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.pill-online { background: rgba(0, 168, 132, .15); color: var(--green); }
.pill-offline { background: rgba(239, 105, 122, .14); color: var(--red); }
.pill-warn { background: rgba(245, 166, 35, .14); color: var(--amber); }
.pill-idle { background: rgba(134, 150, 160, .14); color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #182531; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty {
    text-align: center;
    padding: 46px 20px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.empty h3 { color: var(--text); margin-bottom: 8px; }

.alert { border-radius: 9px; padding: 11px 13px; font-size: 13px; margin-top: 12px; }
.alert-error { background: rgba(239, 105, 122, .12); border: 1px solid rgba(239, 105, 122, .3); color: #ffc9d1; }
.alert-ok { background: rgba(0, 168, 132, .12); border: 1px solid rgba(0, 168, 132, .3); color: #96ebd5; }
.alert-info { background: rgba(83, 189, 235, .1); border: 1px solid rgba(83, 189, 235, .28); color: #bfe8f8; }

.key-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    max-width: 320px;
}

.key-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 6px;
    background: #22303c;
    color: var(--muted);
    margin-left: 6px;
}

.tag-default { background: rgba(0, 168, 132, .18); color: var(--green); }

/* ------------------------------- pairing / QR */

.pair-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }

.qr-stage {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    width: 268px;
    height: 268px;
    display: grid;
    place-items: center;
    margin: 0 auto;
}

.qr-stage img { width: 100%; height: 100%; object-fit: contain; }

.qr-placeholder {
    width: 268px;
    height: 268px;
    margin: 0 auto;
    border-radius: 14px;
    border: 1px dashed var(--line);
    display: grid;
    place-items: center;
    color: var(--muted);
    text-align: center;
    padding: 20px;
    font-size: 13px;
}

.steps { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 12px; }

.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: 14px; }
.steps li .dot {
    width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%;
    border: 2px solid var(--line); display: grid; place-items: center; font-size: 11px;
}
.steps li.done { color: var(--text); }
.steps li.done .dot { background: var(--green); border-color: var(--green); color: #06231d; }
.steps li.active .dot { border-color: var(--amber); }
.steps li.active { color: var(--amber); }

.center { text-align: center; }

/* ------------------------------- test send */

.segmented { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.segmented button {
    font: inherit; font-size: 13px; border: none; background: transparent; color: var(--muted);
    padding: 7px 13px; border-radius: 7px; cursor: pointer;
}
.segmented button.on { background: var(--green); color: #06231d; font-weight: 600; }

.phone-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.phone-preview { font-size: 13px; color: var(--muted); margin-top: 7px; }
.phone-preview b { color: var(--green); font-weight: 600; }

pre.out {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    font-size: 12.5px;
    max-height: 260px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- page 5: API guide (rendered markdown) ---------- */

.doc {
    font-size: 13.5px;
    line-height: 1.62;
    color: var(--text);
    overflow-wrap: break-word;
}

.doc > :first-child { margin-top: 0; }
.doc h1, .doc h2, .doc h3, .doc h4 { line-height: 1.3; margin: 26px 0 8px; }
.doc h1 { font-size: 20px; }
.doc h2 { font-size: 17px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.doc h3 { font-size: 14.5px; color: var(--green); }
.doc h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.doc p { margin: 9px 0; }
.doc ul, .doc ol { margin: 9px 0; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0; }
.doc a { color: var(--blue); }
.doc hr { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.doc blockquote {
    margin: 10px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--green-dark);
    background: var(--bg-soft);
    color: var(--muted);
    border-radius: 0 8px 8px 0;
}

.doc code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.3px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
}

.doc pre {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    overflow: auto;
    margin: 12px 0;
}

.doc pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 12.2px;
    line-height: 1.55;
    white-space: pre;
    display: block;
    color: #d7e2ea;
}

.doc table {
    display: block;
    width: 100%;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 12.6px;
}

.doc th, .doc td { padding: 8px 10px; }
.doc td code { white-space: nowrap; }

.guide-toolbar .row-actions { justify-content: flex-start; margin-top: 14px; }
.guide-note { font-size: 12.3px; line-height: 1.5; margin-top: 12px; }

details.code-file {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--bg-soft);
}

details.code-file > summary {
    cursor: pointer;
    padding: 10px 13px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--muted);
    list-style: none;
}

details.code-file > summary::-webkit-details-marker { display: none; }
details.code-file > summary::before { content: '▸ '; color: var(--green); }
details.code-file[open] > summary::before { content: '▾ '; }
details.code-file > summary:hover { color: var(--text); }
details.code-file pre {
    margin: 0;
    border: none;
    border-top: 1px solid var(--line);
    border-radius: 0 0 10px 10px;
    max-height: 420px;
    overflow: auto;
}
details.code-file pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 12.2px;
    color: #d7e2ea;
    white-space: pre;
    display: block;
}

/* ------------------------------- inbox */

.inbox-toolbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.inbox-toolbar .field { margin: 0; min-width: 220px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-bottom: 11px; }

.msg-list { display: flex; flex-direction: column; gap: 10px; }

.msg {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    border-radius: 10px;
    padding: 13px 15px;
}

.msg.out { border-left-color: var(--blue); }
.msg.in { border-left-color: var(--green); }

.msg-head { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.msg-head .who { color: var(--text); font-weight: 600; font-size: 13.5px; }
.msg-head .time { margin-left: auto; }
.msg-body { margin-top: 8px; font-size: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }

.msg-media { margin-top: 10px; }
.msg-media img { max-width: 260px; border-radius: 8px; display: block; }

.badge {
    font-size: 11px; padding: 2px 7px; border-radius: 5px;
    background: #22303c; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
}

/* ------------------------------- toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }

.toast {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--green);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
    font-size: 13.5px;
    max-width: 340px;
    animation: pop .18s ease-out;
}

.toast.err { border-left-color: var(--red); }

@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ------------------------------- responsive */

@media (max-width: 1000px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .pair-layout, .grid-2 { grid-template-columns: 1fr; }
}
