/* ============ SponsorAgent Shared Styles ============ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

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

:root {
  --bg-dark: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #181825;
  --bg-input: #1a1a28;
  --accent: #6ee7b7;
  --accent-dim: #34d399;
  --accent-glow: rgba(110, 231, 183, 0.15);
  --text-primary: #f0f0f5;
  --text-secondary: #8b8b9e;
  --text-muted: #5a5a6e;
  --border: #1e1e2a;
  --border-focus: #2e2e4a;
  --gradient-start: #6ee7b7;
  --gradient-end: #3b82f6;
  --red: #f87171;
  --yellow: #fbbf24;
  --green: #34d399;
  --blue: #60a5fa;
  --yt-red: #ff0000;
  --twitch-purple: #9146ff;
  --tiktok-pink: #ff0050;
  --kick-green: #53fc18;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); }

/* ============ LAYOUT ============ */
.page-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 0 20px;
  margin-bottom: 32px;
  color: var(--text-primary);
}

.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

.sidebar-nav a .icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-plan {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 1000px;
}

/* ============ AUTH PAGES ============ */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.auth-logo span { color: var(--accent); }

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-error {
  display: none;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.form-success {
  display: none;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: #0a0a0f;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-full {
  width: 100%;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--border-focus);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}

/* ============ PAGE HEADER ============ */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ============ STATS ROW ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============ SCORE RING ============ */
.score-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--border);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.score-ring.good { border-color: var(--green); color: var(--green); }
.score-ring.ok { border-color: var(--yellow); color: var(--yellow); }
.score-ring.low { border-color: var(--red); color: var(--red); }

/* ============ TAGS ============ */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-accent { background: var(--accent-glow); color: var(--accent); }
.tag-blue { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.tag-red { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.tag-yellow { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }

/* ============ TABLES ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.data-table td {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
  border-radius: 3px;
  transition: width 0.3s;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  margin-bottom: 24px;
  font-size: 0.9rem;
}

/* ============ LOADING ============ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-secondary);
  gap: 12px;
}

/* ============ RATE CARD ============ */
.rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.rate-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.rate-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.rate-range {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

/* ============ THEME BAR ============ */
.theme-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.theme-name {
  width: 120px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.theme-bar .progress-bar {
  flex: 1;
}

.theme-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 40px;
  text-align: right;
}

/* ============ BRAND LIST ============ */
.brand-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.brand-chip.organic { border-color: rgba(52, 211, 153, 0.3); }
.brand-chip.match { border-color: rgba(96, 165, 250, 0.3); }

/* ============ PRICING ============ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.pricing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  transition: all 0.3s;
}

.pricing-card.featured {
  border-color: var(--accent);
  position: relative;
}

.pricing-card.featured::before {
  content: 'MOST POPULAR';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: #0a0a0f;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.pricing-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-dim);
}

.pricing-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.pricing-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.pricing-price span { font-size: 1rem; color: var(--text-muted); }

.pricing-period {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pricing-features {
  list-style: none;
  text-align: left;
  margin-bottom: 24px;
}

.pricing-features li {
  padding: 8px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pricing-features li::before {
  content: '✓';
  color: var(--accent);
  font-weight: 700;
}

/* ============ MOBILE ============ */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
}

.mobile-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.mobile-nav .logo span { color: var(--accent); }

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  .mobile-nav { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 25;
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 80px 16px 24px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .rate-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 20px;
  }
}

/* ============ CHANNEL CARD ============ */
.channel-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.channel-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.channel-info { flex: 1; min-width: 0; }

.channel-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.channel-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============ PASSWORD REQUIREMENTS ============ */
.password-requirements {
  margin-top: 8px;
  margin-bottom: 12px;
}

.requirement {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 3px 0;
  transition: color 0.2s;
}

.requirement .check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  transition: all 0.2s;
}

.requirement.met { color: var(--green); }
.requirement.met .check {
  background: var(--green);
  border-color: var(--green);
  color: #0a0a0f;
}

/* ============ TOOLTIP / MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 16px;
}

/* ============ FOOTER LINK ============ */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 500;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.back-link:hover { color: var(--accent); }

/* ============ PAGE FOOTER (fixed, sidebar-aware) ============ */
.page-footer {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  z-index: 5;
}

.page-footer a { color: var(--text-muted); }
.page-footer a:hover { color: var(--accent); }

/* ============ SKELETON LOADING ============ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 16px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-text.long { width: 85%; }
.skeleton-stat { height: 48px; width: 80px; margin-bottom: 4px; border-radius: 8px; }
.skeleton-card { height: 80px; width: 100%; border-radius: 14px; margin-bottom: 12px; }

/* ============ BUTTON LOADING STATE ============ */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.btn-primary.loading::after { border-top-color: #0a0a0f; }
.btn-secondary.loading::after { border-top-color: var(--accent); }

/* ============ TABLE WRAPPER (mobile scroll) ============ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}

.table-wrapper .data-table {
  min-width: 500px;
}

/* ============ SIDEBAR BACKDROP ============ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 24;
}

/* ============ ANALYSIS PROGRESS ============ */
.analysis-progress {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(110, 231, 183, 0.08);
  border: 1px solid rgba(110, 231, 183, 0.2);
  border-radius: 10px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--accent);
}

.analysis-progress.show { display: flex; }
.analysis-progress .spinner { flex-shrink: 0; }

/* ============ TOAST IMPROVEMENTS ============ */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============ MOBILE OVERRIDES ============ */
@media (max-width: 768px) {
  /* Footer: full width on mobile */
  .page-footer {
    left: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Buttons: minimum tap target */
  .btn {
    min-height: 44px;
  }

  /* iOS Safari zoom prevention on inputs */
  .form-group input,
  .form-group textarea,
  .form-group select,
  .auth-card input,
  .auth-card textarea,
  .auth-card select {
    font-size: 16px;
  }

  /* Channel actions stack on very small */
  .channel-card {
    flex-wrap: wrap;
  }

  .channel-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Sidebar backdrop shows when sidebar is open */
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.show {
    display: block;
  }
}

@media (max-width: 480px) {
  /* Single column stats on iPhone SE */
  .stats-row {
    grid-template-columns: 1fr;
  }

  /* Reduce card padding */
  .card {
    padding: 16px;
  }

  /* Smaller page header */
  .page-header h1 {
    font-size: 1.5rem;
  }

  /* Toast full width */
  .toast {
    left: 12px;
    right: 12px;
    transform: translateY(80px);
    max-width: none;
    width: auto;
  }

  .toast.show {
    transform: translateY(0);
  }
}
