/* Shared admin chrome — loaded by /admin/, /admin/observability/, /admin/replay/.
   Page-specific styles stay inline in each page's <style> block. */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafbfc;
  --bg-soft: #f4f6f9;
  --bg-soft-2: #f1f5f9;
  --border: #e6e9ef;
  --border-soft: #eef0f4;
  --text: #0c1724;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --accent: #2b67f6;
  --accent-soft: #eaf0fe;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --shadow-sm: 0 1px 0 rgba(15, 23, 42, .04);
  --touch-min: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}

/* Keyboard focus ring — :where() keeps specificity at 0 so existing :focus
   styles still win for mouse interactions. */
:where(button, a, [role="button"], input, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Sticky header */
header.app {
  position: sticky; top: 0; z-index: 50;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
/* Admin uses flex directly on header.app; replay wraps in .header-top.
   Apply layout to whichever element is the direct child container. */
header.app:not(:has(.header-top)),
header.app .header-top {
  display: flex; align-items: center; justify-content: space-between;
}

.app-title { display: flex; align-items: center; gap: 10px; }
.app-title img { width: 24px; height: 24px; }
/* Brand wordmark — visual chrome, not a content heading. The page's real
   content headings live inside <main>. */
.app-title .brand {
  font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  color: var(--text);
}
.app-title .crumb { color: var(--text-faint); font-weight: 400; margin: 0 2px; }
.app-title .crumb-text { color: var(--text-muted); font-weight: 500; }

/* Tab links — touch-target token sized */
.app-title .tab-link,
a.tab-link {
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  padding: 6px 12px; border-radius: 6px;
  display: inline-flex; align-items: center;
  min-height: var(--touch-min);
}
.app-title .tab-link:hover,
a.tab-link:hover { background: var(--bg-soft); color: var(--text); }
.app-title .tab-link.active,
a.tab-link.active { color: var(--accent); background: var(--accent-soft); }

.app-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
button.btn {
  font-family: inherit; font-size: 13px;
  padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  cursor: pointer;
  min-height: var(--touch-min);
  transition: background 100ms ease, border-color 100ms ease;
}
button.btn:hover { background: var(--bg-soft); }
button.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.btn.primary:hover { background: #1f55d6; }
button.btn:disabled { opacity: .55; cursor: not-allowed; }

a.back {
  color: var(--text-muted); font-size: 13px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
a.back:hover { color: var(--accent); }

/* Page wrapper */
main { padding: 18px 20px 40px; max-width: 1520px; margin: 0 auto; }
.status-line { font-size: 12px; color: var(--text-faint); margin: -4px 0 14px 0; }

/* Calendar badge — replaces a real <select> with a single option, so
   iOS doesn't pop a system wheel for a non-choice. Pair with a hidden
   <input id="cal"> to preserve the cal.value JS contract. */
.cal-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  min-height: var(--touch-min);
  white-space: nowrap;
}

/* Mobile: stop the header from overflowing the viewport on phones.
   Wrap into multiple rows, drop the brand wordmark + breadcrumb that
   are visual chrome at desktop sizes, and let the tab strip scroll
   horizontally as a last resort. */
@media (max-width: 768px) {
  header.app {
    padding: 10px 12px;
  }
  header.app:not(:has(.header-top)),
  header.app .header-top {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .app-title {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }
  .app-title::-webkit-scrollbar { display: none; }
  .app-title .brand,
  .app-title .crumb {
    display: none;
  }
  .app-title .tab-link,
  a.tab-link {
    padding: 6px 10px;
    flex-shrink: 0;
  }
  .app-actions {
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  a.back { font-size: 12px; }
  main { padding: 14px 12px 32px; }
}

/* Section eyebrow — section labels in the page (NOT real headings).
   Replaced the former <h2 class="section"> pattern, which inverted the
   semantic hierarchy by being smaller than the h3 panel titles below it. */
.eyebrow {
  margin: 26px 0 10px 0;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.eyebrow:first-child { margin-top: 0; }

/* Live-activity eyebrow gets a pulsing dot + secondary meta text */
.eyebrow .live-dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--ok); border-radius: 99px; margin-right: 6px;
  vertical-align: 1px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.eyebrow .live-meta {
  color: var(--text-faint); font-weight: 400; margin-left: 8px;
  text-transform: none; letter-spacing: 0; font-size: 11px;
}

/* Skeleton loader utility — shimmer bars matching destination layout.
   Use inline style="height:Npx; width:N%" to size for the target shape. */
.skeleton {
  display: block;
  background: linear-gradient(
    90deg,
    var(--bg-soft) 25%,
    var(--bg-soft-2) 50%,
    var(--bg-soft) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* Dark theme — applied via data-theme="dark" on <html>. Brightens
   warn/danger/ok so they stay legible on the dark navy surface. */
[data-theme="dark"] {
  --bg: #0f1a2e;
  --bg-subtle: #13203a;
  --bg-soft: #18253f;
  --bg-soft-2: #1c2a47;
  --border: #2a3a5a;
  --border-soft: #243250;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #3b82f6;
  --accent-soft: #1e3a8a;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --warn-soft: rgba(251, 191, 36, .15);
  --danger-soft: rgba(248, 113, 113, .15);
  --ok-soft: rgba(52, 211, 153, .15);
}
