/* ============================================================
   WATCHTOWER — Shared component library
   Load AFTER wt-tokens.css on every page.
   ============================================================ */

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .04s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost     { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger    { background: var(--neg); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-navy      { background: var(--navy-2); color: var(--on-navy); }
.btn-navy:hover { background: var(--navy-3); }
.btn-sm { font-size: 12px; padding: 7px 12px; border-radius: var(--r-sm); }
.btn-lg { font-size: 15px; padding: 13px 22px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Inputs ─── */
.input, .select, .textarea {
  font-family: var(--font-sans); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 10px 12px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%235f6878' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--text-muted); }

/* Toggle */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 38px; height: 22px; background: var(--border-2); border-radius: 999px; transition: background .15s; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track + .knob { transform: translateX(16px); }

/* Checkbox */
.cbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.cbox input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-2); border-radius: 4px; background: var(--surface); cursor: pointer; position: relative; transition: border-color .15s, background .15s; }
.cbox input:checked { background: var(--accent); border-color: var(--accent); }
.cbox input:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px; border: 2px solid #fff; border-top: 0; border-left: 0; transform: rotate(45deg); }

/* ─── Pills / chips / badges ─── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; line-height: 1.55; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-muted { background: var(--neu-bg); color: var(--neu-ink); }
.pill-accent { background: var(--accent-tint); color: var(--accent-ink); }

/* platform pills */
.pl { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.pl-twitter   { background: var(--p-twitter-bg);   color: var(--p-twitter-ink); }
.pl-instagram { background: var(--p-instagram-bg); color: var(--p-instagram-ink); }
.pl-tiktok    { background: var(--p-tiktok-bg);    color: var(--p-tiktok-ink); }
.pl-youtube   { background: var(--p-youtube-bg);   color: var(--p-youtube-ink); }
.pl-linkedin  { background: var(--p-linkedin-bg);  color: var(--p-linkedin-ink); }

/* keyword pill */
.kw { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 500; background: var(--accent-tint); color: var(--accent-ink); }

/* verdict badge */
.verdict {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
}
.verdict-clean { background: var(--pos-bg); color: var(--pos-ink); }
.verdict-risk  { background: var(--neg-bg); color: var(--neg-ink); }
.verdict-analyzing { background: var(--accent-tint); color: var(--accent-ink); }
.verdict-analyzing .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: wt-pulse 1.5s ease-out infinite; }
@keyframes wt-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* sentiment badge: label + signed score + theme */
.sent {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.sent .score { font-family: var(--font-mono); font-weight: 700; }
.sent .theme { font-weight: 500; opacity: .75; }
.sent-pos { background: var(--pos-bg); color: var(--pos-ink); }
.sent-neg { background: var(--neg-bg); color: var(--neg-ink); }
.sent-neu { background: var(--neu-bg); color: var(--neu-ink); }
.sent-off { background: var(--sent-off-bg); color: var(--sent-off-ink); }

/* status badge (mono, admin) */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 7px; border-radius: var(--r-sm); font-weight: 600;
}
.badge-ok    { background: var(--pos-bg); color: var(--pos-ink); }
.badge-warn  { background: var(--warn-bg); color: var(--warn-ink); }
.badge-err   { background: var(--neg-bg); color: var(--neg-ink); }
.badge-info  { background: var(--accent-tint); color: var(--accent-ink); }
.badge-muted { background: var(--neu-bg); color: var(--neu-ink); }

/* channel scope badge */
.scope { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.scope-watchtower { background: var(--accent-tint); color: var(--accent-ink); }
.scope-influencer { background: #ede9fe; color: #5b21b6; }
.scope-both { background: var(--pos-bg); color: var(--pos-ink); }

/* ─── Cards ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s-6); }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-card); }
.kpi .val { font-size: 32px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; line-height: 1.05; }
.kpi .key { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.kpi .delta { font-family: var(--font-mono); font-size: 11px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--pos); }
.kpi .delta.down { color: var(--neg); }

/* ─── Tables ─── */
.t-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.t-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.t-table td { padding: 12px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; color: var(--text); vertical-align: middle; }
.t-table tr:last-child td { border-bottom: 0; }
.t-table tbody tr:hover td { background: color-mix(in oklab, var(--accent) 3%, var(--surface)); }
.t-table .mono { font-family: var(--font-mono); font-size: 12px; }

/* ─── Filter bar ─── */
.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filterbar .select { width: auto; min-width: 150px; }

/* ─── Slide-over modal ─── */
.sheet-scrim { position: fixed; inset: 0; background: rgba(11,18,32,.45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90; }
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 92vw); background: var(--surface); box-shadow: var(--shadow-pop); transform: translateX(100%); transition: transform .26s cubic-bezier(.4,0,.2,1); z-index: 91; display: flex; flex-direction: column; }
.sheet.open { transform: translateX(0); }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.sheet header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.sheet .body { padding: 22px; overflow-y: auto; flex: 1; }
.sheet .x { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); cursor: pointer; display: grid; place-items: center; color: var(--text-muted); }
.sheet .x:hover { background: var(--surface-2); color: var(--ink); }

/* ─── Tabs (app) ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { appearance: none; background: transparent; border: 0; padding: 13px 16px; cursor: pointer; font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button .lock { width: 12px; height: 12px; opacity: .5; }
.tabs button.locked { color: var(--text-subtle); }

/* ─── Misc ─── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); border: 1px dashed var(--border-2); border-radius: var(--r-lg); background: var(--surface); }
.divider { height: 1px; background: var(--divider); }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.avatar { border-radius: 50%; background: var(--navy-2); color: var(--on-navy); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
[hidden] { display: none !important; }
