/* WATI Export — mobile-first, dark theme, no external assets. */

[hidden] { display: none !important; }

:root {
  color-scheme: dark light;
  --bg: #0b1220;
  --bg-soft: #101a2e;
  --card: #141f36;
  --card-border: #24334f;
  --text: #e8eef7;
  --muted: #93a1b8;
  --accent: #22d3ee;
  --accent-ink: #062a33;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --btn: #1d2c49;
  --focus: #7dd3fc;
  --radius: 14px;
  --tap: 44px;
  --header-h: 60px;
  --tabbar-h: 68px;
  --maxw: 720px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f5f9;
    --bg-soft: #e8eef6;
    --card: #ffffff;
    --card-border: #d7e0ec;
    --text: #0f1c2e;
    --muted: #5b6b82;
    --accent: #0891b2;
    --accent-ink: #ffffff;
    --btn: #e2eaf3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
@media (min-width: 768px) {
  body { padding-bottom: 32px; }
}

h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1rem; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
strong { font-weight: 700; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; background: rgba(127,127,127,.18); padding: 0 .3em; border-radius: 4px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--card-border);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-weight: 800; font-size: 1.02rem; letter-spacing: .2px; }
.brand-sub { font-size: .75rem; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* Top tabs: hidden on phones, visible ≥768px */
.top-tabs { display: none; }
@media (min-width: 768px) {
  .top-tabs { display: block; border-top: 1px solid var(--card-border); }
  .top-tabs-inner { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 4px; padding: 6px 14px; }
  .top-tabs-inner button {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); background: transparent; border: 0; border-radius: 10px;
    color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
  }
  .top-tabs-inner button svg { width: 18px; height: 18px; }
  .top-tabs-inner button[aria-selected="true"] { background: var(--btn); color: var(--text); }
}

/* Bottom tab bar (phones) */
.bottom-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg-soft);
  border-top: 1px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 768px) { .bottom-tabs { display: none; } }
.bottom-tabs-inner {
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: var(--maxw); margin: 0 auto;
}
.bottom-tabs-inner button {
  appearance: none; background: transparent; border: 0; color: var(--muted);
  font: inherit; font-size: .68rem; font-weight: 600;
  min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; padding: 6px 2px;
}
.bottom-tabs-inner button svg { width: 22px; height: 22px; }
.bottom-tabs-inner button[aria-selected="true"] { color: var(--accent); }

/* Layout */
.container { max-width: var(--maxw); margin: 0 auto; padding: 14px 14px 24px; }
.panel-head { margin: 6px 0 12px; }
.panel-head h1 { margin-bottom: 2px; }
.panel-head.split { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* Hero / landing */
.hero { padding: 22px 16px; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.hero h1 { font-size: 1.6rem; line-height: 1.25; margin-bottom: 8px; }
.hero .muted { margin-bottom: 14px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 480px) { .hero-actions { flex-direction: row; } .hero-actions .btn { flex: 1; } }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: .92rem; }
.steps li::marker { color: var(--accent); font-weight: 800; }

/* Skeleton */
.skeleton-block { min-height: 110px; background: linear-gradient(100deg, var(--card) 30%, rgba(148,163,184,.18) 50%, var(--card) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Status chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--card-border); border-radius: 999px;
  padding: 6px 12px; font-size: .78rem; font-weight: 700; min-height: 32px;
  background: rgba(127,127,127,.08);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.chip.queued .dot { background: var(--warn); }
.chip.running .dot { background: var(--accent); }
.chip.done .dot { background: var(--good); }
.chip.failed .dot, .chip.canceled .dot { background: var(--bad); }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; flex: none;
  background: rgba(34,211,238,.16); color: var(--accent); border: 1px solid currentColor;
}
.badge.ok { background: rgba(52,211,153,.14); color: var(--good); }
.badge.err { background: rgba(248,113,113,.14); color: var(--bad); }
.badge.warn { background: rgba(251,191,36,.14); color: var(--warn); }

/* Export rows */
.row-item {
  border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; background: rgba(127,127,127,.05);
  display: block; color: inherit; text-decoration: none;
}
a.row-item:hover { border-color: var(--accent); }
.row-item:last-child { margin-bottom: 0; }
.row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.row-title { font-weight: 700; overflow-wrap: anywhere; }
.row-meta { font-size: .78rem; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Progress bars */
.prog { margin-top: 8px; }
.prog-row { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 6px; }
.prog-row .prog-label { flex: none; width: 74px; font-weight: 700; }
.prog-row .prog-num { flex: none; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.prog-track { flex: 1; height: 10px; border-radius: 999px; background: rgba(127,127,127,.25); overflow: hidden; min-width: 60px; }
.prog-track > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--card-border); border-radius: 10px;
  min-height: var(--tap); padding: 10px 16px;
  font: inherit; font-weight: 700; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; color: var(--text); background: var(--btn); text-decoration: none;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-secondary { background: transparent; }
.btn-danger { background: #7f1d1d; border-color: #ef4444; color: #fee2e2; }
.btn-ghost { background: transparent; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: rot .7s linear infinite; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.field input, .field select {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--card-border); border-radius: 10px;
  min-height: var(--tap); padding: 8px 12px; width: 100%; max-width: 100%;
}
.check-group { border: 1px solid var(--card-border); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.check-group legend { font-size: .78rem; font-weight: 700; color: var(--muted); padding: 0 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 480px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.form-error { color: var(--bad); font-size: .85rem; margin: 0 0 10px; }
.form-note { margin: 10px 0 0; }

/* Event log */
.log-pre {
  background: #060b16; color: #d6e2f0;
  border: 1px solid var(--card-border); border-radius: 10px;
  padding: 12px; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .76rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-height: 50vh; overflow: auto;
}
@media (prefers-color-scheme: light) { .log-pre { background: #0b1220; color: #d6e2f0; } }
.log-pre code { background: none; padding: 0; font-size: inherit; }
.log-line-err { color: #fca5a5; }
.log-line-warn { color: #fcd34d; }

/* Toast / errors */
.toast-region { position: sticky; top: calc(var(--header-h) + 8px); z-index: 60; max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #7f1d1d; color: #fee2e2; border: 1px solid #ef4444;
  border-radius: 12px; padding: 12px 14px; margin-top: 8px;
  font-size: .88rem;
}
.toast.ok { background: #064e3b; border-color: var(--good); color: #d1fae5; }
.toast button { margin-left: auto; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px; min-width: 44px; min-height: 44px; font: inherit; cursor: pointer; flex: none; }
.section-error {
  background: rgba(248,113,113,.12); border: 1px solid var(--bad); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin: 0 0 12px;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.62);
  display: flex; align-items: flex-end; justify-content: center; padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) { .modal-overlay { align-items: center; } }
.modal {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 16px;
  padding: 18px; width: 100%; max-width: 440px;
}
.modal h2 { margin-bottom: 6px; }
.modal .muted { font-size: .88rem; margin-bottom: 10px; overflow-wrap: anywhere; }
.confirm-hint { margin-bottom: 10px; font-size: .9rem; }
.modal .field input { width: 100%; }
.modal-error { color: var(--bad); font-size: .85rem; margin: 8px 0 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--card-border); border-radius: 12px; }
.empty .btn { margin-top: 10px; }

/* Guest banner: app-shell notice at the top of app pages. It lives in the
   normal document flow (above the page content, below the sticky header),
   so it can never overlap the fixed bottom tab bar; no fixed positioning. */
.guest-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(34,211,238,.10);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: .85rem;
}
.guest-banner-text { flex: 1 1 180px; min-width: 0; }
.guest-banner .btn { flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
