/* Hidden Stats Studio — CMS admin UI (prototype).
   Intentionally a clean, neutral "tool" look — NOT the neon site theme.
   Self-contained, light/dark aware. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6ec;
  --text: #1c2430;
  --muted: #667085;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --danger: #d92d20;
  --ok: #12805c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --surface: #161b22;
    --surface-2: #1c222c;
    --border: #2a313c;
    --text: #e6e9ef;
    --muted: #93a0b1;
    --brand: #7c74f5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.2; }
p { margin: 0 0 0.75rem; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }

/* Prototype banner */
.proto-banner {
  background: repeating-linear-gradient(45deg, #fef3c7, #fef3c7 12px, #fde68a 12px, #fde68a 24px);
  color: #7c5e10;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 6px 12px;
  border-bottom: 1px solid #f0d488;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.9rem;
  transition: background 0.12s, border-color 0.12s, transform 0.03s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { filter: brightness(1.06); background: var(--brand); }
.btn--danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger:hover { background: rgba(217, 45, 32, 0.08); }
.btn--sm { padding: 5px 9px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Login */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px; text-align: center;
}
.login-card .logo {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 14px;
  background: linear-gradient(135deg, #27e6f4, #ff2aa4); display: grid; place-items: center;
  color: #04211e; font-weight: 800; font-family: var(--mono); font-size: 1.4rem;
}
.login-card h1 { font-size: 1.35rem; }
.login-card .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 24px; }
.google-btn {
  width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem;
  border: 1px solid var(--border); background: var(--surface);
}
.mock-switch {
  margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border);
  font-size: 0.82rem; color: var(--muted); text-align: left;
}
.mock-switch label { display: block; margin-bottom: 6px; font-weight: 600; }
.mock-switch select {
  width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}

/* App shell */
.app { display: none; min-height: 100vh; grid-template-columns: 260px 1fr; }
.app.is-on { display: grid; }
@media (max-width: 720px) { .app.is-on { grid-template-columns: 1fr; } }

/* Desktop: lock the shell to the viewport so the sidebar stays static and only the main panel scrolls. */
@media (min-width: 721px) {
  body:has(.app.is-on) { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  .app.is-on { flex: 1; min-height: 0; }
  .sidebar { min-height: 0; overflow-y: auto; }
  .main { min-height: 0; overflow-y: auto; }
}

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 8px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, #27e6f4, #ff2aa4); display: grid; place-items: center;
  color: #04211e; font-weight: 800; font-family: var(--mono);
}
.sidebar .brand strong { font-size: 0.95rem; }
.sidebar .brand small { display: block; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

.side-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 8px 8px 2px; }
.site-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; border: 1px solid transparent; text-align: left;
  width: 100%; background: transparent; color: var(--text); font-weight: 600; font-size: 0.9rem;
}
.site-item:hover { background: var(--surface-2); }
.site-item.is-active { background: var(--surface-2); border-color: var(--border); }
.site-item .role { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.pill { padding: 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }

/* Section nav (left) */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 0.9rem;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* Site selector (bottom, above user) */
.site-picker { margin-top: auto; padding: 10px 4px 4px; }
.site-picker .side-label { display: block; padding: 0 4px 6px; }
.site-picker select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
}

.user-box { padding: 12px 8px 4px; border-top: 1px solid var(--border); }
.user-box .who { font-size: 0.85rem; font-weight: 600; }
.user-box .email { font-size: 0.76rem; color: var(--muted); word-break: break-all; }

/* Main */
.main { padding: 28px 32px; overflow-x: auto; }
.main-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.main-head h2 { font-size: 1.4rem; }
.main-head .crumbs { color: var(--muted); font-size: 0.85rem; margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 9px 14px; border: 0; background: transparent; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.is-active { color: var(--text); border-bottom-color: var(--brand); }

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

/* Content list */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: flex-start; gap: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.item .drag { display: flex; flex-direction: column; gap: 2px; }
.item .drag button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; width: 26px; height: 22px; line-height: 1; color: var(--muted); }
.item .body { flex: 1; min-width: 0; }
.item .body time { font-size: 0.75rem; color: var(--brand); font-weight: 700; }
.item .body h3 { font-size: 1.02rem; margin: 2px 0 4px; }
.item .body p { color: var(--muted); font-size: 0.9rem; margin: 0; }
.item .body .link { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.item .row-actions { display: flex; gap: 4px; }
.status-tag { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; }
.status-published { background: rgba(18,128,92,0.12); color: var(--ok); }
.status-draft { background: var(--surface-2); color: var(--muted); }

/* Form / modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,0.5); display: none;
  align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-backdrop.is-on { display: flex; }
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3); padding: 24px;
}
.modal h3 { font-size: 1.15rem; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--danger); }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.field .hint { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 0.76rem; color: var(--danger); margin-top: 4px; display: none; }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field.has-error .err { display: block; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Page-text editor (key/value display of a section's fields) */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 0.88rem; }
.kv:first-of-type { border-top: 0; padding-top: 0; }
.kv .k { color: var(--muted); font-weight: 600; }
.kv .v { color: var(--text); word-break: break-word; white-space: pre-wrap; }
.kv .v em { color: var(--muted); }
.item .body a.link { color: var(--brand); text-decoration: none; }
.item .body a.link:hover { text-decoration: underline; }

pre.json {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-family: var(--mono); font-size: 0.82rem; overflow-x: auto; margin: 0 0 12px;
  white-space: pre; max-height: 340px;
}
.note { font-size: 0.82rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
