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

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* Light theme (default) */
  --bg:           #F8F8F8;
  --sidebar-bg:   #FFFFFF;
  --surface:      #FFFFFF;
  --surface2:     #EFEFEF;
  --border:       #E0E0E0;
  --text:         #000000;
  --text-muted:   #555555;
  --text-dim:     #999999;
  --accent:       #AADC00;
  --accent-hover: #BBEC10;
  --accent-text:  #000000;
  --green:        #22C55E;
  --yellow:       #F59E0B;
  --orange:       #F97316;
  --red:          #EF4444;
  --radius:       10px;
  --radius-sm:    7px;
  --radius-lg:    14px;
  --gradient:     linear-gradient(135deg, #AADC00 0%, #CFF21E 100%);
  --gradient-soft:linear-gradient(135deg, rgba(170,220,0,0.12) 0%, rgba(170,220,0,0.05) 100%);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md:    0 4px 20px rgba(170,220,0,0.25), 0 2px 6px rgba(0,0,0,0.07);
  --shadow-btn:   0 4px 14px rgba(170,220,0,0.45);
}

[data-theme="dark"] {
  --bg:           #000000;
  --sidebar-bg:   #0D0D0D;
  --surface:      #141414;
  --surface2:     #1C1C1C;
  --border:       #2A2A2A;
  --text:         #FFFFFF;
  --text-muted:   #888888;
  --text-dim:     #444444;
  --accent:       #CFF21E;
  --accent-hover: #D8F53A;
  --accent-text:  #000000;
  --green:        #22C55E;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow:       0 2px 8px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:    0 4px 20px rgba(207,242,30,0.15), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-btn:   0 4px 14px rgba(207,242,30,0.35);
}

/* ─── Base ────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Roboto', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 20px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 28px;
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo svg { flex-shrink: 0; }
.logo-accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  padding: 0 22px 10px;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.18s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--gradient-soft);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gradient);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 18px 22px 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.footer-links { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.footer-links a { color: var(--text-dim); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--accent); }

.footer-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.lang-btn {
  border: none; background: none; color: var(--text-muted);
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 5px;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.lang-btn.active { background: var(--gradient); color: var(--accent-text); box-shadow: 0 2px 8px rgba(170,220,0,0.3); }

.theme-toggle {
  width: 32px; height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.btn-logout {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px; padding: 5px 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Main ────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: 280px;
  padding: 40px 44px;
  max-width: none;
}

.page { display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 5px;
  letter-spacing: -0.4px;
  color: var(--accent);
}
.page-subtitle { color: var(--text-muted); font-size: 14px; font-weight: 400; }

/* ─── Search ──────────────────────────────────────────────────────────────── */
.search-row { display: flex; gap: 10px; margin-bottom: 18px; }

.search-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-sm);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(170,220,0,0.12);
}
.search-input::placeholder { color: var(--text-dim); }

.btn-search {
  background: var(--gradient);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 11px 28px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  box-shadow: var(--shadow-btn);
  letter-spacing: 0.1px;
}
.btn-search:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(170,220,0,0.45);
}
.btn-search:active { transform: translateY(0); }
.btn-search:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ─── Filters primary ─────────────────────────────────────────────────────── */
.filters-primary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 112px; }
.filter-group label {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.filter-group select {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 28px 6px 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke="%23CFF21E" stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(207,242,30,0.1);
}
.filter-group select option { background: var(--surface2); color: var(--text); }

/* ─── Results summary ─────────────────────────────────────────────────────── */
.results-summary { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; font-weight: 500; }
.results-summary strong { color: var(--accent); }

/* ─── Secondary filters ───────────────────────────────────────────────────── */
.filters-secondary {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 13px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.sfilter-group { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }
.subs-input, .virality-input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 8px;
  outline: none;
  width: 80px;
  transition: border-color 0.15s;
}
.subs-input:focus, .virality-input:focus { border-color: var(--accent); }
.virality-input { width: 58px; }
.sfilter-group select {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 24px 5px 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke="%23CFF21E" stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
}
.sfilter-actions { display: flex; gap: 8px; margin-left: auto; }

.btn-excel {
  display: flex; align-items: center; gap: 6px;
  background: var(--gradient); color: var(--accent-text); border: none;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  padding: 7px 14px; cursor: pointer; transition: all 0.15s;
  font-family: inherit; box-shadow: 0 2px 10px rgba(170,220,0,0.3);
}
.btn-excel:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(170,220,0,0.4); }

