/* ══════════════════════════════════════════════════════════════════
   main.css — CCCT shared stylesheet
   Loaded by base.html and base_public.html via <link>
   ══════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --border: #e2e0da;
  --text: #1a1a18;
  --muted: #6b6a65;
  --accent: #1a3a6b;
  --accent-light: #e8edf5;
  --danger: #a32d2d;
  --danger-light: #fcebeb;
  --warn: #854f0b;
  --warn-light: #faeeda;
  --ok: #0f6e56;
  --ok-light: #e1f5ee;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Layout ──────────────────────────────────────────────────────── */
main { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Card ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Forms ───────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; margin-top: 0.75rem; }
label:first-of-type { margin-top: 0; }
input, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); background: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1.5rem; }

/* ── Submit button (form default) ────────────────────────────────── */
button[type=submit] {
  margin-top: 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
button[type=submit]:hover { opacity: 0.88; }

/* ── General-purpose button classes ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover    { opacity: 0.88; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 5px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; border-radius: 4px; }

.btn-primary  { background: var(--accent);       color: #fff; }
.btn-success  { background: var(--ok);            color: #fff; }
.btn-danger   { background: var(--danger-light);  color: var(--danger); border: 1px solid #f09595; }
.btn-warn     { background: var(--warn-light);    color: var(--warn);   border: 1px solid #fac775; }
.btn-ghost    { background: var(--bg);            color: var(--muted);  border: 1px solid var(--border); }
.btn-accent   { background: var(--accent-light);  color: var(--accent); border: 1px solid var(--accent); }
.btn-ok       { background: var(--ok-light);      color: var(--ok);     border: 1px solid #9fe1cb; }

/* ── Flash / alert messages ──────────────────────────────────────── */
.flash-ok, .flash-warn, .flash-err, .flash-error {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 13px;
  border: 1px solid;
}
.flash-ok    { background: var(--ok-light);     color: var(--ok);     border-color: #9fe1cb; }
.flash-warn  { background: var(--warn-light);   color: var(--warn);   border-color: #fac775; }
.flash-err   { background: var(--danger-light); color: var(--danger); border-color: #f09595; }
.flash-error { background: var(--danger-light); color: var(--danger); border-color: #f7c1c1; margin-bottom: 1.5rem; }

/* ── Status / feature badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.badge-ok      { background: var(--ok-light);     color: var(--ok);     }
.badge-warn    { background: var(--warn-light);   color: var(--warn);   }
.badge-err     { background: var(--danger-light); color: var(--danger); }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ── Data tables ─────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead tr { border-bottom: 1px solid var(--border); background: var(--bg); }
.data-table th {
  text-align: left;
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table td { padding: 9px 0; }
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table .td-right  { text-align: right; }
.data-table .td-muted  { color: var(--muted); }
.data-table .td-sm     { font-size: 12px; color: var(--muted); }
.data-table .td-bold   { font-weight: 500; }
.data-table .td-nowrap { white-space: nowrap; }

/* ── KPI card grid ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 26px; font-weight: 500; margin-top: 4px; }
.kpi-sub   { font-size: 11px; color: var(--muted); }

/* ── Metric cards (superadmin cluster quality metrics) ───────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.metric-card { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; }
.metric-card .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-card .value { font-size: 20px; font-weight: 500; margin-top: 2px; }

/* ── Stat box grid (scrape status panel) ─────────────────────────── */
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.75rem 0; }
.stat-box    { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.75rem; text-align: center; }
.stat-num    { font-size: 20px; font-weight: 600; line-height: 1.1; }
.stat-lbl    { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Superadmin two-column layout ────────────────────────────────── */
.sa-wrap    { display: flex; gap: 2rem; align-items: flex-start; }
.sa-sidebar { width: 180px; flex-shrink: 0; position: sticky; top: 1rem; }
.sa-content { flex: 1; }
.sa-sb-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}
.sa-sb-link:hover { background: var(--bg); }

/* ── Page header row (title + optional CTA) ──────────────────────── */
.page-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.page-hdr h2, .page-hdr h1 { font-size: 18px; font-weight: 500; }
.page-title { font-size: 20px; font-weight: 500; margin-bottom: 1.25rem; }

/* ── Auth page layout ────────────────────────────────────────────── */
.auth-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.auth-box h1    { font-size: 20px; font-weight: 500; margin-bottom: 0.25rem; }
.auth-sub       { font-size: 13px; color: var(--muted); margin-bottom: 1.75rem; }
.auth-footer    { text-align: center; font-size: 13px; color: var(--muted); margin-top: 1.25rem; }
.auth-footer a  { color: var(--accent); font-weight: 500; }

/* ── OAuth button & divider ──────────────────────────────────────── */
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  margin-bottom: 1.25rem;
  transition: background 0.15s;
  cursor: pointer;
}
.oauth-btn:hover { background: #f5f5f5; }
.oauth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.oauth-divider hr   { flex: 1; border: none; border-top: 1px solid var(--border); }
.oauth-divider span { font-size: 12px; color: var(--muted); }

/* ── Topbar (dark brand bar at the very top) ─────────────────────── */
header { background: var(--accent); color: #fff; display: flex; flex-direction: column; }
.topbar {
  background: #0d2044;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 44px;
  gap: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar-logo     { display: flex; align-items: center; flex-shrink: 0; text-decoration: none; }
.topbar-logo img { height: 26px; width: auto; filter: brightness(0) invert(1); opacity: 0.9; }
.topbar-sep      { width: 1px; height: 16px; background: rgba(255,255,255,0.15); margin: 0 4px; flex-shrink: 0; }
.topbar-name     { color: rgba(255,255,255,0.5); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.topbar-right    { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.topbar-user     { color: rgba(255,255,255,0.4); font-size: 11px; }
.topbar-role {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 4px;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.topbar-signout {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.03em;
  transition: color 0.15s;
}
.topbar-signout:hover { color: rgba(255,255,255,0.85); }

/* Public variant: sign-in / register buttons in topbar */
.topbar-signin {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}
.topbar-signin:hover { color: rgba(255,255,255,0.9); }
.topbar-register {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  transition: background 0.15s;
}
.topbar-register:hover { background: rgba(255,255,255,0.18); }

/* ── Main nav bar ────────────────────────────────────────────────── */
.mainnav {
  background: #1a3a6b;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 40px;
  gap: 0;
}
.nav-link {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13px;
  padding: 0 14px;
  height: 40px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover { color: #fff; border-bottom-color: rgba(255,255,255,0.4); }
.nav-sep      { width: 1px; height: 16px; background: rgba(255,255,255,0.15); margin: 0 8px; }
.nav-sa {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 12px;
  background: rgba(255,255,255,0.12);
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 500;
}
.nav-admin {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 12px;
  padding: 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 5px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-admin:hover { color: #fff; border-bottom-color: rgba(255,255,255,0.3); }

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
  background: #111c30;
  color: #c9d0dc;
  margin-top: 4rem;
  padding: 3rem 2rem 1.5rem;
}
.footer-inner   { max-width: 900px; margin: 0 auto; }
.footer-grid    { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 2.5rem; margin-bottom: 2.5rem; }
.footer-logo    { height: 48px; width: auto; margin-bottom: 1rem; display: block; }
.footer-tagline { font-size: 13px; line-height: 1.7; color: #8a93a6; max-width: 260px; margin: 0 0 1rem; }
.footer-li      {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #8a93a6;
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}
.footer-li:hover { color: #fff; }
.footer-col-hdr {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5a6478;
  margin-bottom: 1rem;
}
.footer-link {
  display: block;
  font-size: 13px;
  color: #8a93a6;
  text-decoration: none;
  margin-bottom: 6px;
  transition: color 0.15s;
}
.footer-link:hover { color: #fff; }
.footer-bar {
  border-top: 1px solid #1e2b42;
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.footer-copy        { font-size: 12px; color: #5a6478; }
.footer-legal       { display: flex; gap: 1.25rem; }
.footer-legal-link  { font-size: 11px; color: #5a6478; text-decoration: none; transition: color 0.15s; }
.footer-legal-link:hover { color: #8a93a6; }
.footer-disclaimer  { font-size: 11px; color: #3d4a5e; margin-top: 1rem; line-height: 1.6; }

/* ── Inline code chip ────────────────────────────────────────────── */
.code-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

/* ── Meta/section heading label ──────────────────────────────────── */
.meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

/* ── Usage progress bar ──────────────────────────────────────────── */
.usage-bar-track { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.usage-bar-fill  { height: 6px; border-radius: 4px; }

/* ── Superadmin sidebar extras ───────────────────────────────────── */
.sa-nav-icon  { font-size: 14px; }
.sa-sidebar-div { border-top: 1px solid var(--border); margin: 1rem 0 .75rem; }

/* ── Job status pulse (sidebar indicator + drawer dot) ───────────── */
@keyframes jdpulse { 0%,100%{opacity:1} 50%{opacity:.3} }
#jd-sb-indicator {
  display: none;
  margin-top: 1rem;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--warn-light);
  cursor: pointer;
  align-items: center;
  gap: 8px;
}
#jd-sb-dot   { width:7px; height:7px; background:var(--warn); border-radius:50%; flex-shrink:0; animation:jdpulse 1.2s infinite; }
#jd-sb-label { font-size:12px; color:var(--warn); font-weight:500; }

/* ── Text color utilities ────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-ok      { color: var(--ok); }
.text-warn    { color: var(--warn); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--muted); }

/* ── Superadmin sidebar section heading ──────────────────────────── */
.sa-sidebar-hdr {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .75rem;
}
.sa-sb-link--active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

/* ── Superadmin dashboard quick-action cards ─────────────────────── */
.sa-dash-card {
  display: block;
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: box-shadow .15s;
}
.sa-dash-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.sa-dash-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }

/* ── Form helpers ────────────────────────────────────────────────── */
.field-hdr  { font-size:13px; font-weight:500; display:block; margin-bottom:.4rem; }
.field-lbl  { font-size:12px; color:var(--muted); display:block; margin-bottom:3px; }
.field-help { font-size:11px; color:var(--muted); margin-top:4px; }
.field-row  { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin-bottom:1rem; }
.field-section-title { font-size:13px; font-weight:500; margin-bottom:.75rem; }
.input-sm   { width:130px; }
.input-wide { max-width:380px; }
.textarea-code {
  width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:6px;
  font-size:13px; background:var(--bg); resize:vertical; font-family:monospace;
}

/* ── Card header row (flex, space-between) ───────────────────────── */
.card-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem; }
.card-row-title { font-size:13px; font-weight:500; }

/* ── Spacing & size utilities ────────────────────────────────────── */
.mb-1       { margin-bottom:1rem; }
.mb-2       { margin-bottom:1.5rem; }
.link-sm    { font-size:12px; }
.ml-auto    { margin-left:auto; }
.form-inline { display:inline; }
.card--flush { padding:0; overflow:hidden; }
.select-sm  { font-size:13px; padding:3px 6px; border:1px solid var(--border); border-radius:4px; background:var(--bg); }
.tr-muted   { opacity:0.5; }
.stat-bar   { background:var(--accent); height:8px; border-radius:4px; min-width:4px; }

/* ── Flush-card table padding ────────────────────────────────────── */
.card--flush .data-table th,
.card--flush .data-table td { padding-left: 16px; padding-right: 16px; }

/* ── Link weight utilities ───────────────────────────────────────── */
.link-strong { font-weight: 500; }
.lh-relaxed  { line-height: 1.6; }
.mt-half     { margin-top: .5rem; }

/* ── Auth form field spacing ─────────────────────────────────────── */
.auth-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; margin-top: 0.85rem; }
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input  { margin-bottom: 0; }
.auth-form .field-gap  { margin-bottom: 1rem; }
.auth-form .field-last { margin-bottom: 1.5rem; }
.btn-full { width: 100%; margin-top: 0; justify-content: center; }
