/* ============================================
   vidIQ Partner Dashboard — Shared Styles
   ============================================ */

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

:root {
  /* vidIQ brand palette — dark-first, blue-accented */
  --primary: #1863DC;
  --primary-dark: #1453B8;
  --primary-light: rgba(24,99,220,.12);
  --primary-glow: rgba(24,99,220,.18);
  --green: #00C853;
  --green-dark: #00A344;
  --green-light: rgba(0,200,83,.10);
  --green-glow: rgba(0,200,83,.12);
  --sidebar-bg: #070A12;
  --sidebar-hover: #111827;
  --sidebar-active: #1A2236;
  --bg: #0A0D15;
  --card: #111827;
  --card-border: #1E2A3A;
  --text: #E8ECF2;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.15);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
  --transition: .2s ease;
  --sidebar-width: 260px;
  --header-height: 64px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Dark Mode (matches default now; light kept for toggle) ---------- */
[data-theme="dark"] {
  --bg: #0A0D15;
  --card: #111827;
  --card-border: #1E2A3A;
  --text: #E8ECF2;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
  --green-light: rgba(0,200,83,.10);
}

/* ---------- Light Mode override (optional) ---------- */
[data-theme="light"] {
  --bg: #0D1220;
  --card: #141C2E;
  --card-border: #1E2D45;
  --text: #E8ECF2;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow: 0 1px 3px rgba(0,0,0,.25);
  --shadow-md: 0 4px 6px rgba(0,0,0,.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.35);
  --green-light: rgba(0,200,83,.10);
}

body { min-height: 100vh; display: flex; overflow-x: hidden; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: #4B8EF0; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  height: var(--header-height);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700; font-size: 18px;
}
.sidebar-brand img, .sidebar-brand svg { width: 32px; height: 32px; }
.sidebar-brand .brand-text span { color: var(--primary); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65); font-weight: 500;
  transition: all var(--transition); text-decoration: none;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { color: #fff; background: var(--sidebar-hover); text-decoration: none; }
.sidebar-nav a.active { color: #fff; background: var(--sidebar-active); }
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: 0;
  width: 3px; height: 24px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.sidebar-nav a { position: relative; }
.sidebar-nav .nav-icon { width: 20px; height: 20px; opacity: .7; flex-shrink: 0; }
.sidebar-nav a.active .nav-icon, .sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-section { padding: 24px 14px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.3); font-weight: 600; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: rgba(255,255,255,.35);
}

/* ---------- Main Content ---------- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ---------- Top Header ---------- */
.header {
  height: var(--header-height);
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 { font-size: 18px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 16px; }

.partner-url {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-light); color: #4B8EF0;
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.partner-url svg { width: 14px; height: 14px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}

/* Dark mode toggle */
.theme-toggle {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: var(--bg); color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--primary-light); color: var(--primary); }

.hamburger {
  display: none; width: 36px; height: 36px; border: none;
  background: none; color: var(--text); cursor: pointer;
  align-items: center; justify-content: center;
}

/* ---------- Content Area ---------- */
.content { padding: 28px; flex: 1; }

/* ---------- Timeframe Bar ---------- */
.timeframe-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 20px;
}
.tf-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-muted);
  white-space: nowrap;
}
.tf-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tf-btn {
  padding: 7px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.tf-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.tf-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tf-custom-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.tf-date-input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.tf-date-input::-webkit-calendar-picker-indicator { filter: invert(.7); }
.tf-apply-btn {
  padding: 6px 14px !important;
  font-size: 12px !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* ---------- KPI Cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--primary); opacity: 0;
  transition: opacity var(--transition);
}
.kpi-card:hover::after { opacity: 1; }
.kpi-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.kpi-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.kpi-change {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 600; margin-top: 8px; padding: 2px 8px;
  border-radius: 12px;
}
.kpi-change.up { color: #059669; background: #ECFDF5; }
.kpi-change.down { color: #DC2626; background: #FEF2F2; }
[data-theme="dark"] .kpi-change.up { background: rgba(5,150,105,.15); }
[data-theme="dark"] .kpi-change.down { background: rgba(220,38,38,.15); }

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-size: 15px; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.chart-card canvas { width: 100% !important; }

/* ---------- Funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.funnel-step {
  display: flex; align-items: center; gap: 12px;
}
.funnel-bar-wrap { flex: 1; position: relative; height: 40px; }
.funnel-bar {
  height: 100%; border-radius: 6px;
  display: flex; align-items: center; padding: 0 14px;
  font-weight: 700; color: #fff; font-size: 14px;
  transition: width .8s cubic-bezier(.22,1,.36,1);
}
.funnel-label {
  width: 80px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  text-align: right; flex-shrink: 0;
}
.funnel-pct {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  width: 50px; flex-shrink: 0;
}

/* ---------- Tables ---------- */
.table-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--card-border);
}
.table-header h3 { font-size: 15px; font-weight: 700; }
.table-actions { display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 1px solid var(--card-border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
thead th:hover { color: var(--text); }
thead th .sort-icon { margin-left: 4px; opacity: .4; font-size: 10px; }
thead th.sorted .sort-icon { opacity: 1; color: var(--primary); }
tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--card-border);
  font-size: 13px; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--primary-glow); }

