/* ═══════════════════════════════════════════════════
   TTS Affiliate Dashboard — Styles
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12131a;
  --bg-card: #1a1b25;
  --bg-card-hover: #22232f;
  --bg-glass: rgba(26, 27, 37, 0.7);
  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(139, 92, 246, 0.4);
  --text-primary: #f1f1f4;
  --text-secondary: #8b8d9e;
  --text-muted: #5a5c6e;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-pink: #ec4899;
  --gradient-purple: linear-gradient(135deg, #8b5cf6, #6d28d9);
  --gradient-blue: linear-gradient(135deg, #3b82f6, #2563eb);
  --gradient-green: linear-gradient(135deg, #10b981, #059669);
  --gradient-orange: linear-gradient(135deg, #f59e0b, #d97706);
  --sidebar-width: 240px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-brand {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-icon { font-size: 28px; }
.brand-text { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.brand-highlight { color: var(--accent-purple); }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.2);
}
.nav-icon { font-size: 18px; }

.sidebar-footer { padding: 16px 24px; border-top: 1px solid var(--border); }
.system-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }

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

/* ─── Header ─────────────────────────────────────── */
.header {
  height: var(--header-height);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.menu-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 22px; cursor: pointer; }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--gradient-purple);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* ─── Pages ──────────────────────────────────────── */
.page { display: none; padding: 28px; flex-direction: column; gap: 24px; }
.page.active { display: flex; }
.page-actions { display: flex; gap: 12px; align-items: center; }

/* ─── Stats Grid ─────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.stat-card {
  padding: 24px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  opacity: 0.12;
  border-radius: var(--radius);
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.gradient-purple { background: var(--bg-card); border-left: 3px solid var(--accent-purple); }
.stat-card.gradient-blue { background: var(--bg-card); border-left: 3px solid var(--accent-blue); }
.stat-card.gradient-green { background: var(--bg-card); border-left: 3px solid var(--accent-green); }
.stat-card.gradient-orange { background: var(--bg-card); border-left: 3px solid var(--accent-orange); }
.stat-icon { font-size: 32px; z-index: 1; }
.stat-info { display: flex; flex-direction: column; gap: 4px; z-index: 1; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* ─── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { border-color: rgba(255, 255, 255, 0.1); }
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.btn-primary { background: var(--gradient-purple); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3); }
.btn-glow { box-shadow: var(--shadow-glow); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
}
.btn-outline:hover { border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.08); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: var(--gradient-green); color: white; }
.btn-danger { background: var(--accent-red); color: white; }

/* ─── Action Grid ────────────────────────────────── */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-btn {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  transition: var(--transition);
}
.action-btn:hover {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.06);
  transform: translateY(-2px);
}
.action-icon { font-size: 28px; }
.action-label { font-size: 12px; font-weight: 600; text-align: center; }

/* ─── Activity Feed ──────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 12px; max-height: 300px; overflow-y: auto; }
.activity-item {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.activity-item .time { color: var(--text-muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
.activity-empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* ─── Chart Bars ─────────────────────────────────── */
.chart-placeholder { display: flex; flex-direction: column; gap: 20px; }
.chart-bar-group { display: flex; align-items: center; gap: 12px; }
.chart-label { width: 70px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.chart-bar-track { flex: 1; height: 28px; background: var(--bg-secondary); border-radius: 14px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 14px; transition: width 1s ease; min-width: 4px; }
.chart-bar.gradient-purple { background: var(--gradient-purple); }
.chart-bar.gradient-blue { background: var(--gradient-blue); }
.chart-bar.gradient-green { background: var(--gradient-green); }
.chart-bar.gradient-orange { background: var(--gradient-orange); }
.chart-value { font-size: 13px; font-weight: 600; width: 80px; text-align: right; }

/* ─── Products Grid ──────────────────────────────── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  cursor: pointer;
}
.product-card:hover { border-color: var(--accent-purple); transform: translateY(-2px); box-shadow: var(--shadow); }
.product-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.product-name { font-weight: 600; font-size: 15px; line-height: 1.4; }
.product-score {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.score-high { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.score-mid { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }
.score-low { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.product-meta { display: flex; gap: 16px; margin: 12px 0; font-size: 13px; color: var(--text-secondary); }
.product-meta span { display: flex; align-items: center; gap: 4px; }
.product-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-discovered { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.status-approved { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); }
.status-content_created { background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); }
.product-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ─── Content List ───────────────────────────────── */
.content-list { display: flex; flex-direction: column; gap: 12px; }
.content-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.content-item:hover { border-color: rgba(255, 255, 255, 0.1); }
.content-style-badge {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
  white-space: nowrap;
}
.content-info { flex: 1; }
.content-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.content-subtitle { font-size: 12px; color: var(--text-secondary); }
.content-actions { display: flex; gap: 8px; }

/* ─── Empty State ────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; }

/* ─── Select ─────────────────────────────────────── */
.select-sm {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
}

/* ─── Toast ──────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  backdrop-filter: blur(20px);
  min-width: 280px;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

/* ─── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.modal-body { padding: 24px; }

/* ─── Settings ───────────────────────────────────── */
.settings-group { margin-bottom: 32px; }
.settings-group h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
.service-status-grid { display: flex; flex-direction: column; gap: 8px; }
.service-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-secondary); border-radius: var(--radius-sm);
}
.service-name { font-weight: 500; font-size: 14px; }
.service-badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.service-online { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.service-offline { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* ─── Loading ────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ─── Animations ─────────────────────────────────── */
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.page.active > * { animation: fadeIn 0.3s ease; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .products-grid { grid-template-columns: 1fr; }
}
