/* ═══════════════════════════════════════════════
   SAVVYALIEN Design System — Shared Layout
   ═══════════════════════════════════════════════ */
:root {
  --g: #00FF88;
  --bg: #050505;
  --sidebar: #080808;
  --card: #111;
  --border: #1a1a1a;
  --muted: #555;
  --sidebar-w: 200px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.local-mirror { transform: scaleX(-1); }
body { background: var(--bg); color: #fff; font-family: 'Segoe UI', Tahoma, sans-serif; height: 100dvh; overflow: hidden; }
a { text-decoration: none; color: inherit; }

/* ── App shell ──────────────────────────────── */
.sa-app { display: flex; height: 100dvh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────── */
.sa-sidebar {
  width: var(--sidebar-w); background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden; flex-shrink: 0;
  scrollbar-width: none; transition: width .2s;
}
.sa-sidebar::-webkit-scrollbar { display: none; }

.sb-header {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 10px; flex-shrink: 0;
}
.hamburger-btn {
  background: none; border: none; color: #777; cursor: pointer;
  padding: 6px; border-radius: 6px; font-size: 18px; line-height: 1; flex-shrink: 0;
}
.hamburger-btn:hover { background: #1a1a1a; color: white; }
.sb-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sb-logo { width: 34px; height: 34px; flex-shrink: 0; }
.sb-brand-text { font-weight: 900; font-style: italic; font-size: 11px; line-height: 1.2; color: #ddd; }
.sb-brand-text .g { color: var(--g); }

/* Nav */
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 4px 8px; }
.sn-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13px; color: #888; cursor: pointer; transition: .15s;
}
.sn-item:hover, .sn-item.active { background: #1a1a1a; color: white; }
.sn-item[aria-disabled="true"] { cursor: not-allowed; opacity: .45; }
.sn-item[aria-disabled="true"]:hover { background: transparent; color: #888; }
.sn-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sn-live { background: var(--g); color: black; font-size: 9px; font-weight: 900; padding: 2px 6px; border-radius: 3px; letter-spacing: .5px; flex-shrink: 0; }

.sb-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); padding: 14px 18px 6px; margin-top: 2px; }

.sub-item { display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: 13px; color: #888; cursor: pointer; transition: .15s; }
.sub-item:hover { color: white; }
.sub-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,#222,#444); flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #888; }
.sub-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.sub-avatar.live-ring { box-shadow: 0 0 0 2px var(--g); }
.sub-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.show-more-btn { background: none; border: none; color: var(--muted); font-size: 12px; padding: 6px 16px 10px; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 4px; }
.show-more-btn:hover { color: #888; }

/* ── Main content ───────────────────────────── */
.sa-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Topbar */
.sa-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--sidebar);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tb-search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; background: #0f0f0f; border: 1px solid var(--border); border-radius: 50px; overflow: hidden;
}
.tb-search input { flex: 1; background: none; border: none; outline: none; color: white; padding: 9px 18px; font-size: 14px; }
.tb-search input::placeholder { color: #444; }
.tb-search-btn { background: var(--g); color: black; border: none; padding: 0 18px; cursor: pointer; font-size: 15px; }
.tb-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.go-live-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--g); color: black; border: none;
  padding: 8px 14px; border-radius: 50px; font-weight: 900; font-size: 12px;
  cursor: pointer; white-space: nowrap; transition: .15s;
}
.go-live-btn:hover { background: #00cc6e; }
.go-live-plus { width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.tb-icon-btn { width: 38px; height: 38px; border-radius: 50%; background: #0f0f0f; border: 1px solid var(--border); color: white; cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center; position: relative; }
.tb-icon-btn:disabled { color: #555; border-color: #222; cursor: not-allowed; opacity: .55; }
.tb-avatar-btn { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,var(--g),#00aaff); border: none; cursor: pointer; font-size: 14px; font-weight: bold; color: black; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.notif-dot { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--g); border: 2px solid var(--sidebar); font-size: 7px; color: black; font-weight: bold; display: flex; align-items: center; justify-content: center; }

/* ── Scrollable content ─────────────────────── */
.sa-content { flex: 1; overflow-y: auto; padding: 20px 24px; scrollbar-width: thin; scrollbar-color: #222 transparent; }

/* ── Channel cards ──────────────────────────── */
.section-title { font-size: 15px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.channels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px,1fr)); gap: 16px; margin-bottom: 36px; }
.ch-card { background: #101010; border-radius: 13px; overflow: hidden; border: 1px solid #202020; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.ch-card:hover { border-color: #383838; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.3); }
.ch-card:focus-visible { outline: 2px solid var(--g); outline-offset: 3px; }
.ch-thumb { position: relative; aspect-ratio: 16/9; margin: 8px 8px 0; overflow: hidden; border-radius: 9px 9px 3px 3px; border: 1px solid #252525; background: #080808; }
.live-badge { position: absolute; top: 8px; left: 8px; z-index: 3; background: #e00016; color: white; font-size: 10px; font-weight: 900; padding: 4px 9px; border-radius: 5px; letter-spacing: 1px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
@keyframes lp { 0%,100%{opacity:1;}50%{opacity:.6;} }
.live-badge { animation: lp 1.8s infinite; }
.live-badge.recorded-badge { animation: none; background: #7a111c; }
.live-badge.streamed-badge { animation: none; background: #21674a; }
.sa-stream-share { position: absolute; top: 8px; right: 8px; z-index: 4; border: 1px solid #666; border-radius: 6px; padding: 4px 8px; background: rgba(0,0,0,.84); color: #fff; font-size: 11px; font-weight: 800; cursor: pointer; }
.sa-stream-share:hover, .sa-stream-share:focus-visible { border-color: var(--g); color: var(--g); outline: none; }
.ch-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 10px; background: linear-gradient(to top,rgba(0,0,0,.75),transparent); display: flex; align-items: center; justify-content: space-between; }
.ch-handle { font-size: 11px; color: rgba(255,255,255,.8); }
.ch-cams { font-size: 11px; color: var(--g); font-weight: bold; }
.cam-strip { padding: 8px; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.cam-strip::-webkit-scrollbar { display: none; }
.ch-thumb-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #080808; display: block; }
.sa-stream-thumbnail { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-slot { position: relative; width: 55px; aspect-ratio: 4/3; border-radius: 6px; flex-shrink: 0; background: #090909; border: 1px solid #191919; overflow: hidden; }
.cam-slot.active { border-color: rgba(0,255,136,.55); }
.cam-slot-video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.ch-info { padding: 8px 12px 13px; }
.sa-stream-card .ch-info { display: flex; align-items: flex-start; gap: 10px; }
.sa-stream-creator-link, .sa-stream-creator-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(0,255,136,.22); background: #18251f;
  color: var(--g); font-size: 15px; font-weight: 800;
}
.sa-stream-creator-link { text-decoration: none; }
.sa-stream-creator-link:hover, .sa-stream-creator-link:focus-visible {
  border-color: var(--g); outline: 2px solid rgba(0,255,136,.35); outline-offset: 2px;
}
.sa-stream-creator-link img, .sa-stream-creator-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.sa-stream-info-details { min-width: 0; flex: 1; }
.ch-info-row { display: flex; align-items: center; gap: 8px; margin-bottom: 1px; }
.ch-info-row .ch-name { flex: 1; min-width: 0; }
.ch-name { font-size: 14px; font-weight: 700; margin-bottom: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-stream-title { font-size: 12px; color: #666; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-meta { font-size: 12px; color: var(--muted); }
.sa-stream-owner { flex-shrink: 0; color: var(--g); font-size: 11px; font-weight: 800; }
.sa-stream-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.28); font-size: 28px; }
.sa-preview-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 10px; color: #a1aaa3; background: #0d110e; text-align: center; font-size: 12px; line-height: 1.4; }
.sa-stream-stage.preview-unavailable .sa-stream-placeholder { display: none; }
.cam-slot .sa-preview-fallback { padding: 2px; font-size: 7px; line-height: 1.1; }
.cam-slot.preview-unavailable { border-color: #241b1b; }
.sa-stream-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 13px; }

/* ── Recorded grid ──────────────────────────── */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px,1fr)); gap: 16px; margin-bottom: 40px; }
.rec-card { background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; transition: .15s; }
.rec-card:hover { border-color: #333; }
.rec-thumb { height: 120px; position: relative; }
.rec-badge { position: absolute; top: 8px; left: 8px; background: #700; color: white; font-size: 10px; font-weight: 900; padding: 3px 8px; border-radius: 4px; letter-spacing: 1px; }
.rec-info { padding: 9px 10px; }
.rec-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-meta { font-size: 11px; color: var(--muted); }

/* ── Empty / loading states ─────────────────── */
.empty-state { color: var(--muted); font-size: 13px; text-align: center; padding: 48px 20px; line-height: 1.8; grid-column: 1/-1; }

/* ── Collapsed sidebar (icon-only, desktop) ─── */
.sa-sidebar.collapsed {
  width: 56px;
}
.sa-sidebar.collapsed .sb-header {
  justify-content: center;
  padding: 13px 0;
}
.sa-sidebar.collapsed .sb-label,
.sa-sidebar.collapsed #sub-list,
.sa-sidebar.collapsed .show-more-btn { display: none; }
.sa-sidebar.collapsed .sb-nav { padding: 4px 2px; }
.sa-sidebar.collapsed .sn-item {
  justify-content: center;
  padding: 9px 0;
  font-size: 0;          /* hides raw text nodes */
  gap: 0;
}
.sa-sidebar.collapsed .sn-icon {
  font-size: 18px;
  width: auto;
}
.sa-sidebar.collapsed .sn-live {
  font-size: 9px;
  padding: 2px 6px;
}

/* ── Topbar brand (logo + name, always visible) ─── */
.tb-brand {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; text-decoration: none;
}
.tb-brand .sb-logo { width: 30px; height: 30px; }
.tb-brand .sb-brand-text { font-weight: 900; font-style: italic; font-size: 11px; line-height: 1.2; color: #ddd; white-space: nowrap; }
.tb-brand .sb-brand-text .g { color: var(--g); }

/* ── Responsive ─────────────────────────────── */
.mobile-menu-btn { display: none; }
.mobile-nav-backdrop { position: fixed; inset: 0; z-index: 199; background: rgba(0,0,0,.6); }
.mobile-nav-backdrop[hidden] { display: none; }
@media (max-width: 700px) {
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 6px; border-radius: 6px; }
  .sa-topbar:has(.mobile-menu-btn) { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .sa-topbar:has(.mobile-menu-btn) .tb-brand { flex: 1; }
  .sa-topbar:has(.mobile-menu-btn) .tb-brand .sb-brand-text { display: none; }
  .sa-topbar:has(.mobile-menu-btn) .tb-search { order: 3; flex: 1 0 100%; max-width: none; min-width: 0; }
  .sa-topbar:has(.mobile-menu-btn) .tb-search input { min-width: 0; width: 100%; }
  .sa-topbar:has(.mobile-menu-btn) .tb-search-btn { min-height: 44px; }
  .sa-sidebar { display: none; }
  .sa-sidebar.open { display: flex; position: fixed; inset: 0 auto 0 0; z-index: 200; height: 100%; width: var(--sidebar-w); box-shadow: 4px 0 24px rgba(0,0,0,.9); }
  .sa-content { padding: 14px; }
  .channels-grid { grid-template-columns: 1fr; }
  .rec-grid { grid-template-columns: 1fr; }
}
