/* Sonbola WhatsApp Gateway admin UI. Hand-written, RTL-first, no build step.
   Brand: deep green #1C4536 and wheat gold #D3A03C, taken from the Sonbola mark.
   Chrome (header, buttons, links) carries the brand; message bubbles stay WhatsApp-like on
   purpose, so the log reads as what the customer actually received. */
:root { --bg: #f4f6f4; --card: #fff; --line: #e2e7e3; --text: #16241d; --muted: #66756d;
        --brand: #1C4536; --brand-dark: #123125; --brand-soft: #e8efeb;
        --gold: #D3A03C; --gold-dark: #b07f24; --gold-soft: #fbf1de;
        --green: #1C4536; --green-dark: #123125; --accent: #D3A03C;
        --bubble: #d9fdd3; --bubble-deep: #cdf5c6; --chat: #efeae2;
        --tick: #8696a0; --tick-read: #53bdeb; --link: #1C4536;
        --ok: #1fa855; --warn: #b45309; --bad: #c0392b; --info: #0b6b8a; --radius: 8px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font-family: "Cairo", "Segoe UI", Tahoma, "Noto Naskh Arabic", Arial, sans-serif;
       font-size: 15px; line-height: 1.6; }
a { color: var(--link); text-decoration: none; font-weight: 600; } a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--brand); color: #fff; flex-wrap: wrap; box-shadow: 0 2px 6px rgba(18, 49, 37, .18); }
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .6rem; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand img { width: 30px; height: 31px; display: block; }
.topbar .brand .wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.topbar .brand .wordmark small { font-size: .58rem; letter-spacing: .22em; color: var(--gold); font-weight: 600; }
.topbar nav { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #cfdcd6; font-weight: 500; padding: .15rem 0; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.active { color: #fff; font-weight: 700; border-bottom: 3px solid var(--gold); }
.topbar .user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; } .topbar .user a, .topbar .user button { color: #fff; }
.topbar .user .btn { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.topbar .user .btn:hover { background: rgba(255,255,255,.12); }

.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1rem; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; color: var(--brand); font-weight: 700; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: 0 1px 2px rgba(18, 49, 37, .05); }
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.toolbar { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .6rem; } label.inline { display: inline-flex; align-items: center; gap: .4rem; }
input, select, textarea { display: block; width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fbfcfb; margin-top: .2rem; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(28, 69, 54, .12); }
textarea { resize: vertical; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.btn { display: inline-block; padding: .45rem 1rem; border: 1px solid var(--line); border-radius: 24px; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-soft); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0c9c3; } .btn.danger:hover { background: #fbeeec; }
.btn.small { padding: .22rem .7rem; font-size: .85rem; } .btn.block { width: 100%; } .btn[disabled] { opacity: .6; cursor: default; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; } th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: .8rem; letter-spacing: .02em; } tr:hover td { background: #f7f9f8; }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok { background: #d9f2e0; color: #0b6b3a; } .badge.warn { background: var(--gold-soft); color: var(--gold-dark); } .badge.bad { background: #f9dcd8; color: var(--bad); } .badge.info { background: #dcecf2; color: var(--info); }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #d9f2e0; color: #0b6b3a; border-inline-start: 4px solid var(--ok); } .flash.error { background: #f9dcd8; color: var(--bad); border-inline-start-color: var(--bad); }
.error { color: var(--bad); font-size: .9rem; } .muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: Consolas, "Courier New", monospace; direction: ltr; unicode-bidi: embed; }
.key-reveal { background: var(--gold-soft); border: 1px dashed var(--gold); padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.key-reveal code { display: block; font-size: 1.05rem; word-break: break-all; margin-top: .4rem; font-family: Consolas, "Courier New", monospace; }
.qr { text-align: center; padding: .5rem; } .qr img { width: 260px; height: 260px; image-rendering: pixelated; border: 1px solid var(--line); background: #fff; border-radius: 8px; }
.stat { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--line); } .stat:last-child { border-bottom: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.pagination { display: flex; gap: .4rem; margin-top: 1rem; list-style: none; padding: 0; flex-wrap: wrap; } .pagination a, .pagination span { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; } .pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.timeline { margin: .5rem 0 0; padding: 0 1.2rem; font-size: .88rem; } .timeline li { margin-bottom: .25rem; }
/* chat ground and outgoing bubbles: what the customer actually received */
.chat { background: var(--chat); border-radius: 8px; padding: .5rem .75rem; }
.chat td, .chat th { border-bottom-color: rgba(18, 49, 37, .08); } .chat tr:hover td { background: rgba(255,255,255,.4); }
.bubble { display: inline-block; position: relative; max-width: 380px; min-width: 120px; background: var(--bubble); border-radius: 8px; border-start-start-radius: 0; padding: .4rem .55rem .3rem; box-shadow: 0 1px .5px rgba(18,49,37,.13); color: var(--text); font-size: .93rem; line-height: 1.35; text-align: start; }
.bubble .body { white-space: pre-wrap; word-break: break-word; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; margin-top: .15rem; font-size: .72rem; color: var(--muted); }
.bubble .meta .status { font-weight: 700; }
.ticks { display: inline-flex; align-items: center; color: var(--tick); } .ticks svg { width: 17px; height: 12px; display: block; } .ticks.read { color: var(--tick-read); } .ticks.failed { color: var(--bad); } .ticks.pending { color: var(--tick); }
.doc { display: flex; align-items: center; gap: .6rem; background: var(--bubble-deep); border-radius: 6px; padding: .5rem .6rem; margin-bottom: .3rem; }
.doc .pdf { flex: none; width: 30px; height: 36px; border-radius: 3px; background: #c0392b; color: #fff; font: 700 .6rem/36px "Cairo", Arial, sans-serif; text-align: center; }
.doc .name { flex: 1; min-width: 0; } .doc .name strong { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .doc .name span { font-size: .75rem; color: var(--muted); }
.doc a.open { flex: none; width: 30px; height: 30px; border: 1.5px solid var(--muted); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; } .doc a.open:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
/* sign-in and password pages: the brand ground with the mark watermarked at both edges */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem;
  background: var(--brand) url("../img/sonbola-mark-gold.svg") no-repeat left -60px center / 320px,
              url("../img/sonbola-mark-gold.svg") no-repeat right -60px center / 320px, var(--brand); }
.login-card { background: #fff; border-radius: 14px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 18px 40px rgba(0, 0, 0, .28); text-align: center; }
.login-card .lockup { display: flex; flex-direction: column; align-items: center; gap: .35rem; margin-bottom: 1.25rem; }
.login-card .lockup img { width: 62px; height: 63px; }
.login-card .lockup strong { font-size: 1.5rem; font-weight: 700; color: var(--brand); line-height: 1; }
.login-card .lockup small { font-size: .68rem; letter-spacing: .28em; color: var(--gold); font-weight: 600; }
.login-card h1 { font-size: 1.05rem; color: var(--muted); font-weight: 600; margin: 0 0 1.25rem; }
.login-card form { text-align: start; }
.login-card label { color: var(--text); font-weight: 600; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
@media (max-width: 720px) { .topbar { gap: .75rem; } table { font-size: .85rem; } th, td { padding: .4rem; } .bubble { max-width: 100%; } .login-page { background: var(--brand); } }
/* the credit line at the foot of every admin page */
.site-note { max-width: 1200px; margin: 0 auto 2rem; padding: 1rem; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.site-note a { color: var(--brand); } .site-note .dot { margin: 0 .35rem; color: var(--line); }
/* dial code and number side by side in the test-message form */
.phone-row { display: flex; gap: .5rem; margin-top: .2rem; }
.phone-row select { width: auto; min-width: 118px; flex: 0 0 auto; margin-top: 0; }
.phone-row input { flex: 1; margin-top: 0; }
.topbar .who { color: #cfdcd6; }