.badge {
  display: inline-flex; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700;
}
.badge-green { background: #ECFDF5; color: #059669; }
.badge-blue { background: #EFF6FF; color: #2563EB; }
.badge-red { background: #FEF2F2; color: #DC2626; }
.badge-yellow { background: #FFFBEB; color: #D97706; }
[data-theme="dark"] .badge-green { background: rgba(5,150,105,.15); }
[data-theme="dark"] .badge-blue { background: rgba(37,99,235,.15); }
[data-theme="dark"] .badge-red { background: rgba(220,38,38,.15); }
[data-theme="dark"] .badge-yellow { background: rgba(217,119,6,.15); }

/* ---------- Recent Feed ---------- */
.feed { padding: 0; }
.feed-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--card-border);
  transition: background var(--transition);
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--primary-glow); }
.feed-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.feed-info { flex: 1; }
.feed-info strong { font-weight: 600; }
.feed-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.feed-plan { font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; border: none;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Form Controls ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .5px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--card); transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ---------- Generated Link Output ---------- */
.link-output {
  background: var(--bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px;
  word-break: break-all; color: #4B8EF0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.link-output code { flex: 1; }
.copy-btn {
  flex-shrink: 0; padding: 6px 10px; border-radius: 6px;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  font-size: 12px; font-weight: 600;
}
.copy-btn:hover { background: var(--primary-dark); }
.copy-btn.copied { background: #059669; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--card-border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border: none; background: none;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--sidebar-bg); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px); opacity: 0;
  transition: all .3s ease;
  z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---------- Footer ---------- */
.footer {
  padding: 20px 28px;
  text-align: center; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--card-border);
}
.footer a { color: var(--primary); font-weight: 600; }

/* ---------- Generator Page ---------- */
.gen-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-bottom: 28px;
}
.gen-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
}
.gen-card h3 {
  font-size: 15px; font-weight: 700; margin-bottom: 18px;
  padding-bottom: 12px; border-bottom: 1px solid var(--card-border);
}
.link-history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}
.link-history-item:last-child { border-bottom: none; }
.link-meta { font-size: 11px; color: var(--text-muted); }

.bulk-output { max-height: 300px; overflow-y: auto; }
.bulk-output .link-output { margin-bottom: 8px; }

/* Signup tracking KPI grid — 3 columns default */
.signup-kpi-grid { grid-template-columns: repeat(3, 1fr); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  .gen-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .content { padding: 12px; }
  .header { padding: 0 12px; }
  .header-left h1 { font-size: 15px; }
  .partner-url { display: none; }
  .header-right > span { display: none; }

  /* KPI cards mobile */
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 10px; }
  .kpi-change { font-size: 10px; padding: 2px 6px; }

  /* Charts */
  .chart-card { padding: 14px; }
  .chart-card h3 { font-size: 13px; }
  .chart-container { height: 220px; }
  .chart-container-tall { height: 280px; }

  /* Tables — horizontal scroll */
  .table-section { border-radius: var(--radius-sm); }
  .table-header { padding: 12px 14px; }
  .table-header h3 { font-size: 13px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  thead th { padding: 10px 12px; font-size: 10px; }
  tbody td { padding: 10px 12px; font-size: 12px; }

  /* Funnel */
  .funnel-label { width: 60px; font-size: 11px; }
  .funnel-bar { font-size: 12px; padding: 0 10px; }
  .funnel-pct { font-size: 10px; width: 40px; }

  /* Signup tracking */
  #signupTrackingSection h2 { font-size: 15px; }
  .signup-kpi-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }

  /* Data scope badge */
  #dataScopeBadge { padding: 6px 12px; font-size: 11px; flex-wrap: wrap; }

  /* Footer */
  .footer { padding: 14px 12px; font-size: 11px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 18px; }
  .kpi-card { padding: 12px; }

  .header-left h1 { font-size: 14px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  .theme-toggle { width: 30px; height: 30px; }

  /* Stack signup KPIs on very small screens */
  .signup-kpi-grid { grid-template-columns: 1fr !important; }

  /* Chart sizes */
  .chart-container { height: 180px; }
  .chart-container-tall { height: 240px; }

  .charts-grid { gap: 12px; }
  .content { padding: 10px; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 99;
}
.sidebar.open ~ .sidebar-overlay { display: block; }

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

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeInUp .4s ease forwards;
  opacity: 0;
}
.animate-in:nth-child(1) { animation-delay: .05s; }
.animate-in:nth-child(2) { animation-delay: .1s; }
.animate-in:nth-child(3) { animation-delay: .15s; }
.animate-in:nth-child(4) { animation-delay: .2s; }
.animate-in:nth-child(5) { animation-delay: .25s; }
.animate-in:nth-child(6) { animation-delay: .3s; }
