/* ============================================================
   YouTube Opportunity Dashboard — Dark Theme
   Standalone CSS (no build step required)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg-2:      #151823;
  --surface:   #1a1d27;
  --surface-2: #212533;
  --border:    #2a2d3a;
  --border-2:  #363b4d;
  --text:      #e6e8f0;
  --muted:     #8b90a6;
  --muted-2:   #6b7089;
  --primary:   #6366f1;
  --primary-h: #4f52d6;
  --accent:    #f43f5e;
  --success:   #22c55e;
  --success-bg:rgba(34,197,94,.1);
  --danger:    #ef4444;
  --danger-bg: rgba(239,68,68,.1);
  --warn:      #f59e0b;
  --radius:    12px;
  --radius-sm: 8px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Layout shell ─────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.3px;
  padding: 6px 10px 18px;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-links a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--surface); color: var(--text); }
.nav-links a.active { background: var(--primary); color: #fff; }
.nav-links a .ico { width: 18px; text-align: center; font-size: 1rem; }

.sidebar .sidebar-footer { border-top: 1px solid var(--border); padding-top: 14px; }
.logout-btn {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: .9rem;
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Main content ─────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px;
  background: var(--bg-2);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.05rem; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--muted);
}
.topbar .user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center;
  justify-content: center; font-weight: 600; color: var(--text);
}

.content { padding: 28px; flex: 1; max-width: 1200px; width: 100%; }

/* ── Flash messages ───────────────────────────────────────── */
.flash { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: .88rem; border: 1px solid transparent; }
.flash.success { background: var(--success-bg); color: #86efac; border-color: var(--success); }
.flash.error { background: var(--danger-bg); color: #fca5a5; border-color: var(--danger); }

/* ── Cards & panels ───────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.panel + .panel { margin-top: 20px; }
.panel-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.panel-sub { color: var(--muted); font-size: .85rem; margin-bottom: 18px; }

/* ── Forms ────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, .select {
  width: 100%; padding: 11px 14px;
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: .9rem; font-family: inherit;
  transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.input::placeholder { color: var(--muted-2); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 6px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.checkbox-row label { margin: 0; color: var(--text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: #05260f; }
.btn-success:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { background: var(--danger-bg); color: #fca5a5; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: .82rem; }

/* ── Search bar ───────────────────────────────────────────── */
.search-form { display: flex; gap: 10px; }
.search-form .input { flex: 1; }

/* ── Channel result grid ──────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-channels { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.channel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transition: border .15s, transform .15s;
}
.channel-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.channel-card .avatar {
  width: 76px; height: 76px; border-radius: 50%; overflow: hidden;
  background: var(--surface-2); margin-bottom: 12px; border: 2px solid var(--border-2);
}
.channel-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.channel-card .name { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.channel-card .stats { color: var(--muted); font-size: .8rem; margin-bottom: 10px; }
.channel-card .desc { color: var(--muted-2); font-size: .8rem; line-height: 1.5; margin-bottom: 14px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Channel header ───────────────────────────────────────── */
.channel-header { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin-bottom: 22px; }
.channel-banner { height: 160px; background: linear-gradient(135deg, #1e2233, #2a2f45); background-size: cover; background-position: center; }
.channel-meta { display: flex; gap: 18px; padding: 20px; background: var(--surface); align-items: center; }
.channel-meta .avatar { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; border: 3px solid var(--surface); margin-top: -50px; flex-shrink: 0; background: var(--surface-2); }
.channel-meta .info h2 { font-size: 1.3rem; font-weight: 700; }
.channel-meta .info .sub { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.channel-meta .info .desc { color: var(--muted-2); font-size: .82rem; margin-top: 8px; max-width: 640px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 11px 20px; font-weight: 600; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); }

/* ── Video list ───────────────────────────────────────────── */
.video-list { display: flex; flex-direction: column; gap: 12px; }
.video-row {
  display: flex; gap: 16px; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); align-items: flex-start;
}
.video-row .thumb { width: 168px; height: 94px; border-radius: 6px; overflow: hidden; flex-shrink: 0; background: var(--surface-2); }
.video-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-row .vinfo { flex: 1; min-width: 0; }
.video-row .vinfo .vtitle { font-weight: 600; font-size: .92rem; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-row .vinfo .vmeta { color: var(--muted); font-size: .8rem; }
.video-row .vinfo .vdesc { color: var(--muted-2); font-size: .8rem; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-row .badge-dur { display: inline-block; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; padding: 1px 6px; border-radius: 4px; margin-left: 8px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.pagination .page-info { color: var(--muted); font-size: .85rem; }

/* ── Collection tray (sticky bottom) ──────────────────────── */
.tray {
  position: sticky; bottom: 0; z-index: 30; margin-top: 26px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 16px 20px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.35);
}
.tray-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tray-count { font-weight: 600; font-size: .92rem; }
.tray-count .num { color: var(--primary); }
.tray-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.tray-divider { height: 1px; background: var(--border); margin: 14px 0; }
.tray-export { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.tray-export .field { margin-bottom: 0; }
.tray-export .select { min-width: 150px; }
.tray-hint { color: var(--muted-2); font-size: .78rem; margin-top: 10px; }

/* ── Empty states ─────────────────────────────────────────── */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty h3 { color: var(--text); font-weight: 600; margin-bottom: 6px; }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.overlay { position: fixed; inset: 0; background: rgba(8,10,16,.78); z-index: 100; display: none; align-items: center; justify-content: center; }
.overlay.show { display: flex; }
.overlay .box { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 28px 34px; text-align: center; max-width: 360px; }
.overlay .box .big-spin { width: 34px; height: 34px; border: 3px solid var(--border-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 16px; }
.overlay .box h3 { font-size: 1rem; margin-bottom: 6px; }
.overlay .box p { color: var(--muted); font-size: .84rem; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 34px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; font-weight: 700; font-size: 1.15rem; }
.login-card .brand .logo { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--primary)); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.login-card .subtitle { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 26px; }
.login-card .private-note { text-align: center; color: var(--muted-2); font-size: .78rem; margin-top: 18px; }

/* ── Dashboard cards ──────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .label { color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; }
.stat-card .value.sm { font-size: 1rem; font-weight: 600; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.badge.green { background: var(--success-bg); color: #86efac; }
.badge.amber { background: rgba(245,158,11,.12); color: #fcd34d; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 860px) {
  .sidebar { width: 68px; padding: 16px 8px; }
  .sidebar .brand span, .nav-links a span.label, .logout-btn span.label { display: none; }
  .sidebar .brand { justify-content: center; }
  .nav-links a, .logout-btn { justify-content: center; }
  .video-row { flex-direction: column; }
  .video-row .thumb { width: 100%; height: auto; aspect-ratio: 16/9; }
  .content { padding: 18px; }
  .channel-meta { flex-direction: column; text-align: center; }
  .channel-meta .avatar { margin-top: -60px; }
}
