/* ============================================================================
 * TikTokScope — shared site shell (header, footer, API status).
 * Loaded after shadcn.css; uses the design-system tokens.
 * ========================================================================== */
:root {
  --ts-header-h: 57px;      /* sticky header height + 1px border */
  --ts-content-max: 1240px; /* shared max content width */
}

/* --------------------------------------------------------------- header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 86%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.site-header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--ts-header-h);
  max-width: var(--ts-content-max);
  margin: 0 auto;
  padding: 0 20px;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--foreground);
}
.site-brand:hover { text-decoration: none; }
.site-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.site-brand-text { font-weight: 600; font-size: 0.9rem; line-height: 1.1; white-space: nowrap; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.site-nav a:hover { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }
.site-nav a.active { background: var(--accent); color: var(--accent-foreground); font-weight: 600; }

.site-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.site-account {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  color: var(--foreground);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.site-account:hover { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }
.site-theme { width: 2.25rem; padding: 0; }
.site-theme svg { width: 16px; height: 16px; }

/* --------------------------------------------------------- API status */
.site-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.site-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted-foreground);
}
.site-status[data-state="ok"] { color: var(--success); border-color: color-mix(in oklab, var(--success) 30%, transparent); }
.site-status[data-state="ok"] .site-status-dot { background: var(--success); }
.site-status[data-state="down"] { color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 30%, transparent); }
.site-status[data-state="down"] .site-status-dot { background: var(--destructive); }
.site-status[data-state="pending"] .site-status-dot { animation: tsPulse 1.1s ease-in-out infinite; }
@keyframes tsPulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }

/* --------------------------------------------------------------- footer */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.8rem;
}
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  max-width: var(--ts-content-max);
  margin: 0 auto;
  padding: 26px 20px 40px;
}
.site-footer-brand { display: flex; align-items: center; gap: 10px; }
.site-footer-title { color: var(--foreground); font-size: 0.85rem; font-weight: 600; }
.site-footer-note { font-size: 0.75rem; }
.site-footer-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-left: auto; }
.site-footer-nav a,
.site-footer-meta a { color: var(--muted-foreground); }
.site-footer-nav a:hover,
.site-footer-meta a:hover { color: var(--foreground); }
.site-footer-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* --------------------------------------------------------- skip link */
.skip-link {
  position: absolute;
  left: 10px;
  top: -52px;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 9px 15px;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 600;
  font-size: 0.82rem;
  transition: top .12s ease;
}
.skip-link:focus { top: 0; text-decoration: none; }

/* ------------------------------------------- layouts below the header */
/* Sidebar layouts opt in with .has-site-header so the sidebar starts below
   the sticky header instead of covering the full viewport height. */
.has-site-header { min-height: calc(100vh - var(--ts-header-h)); }
.has-site-header > .sidebar {
  top: var(--ts-header-h);
  height: calc(100vh - var(--ts-header-h));
}
.has-site-header .ex-side {
  top: var(--ts-header-h);
  max-height: calc(100vh - var(--ts-header-h));
}

/* Center the main column of single-column pages (e.g. status) on the same
   max width as the header and footer. */
.ts-single { margin-left: auto; margin-right: auto; }

/* Shared page-title row (replaces the old per-page .topbar). */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.page-head .titles { min-width: 0; }
.page-head .searchbar { margin-left: auto; }
@media (max-width: 900px) { .page-head { flex-wrap: wrap; } }

/* ------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .site-header-inner { gap: 10px; padding: 0 14px; }
  .site-brand-text { display: none; }
  .site-status-text { display: none; }
  .site-status { padding: 3px 8px; }
  .site-footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .site-footer-nav { margin-left: 0; }
}

/* Keep the sidebar out of a full-viewport nested-scroll region on small
   screens; the page itself scrolls instead. */
@media (max-width: 900px) {
  .has-site-header > .sidebar {
    position: static;
    top: auto;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .has-site-header .ex-side {
    position: static;
    top: auto;
    max-height: none;
  }
}
