/* Shared base design system — the app shell, form controls, buttons,
   tables, and every other visual primitive common to EVERY portal
   (PLATFORM today; COMPETITION/STUDIO later). Lives outside any one
   portal's folder for the same reason public/shared/modal.css does:
   copy-pasting this per portal is how two consoles quietly drift apart —
   see plan/ui/shared-components.md.

   Design tokens (:root) are the single source of truth for every color/
   radius value a portal-specific stylesheet or public/shared/modal.css
   might reference via var(--accent, ...) fallbacks — defining them here,
   once, is what makes a future re-skin a one-file edit instead of a
   find-and-replace across every portal.

   A portal's own <style> block should hold ONLY what's genuinely specific
   to it (PLATFORM's icon-set editor and strings/translation admin UI are
   the current examples) — anything else belongs here instead. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-hover: #1d212b;
  --panel-border: #262b36;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --accent: #5b8cff;
  --accent-hover: #6f9aff;
  --danger: #ff6b6b;
  --success: #35c98f;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }

/* Links otherwise inherit the browser's default blue/purple-visited
   palette, which reads harshly against this dark theme and doesn't match
   anything else in it — pick up the same accent blue every button
   already uses, with no separate "visited" color (a visited row isn't a
   meaningfully different state here the way it is on the open web). */
a { color: var(--accent); }
a:visited { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---- Login screen ----
   Starts hidden (see the "hidden" class on the element itself) while a
   portal's own app.js decides whether a saved session can be resumed. If
   login turns out to be needed, "hidden" is removed and "login-visible"
   is added a frame later, so it fades in and drops from a -4em offset
   over 200ms instead of flashing in immediately. Every portal's login
   screen should reuse these classes rather than redefining its own — the
   actual FIELDS inside .login-card differ per portal/role, the shell
   around them shouldn't. */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transform: translateY(-4em);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.login-screen.login-visible {
  opacity: 1;
  transform: translateY(0);
}
.login-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}
.login-card .hint {
  margin: 0;
}

/* ---- App shell (ChatGPT-style: sidebar with footer identity, no top
   banner). Every portal's own index.html should reuse this exact
   structure/class set — only NAV_SECTIONS-equivalent content and the
   router logic that drives it differ per portal. ---- */
.app-shell {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 230px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
}
.sidebar-brand {
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--panel-border);
}
.sidebar-brand .sub {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.nav-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-dim);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
}
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: rgba(91,140,255,0.12); color: var(--accent); }

/* Identity + logout pinned to the bottom of the sidebar, a la ChatGPT */
.sidebar-footer {
  flex: none;
  border-top: 1px solid var(--panel-border);
  padding: 10px;
  position: relative;
}
.identity-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.identity-btn:hover { background: var(--panel-hover); }
.identity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.identity-email {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.identity-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}
.identity-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
}
.identity-menu button:hover { background: var(--panel-hover); }

/* ---- Main area ---- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sub-nav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--bg);
}
.sub-nav-back {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 12px 10px 12px 0;
  margin-right: 6px;
  cursor: pointer;
  font-size: 13px;
  border-right: 1px solid var(--panel-border);
}
.sub-nav-back:hover { color: var(--text); }
.sub-nav-item {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 12px 14px;
  border-bottom: 2px solid transparent;
}
.sub-nav-item:hover { color: var(--text); }
.sub-nav-item.active { color: var(--text); border-bottom-color: var(--accent); }
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.loading { color: var(--text-dim); font-size: 13px; }

/* ---- Mobile nav: sidebar becomes an off-canvas panel behind a
   hamburger, below the breakpoint. Hidden entirely on desktop. 768px is
   the one shared breakpoint every portal-agnostic component in this
   project uses (modal.css's mobile takeover matches it too — keep them
   in sync if this ever changes). ---- */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  flex: none;
}
.mobile-topbar .sidebar-brand { padding: 0; border: none; }
.hamburger-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}
.hamburger-btn:hover { border-color: var(--accent); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    max-width: 82vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  .content { padding: 16px; }
  .panel-header { flex-wrap: wrap; gap: 8px; }
  .row { flex-direction: column; gap: 0; }
}

/* ---- Core component styles — panels, cards, forms, tables, buttons,
   badges, messages. The design-system vocabulary every portal's own
   screens are built out of. ---- */
.panel { display: flex; flex-direction: column; gap: 16px; max-width: 880px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { margin: 0; font-size: 16px; }
.panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card.danger-zone { border-color: rgba(255,107,107,0.3); }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: #0d0f14;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; min-width: 0; }
.form-actions { display: flex; gap: 8px; }
.btn {
  appearance: none;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  color: white;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn { display: inline-flex; align-items: center; gap: 8px; }
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-ghost { background: transparent; border: 1px solid var(--panel-border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); background: transparent; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff8080; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.msg { font-size: 13px; padding: 8px 12px; border-radius: 6px; display: none; }
.msg.error { display: block; background: rgba(255,107,107,0.1); color: var(--danger); }
.msg.success { display: block; background: rgba(53,201,143,0.1); color: var(--success); }
.hint { color: var(--text-dim); font-size: 12px; }
code { background: #0d0f14; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--panel-border); vertical-align: middle; }
table.data-table th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.status-pill, .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(91,140,255,0.15);
  color: var(--accent);
}
.badge-muted { background: rgba(154,163,178,0.15); color: var(--text-dim); }
.detail-list { display: grid; grid-template-columns: 140px 1fr; row-gap: 8px; font-size: 13px; margin: 0; }
.detail-list dt { color: var(--text-dim); }
.detail-list dd { margin: 0; }
.setting-row { border: 1px solid var(--panel-border); border-radius: 8px; padding: 14px 16px; }
.setting-row-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.setting-row-control { margin: 8px 0; max-width: 320px; }
.setting-row-actions { display: flex; gap: 8px; }
.settings-list { display: flex; flex-direction: column; gap: 10px; }
details.card summary { cursor: pointer; font-size: 13px; color: var(--text-dim); }
details.card[open] summary { margin-bottom: 12px; }

/* ---- Pager — the generic "N of M, load more / prev / next" control.
   Currently used by the strings admin (page-number style, per
   api-design-standards.md's rule-4 exception for that one endpoint);
   also the shape the future cursor-pager helper
   (plan/ui/shared-components.md) and the eventual tabular-data
   presenter's own pagination row should visually match, so a "pager"
   looks the same everywhere it appears regardless of which pagination
   strategy is driving it underneath. ---- */
.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pager-jump { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ---- Icon action buttons (shared by every portal) ----
   The round icon buttons in table rows and edit forms. Transparent so they
   sit on the dark panel in every portal; the browser's default light button
   was what made them look out of place. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn:disabled:hover { border-color: var(--panel-border); color: var(--text); }