.btn-reset {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 7px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }

/* ─── API notice ──────────────────────────────────────────────────────────── */
.api-notice {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  background: rgba(207,242,30,0.07);
  border: 1.5px solid rgba(207,242,30,0.2);
  border-radius: var(--radius);
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 16px;
}
.api-notice svg { color: var(--accent); flex-shrink: 0; }
.api-notice a { color: var(--accent); text-decoration: none; font-weight: 600; }
.api-notice a:hover { text-decoration: underline; }

.api-key-form { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.api-key-input {
  flex: 1; min-width: 280px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px; font-family: inherit;
  padding: 9px 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.api-key-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(207,242,30,0.1); }
.api-help-link { font-size: 12px; color: var(--accent); text-decoration: none; font-weight: 500; }
.api-help-link:hover { text-decoration: underline; }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 70px 0; color: var(--text-muted);
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error ───────────────────────────────────────────────────────────────── */
.error-state {
  padding: 14px 16px;
  background: rgba(239,68,68,0.07);
  border: 1.5px solid rgba(239,68,68,0.25);
  border-radius: var(--radius);
  color: #f87171;
  font-size: 13px; margin-bottom: 16px;
}

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 90px 0 40px; color: var(--text-muted);
}
.empty-state svg { opacity: 0.35; }
.empty-sub { font-size: 13px; color: var(--text-dim); }

/* ─── Video grid ──────────────────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 18px;
}

/* ─── Video card ──────────────────────────────────────────────────────────── */
.video-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.video-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-thumb {
  position: relative; aspect-ratio: 16/9;
  overflow: hidden; background: var(--surface2);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-duration {
  position: absolute; bottom: 7px; right: 7px;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
}
.virality-badge {
  position: absolute; top: 9px; left: 9px;
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; color: #fff;
}
.virality-high   { background: var(--green); color: #fff; }
.virality-medium { background: #EAB308; color: #1a1a1a; }
.virality-low    { background: #EF4444; color: #fff; }
.virality-viral  { background: #8b5cf6; }

.card-body { padding: 13px 14px; }
.card-title {
  font-size: 13px; font-weight: 600; line-height: 1.45;
  margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  color: var(--text);
}
.card-channel { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.channel-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  object-fit: cover; background: var(--surface2); flex-shrink: 0;
}
.channel-info { min-width: 0; }
.channel-name {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.channel-subs { font-size: 11px; color: var(--text-dim); }

.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 10px; }
.stat-value { font-size: 14px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.card-virality { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.virality-label { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.virality-value { font-size: 12px; font-weight: 700; }
.virality-bar-track {
  height: 4px; background: var(--surface2);
  border-radius: 2px; overflow: hidden; margin-bottom: 8px;
}
.virality-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.card-date { font-size: 11px; color: var(--text-dim); text-align: right; }

/* ─── Load more ───────────────────────────────────────────────────────────── */
.btn-loadmore {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 14px; font-weight: 600; font-family: inherit;
  padding: 11px 36px; border-radius: var(--radius);
  cursor: pointer; transition: all 0.18s; box-shadow: var(--shadow-sm);
}
.btn-loadmore:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-md); }

/* ─── History ─────────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer; transition: all 0.18s;
  box-shadow: var(--shadow-sm);
}
.history-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.history-query { font-size: 14px; font-weight: 600; }
.history-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 12px; }
.history-badge {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: rgba(207,242,30,0.1); padding: 3px 9px; border-radius: 20px;
}

/* ─── Monitoring ──────────────────────────────────────────────────────────── */
.monitoring-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 80px 0; color: var(--text-muted);
}
.monitoring-empty svg { opacity: 0.35; }

/* ─── Shorts badge ────────────────────────────────────────────────────────── */
.shorts-badge {
  position: absolute; top: 9px; right: 9px;
  background: #FF0033; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
