/* ============================================================
   Social Buster - Global Styles
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
  /* Colors */
  --color-primary:        #6366f1; /* Indigo 500 */
  --color-primary-dark:   #4f46e5; /* Indigo 600 */
  --color-primary-light:  #e0e7ff; /* Indigo 100 */
  --color-sidebar-bg:     #1e293b; /* Slate 800 */
  --color-sidebar-text:   #94a3b8; /* Slate 400 */
  --color-sidebar-active: #f1f5f9; /* Slate 100 */
  --color-bg:             #f8fafc; /* Slate 50 */
  --color-surface:        #ffffff;
  --color-border:         #e2e8f0; /* Slate 200 */
  --color-text:           #0f172a; /* Slate 900 */
  --color-text-muted:     #64748b; /* Slate 500 */
  --color-success:        #22c55e; /* Green 500 */
  --color-warning:        #f59e0b; /* Amber 500 */
  --color-danger:         #ef4444; /* Red 500 */
  --color-info:           #3b82f6; /* Blue 500 */

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  /* Borders */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 60px;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

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

img { display: block; max-width: 100%; }

/* ============================================================
   AUTH SCREEN (login / register)
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: var(--space-6);
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.auth-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.auth-tagline {
  color: var(--color-text-muted);
  text-align: center;
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-6);
}

.auth-tab {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }

/* ============================================================
   APP SHELL (sidebar + main)
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--space-6) var(--space-5);
  font-size: var(--text-lg);
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-logo img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

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

.sidebar-nav { flex: 1; padding: var(--space-4) 0; }

.sidebar-section-label {
  padding: var(--space-3) var(--space-5) var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-sidebar-active);
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-right: 3px solid var(--color-primary);
}

.sidebar-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-email {
  font-size: var(--text-xs);
  color: var(--color-sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Main content area ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--space-8);
  max-width: 1200px;
}

.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.page-subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

/* Side-by-side form fields — auto-collapses to single column on small screens */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

/* Visual section divider inside large forms (e.g. expanded Brand Profile) */
.form-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding-top: var(--space-4);
  padding-bottom: var(--space-1);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2);
}

/* Required field marker — red asterisk on mandatory profile fields */
.required-marker {
  color: #dc2626;
  font-weight: 700;
  margin-left: 2px;
}

/* Profile completion banner — shown on dashboard and profile page
   when mandatory fields are still missing */
.profile-completion-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  color: #92400e;
  line-height: 1.5;
}

.profile-completion-banner ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.profile-completion-banner li {
  margin: 2px 0;
}

label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

textarea { resize: vertical; min-height: 80px; }

/* Checkboxes */
.checkbox-group { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); text-decoration: none; color: #fff; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); text-decoration: none; color: var(--color-text); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }

.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }
.btn-full { width: 100%; }

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

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Global toast — fixed position, immune to view re-renders */
#global-toasts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#global-toasts .toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 480px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastSlideIn 0.3s ease-out;
}
#global-toasts .toast-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
#global-toasts .toast-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
#global-toasts .toast-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
#global-toasts .toast-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   BADGES / STATUS INDICATORS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-draft     { background: #f1f5f9; color: #64748b; }
.badge-approved  { background: #eff6ff; color: #1d4ed8; }
.badge-scheduled { background: #fef3c7; color: #92400e; }
.badge-published { background: #f0fdf4; color: #166534; }
.badge-failed    { background: #fef2f2; color: #991b1b; }
.badge-active    { background: #f0fdf4; color: #166534; }
.badge-trialing  { background: #eff6ff; color: #1d4ed8; }
.badge-past-due  { background: #fef3c7; color: #92400e; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }

/* Media card analysis status badges */
.badge-analysis-ready    { background: #f0fdf4; color: #166534; gap: 4px; }
.badge-analysis-pending  { background: #fef9c3; color: #854d0e; gap: 4px; display: inline-flex; align-items: center; }
.badge-analysis-failed   { background: #fef2f2; color: #991b1b; }

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

.spinner-lg  { width: 40px; height: 40px; border-width: 3px; }
.spinner-sm  { width: 16px; height: 16px; border-width: 2px; vertical-align: middle; }
.spinner-xs  { width: 11px; height: 11px; border-width: 2px; vertical-align: middle; display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ============================================================
   DASHBOARD STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card[onclick]:hover {
  border-color: var(--color-primary, #2563eb);
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,.1));
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
}

/* ---- Power BI-Style KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.kpi-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* Color accents — left border stripe */
.kpi-card--green   { border-left: 4px solid var(--color-success); }
.kpi-card--blue    { border-left: 4px solid var(--color-info); }
.kpi-card--indigo  { border-left: 4px solid var(--color-primary); }
.kpi-card--amber   { border-left: 4px solid var(--color-warning); }
.kpi-card--purple  { border-left: 4px solid #8b5cf6; }
.kpi-card--red     { border-left: 4px solid var(--color-danger); }
.kpi-card--pink    { border-left: 4px solid #ec4899; }

.kpi-card__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.kpi-card__value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}
.kpi-card__delta {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: 4px;
}
.kpi-card__delta--up   { color: var(--color-success); }
.kpi-card__delta--down { color: var(--color-danger); }
.kpi-card__delta--flat { color: var(--color-text-muted); }

.kpi-card__sparkline {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 110px;
  height: 44px;
  opacity: 0.5;
  pointer-events: none;
}

.kpi-card__sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ---- Chart containers ---- */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: var(--space-6);
}
.chart-card__title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
@media (max-width: 768px) {
  .chart-row { grid-template-columns: 1fr; }
}

/* ---- Lead field pills ---- */
.field-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  font-size: var(--text-xs);
  margin: 2px;
  white-space: nowrap;
}
.field-pill__label {
  font-weight: 700;
  color: var(--color-primary-dark);
}
.field-pill__value {
  color: var(--color-text);
}

/* ---- Conversion rate gauge (inline bar) ---- */
.rate-gauge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rate-gauge__pct {
  font-weight: 700;
  font-size: var(--text-sm);
  min-width: 36px;
}
.rate-gauge__bar {
  width: 60px;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.rate-gauge__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--space-2); }
.gap-4       { gap: var(--space-4); }
.gap-6       { gap: var(--space-6); }
.mt-4        { margin-top: var(--space-4); }
.mt-6        { margin-top: var(--space-6); }
.mb-4        { margin-bottom: var(--space-4); }
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.text-sm     { font-size: var(--text-sm); }
.font-semibold { font-weight: 600; }
.hidden      { display: none !important; }

/* ============================================================
   MEDIA LIBRARY
   ============================================================ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.media-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.media-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.15); }

.media-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-tertiary, #1a1a2e);
  overflow: hidden;
}
.media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.media-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.media-card-header {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px 10px 0;
}
.media-filename {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-themes, .media-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 10px;
}
.media-card-actions {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  margin-top: auto;
}

/* ============================================================
   CLIP PICKER MODAL
   Smart Clip button → overlay → segment grid
   ============================================================ */

/* Full-screen dark overlay behind the modal */
.clip-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* The white modal box */
.clip-picker-modal {
  background: var(--bg-primary, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header row: title + close button */
.clip-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
}
.clip-picker-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.clip-picker-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
  margin: 3px 0 0;
}
.clip-picker-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted, #6b7280);
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
.clip-picker-close:hover { background: var(--bg-secondary, #f3f4f6); }

/* Scrollable grid of segment cards */
.clip-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Individual segment card */
.clip-card {
  background: var(--bg-secondary, #f9fafb);
  border: 2px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.clip-card:hover {
  border-color: var(--primary, #6366f1);
  box-shadow: 0 3px 14px rgba(99,102,241,0.18);
  transform: translateY(-2px);
}
.clip-card--best-match {
  border-color: var(--primary, #6366f1);
  background: var(--bg-primary, #fff);
}

/* "Best match" badge in the top-left corner */
.clip-best-match-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary, #6366f1);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

/* Thumbnail container */
.clip-card-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #1a1a2e;
  overflow: hidden;
  flex-shrink: 0;
}
.clip-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.clip-card-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: #2a2a3e;
  color: rgba(255,255,255,0.5);
  width: 100%;
  height: 100%;
}

/* Duration badge overlaid on thumbnail bottom-right */
.clip-card-duration {
  position: absolute;
  bottom: 5px;
  right: 6px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Meta section below thumbnail */
.clip-card-meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.clip-card-time {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary, #111);
}
.clip-card-desc {
  font-size: 0.75rem;
  color: var(--text-secondary, #4b5563);
  line-height: 1.4;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mood badge */
.clip-mood-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-tertiary, #e5e7eb);
  color: var(--text-secondary, #374151);
  text-transform: capitalize;
  width: fit-content;
}
/* Mood-specific colors */
.clip-mood-badge--energetic   { background: #fef3c7; color: #92400e; }
.clip-mood-badge--happy       { background: #dcfce7; color: #166534; }
.clip-mood-badge--heartwarming{ background: #fce7f3; color: #9d174d; }
.clip-mood-badge--funny       { background: #fef9c3; color: #854d0e; }
.clip-mood-badge--dramatic    { background: #ede9fe; color: #5b21b6; }
.clip-mood-badge--inspirational{background: #dbeafe; color: #1e40af; }
.clip-mood-badge--professional{ background: #f1f5f9; color: #1e293b; }
.clip-mood-badge--nostalgic   { background: #fdf2f8; color: #831843; }
.clip-mood-badge--exciting    { background: #fff7ed; color: #9a3412; }
.clip-mood-badge--calm        { background: #ecfdf5; color: #065f46; }

/* Tags row */
.clip-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}
.clip-tag {
  font-size: 0.65rem;
  background: var(--bg-tertiary, #f3f4f6);
  color: var(--text-muted, #6b7280);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Energy + pacing row */
.clip-card-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 5-bar energy indicator */
.clip-energy-wrap {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.clip-energy-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--border-color, #d1d5db);
}
/* Each bar is slightly taller than the previous */
.clip-energy-bar:nth-child(1) { height: 5px; }
.clip-energy-bar:nth-child(2) { height: 7px; }
.clip-energy-bar:nth-child(3) { height: 9px; }
.clip-energy-bar:nth-child(4) { height: 11px; }
.clip-energy-bar:nth-child(5) { height: 14px; }
.clip-energy-bar--on { background: var(--primary, #6366f1); }

/* Pacing badge */
.clip-pacing-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: capitalize;
}
.clip-pacing-badge--fast     { background: #fee2e2; color: #991b1b; }
.clip-pacing-badge--moderate { background: #fef9c3; color: #854d0e; }
.clip-pacing-badge--slow     { background: #dbeafe; color: #1e40af; }

/* Platform fit tag */
.clip-platform-match {
  font-size: 0.68rem;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Footer with cancel button */
.clip-picker-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
  text-align: right;
}

/* Loading and error states */
.clip-picker-loading-body,
.clip-picker-error-body {
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-muted, #6b7280);
}

/* Smart Clip button on the post card */
.clip-picker-btn {
  background: var(--primary, #6366f1);
  color: #fff;
  border: none;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
}
.clip-picker-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.clip-picker-btn--failed { background: var(--text-muted, #9ca3af); }

/* ----------------------------------------------------------------
   CLIP CARD — updated structure
   The card is now a <div> with two separate actions:
     1. .clip-card-thumb-wrap--btn  → preview the clip
     2. .clip-card-select-btn       → select/use the clip
   ---------------------------------------------------------------- */

/* Thumbnail wrapper doubles as a preview button */
.clip-card-thumb-wrap--btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  width: 100%;
  display: block;
}
.clip-card-thumb-wrap--btn:focus-visible {
  outline: 2px solid var(--primary, #6366f1);
  outline-offset: 2px;
}

/* Play icon overlaid on thumbnail, visible on hover */
.clip-card-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  border-radius: 6px 6px 0 0;
}
.clip-card-thumb-wrap--btn:hover .clip-card-play-icon,
.clip-card-thumb-wrap--btn:focus-visible .clip-card-play-icon {
  opacity: 1;
}

/* "Use this clip" button at the bottom of each card */
.clip-card-select-btn {
  width: calc(100% - 16px);
  margin: 0 8px 10px;
  padding: 7px 10px;
  background: var(--primary, #6366f1);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.clip-card-select-btn:hover { background: var(--primary-dark, #4f46e5); transform: translateY(-1px); }
.clip-card-select-btn:active { transform: translateY(0); }

/* ----------------------------------------------------------------
   CLIP PREVIEW PANEL
   Sits between the header and the cards grid.
   Hidden by default; shown when a thumbnail is clicked.
   ---------------------------------------------------------------- */
.clip-preview-panel {
  display: none;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: #000;
}
.clip-preview-panel--active {
  display: block;
}
.clip-preview-wrap {
  display: flex;
  flex-direction: column;
}
/* Wrapper needed so the loading overlay can sit on top of the video */
.clip-preview-video-wrap {
  position: relative;
}
/* Spinner overlay shown while the stream token is being fetched */
.clip-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
}
/* Video fills the panel width; max-height keeps it compact */
.clip-preview-video {
  width: 100%;
  max-height: 340px;
  display: block;
  background: #000;
}
/* Row below the video: timestamp label + close button */
.clip-preview-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary, #f3f4f6);
  border-top: 1px solid var(--border-color, #e5e7eb);
}
.clip-preview-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #111);
}
.clip-preview-close-btn {
  appearance: none;
  background: none;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  transition: background 0.15s;
}
.clip-preview-close-btn:hover { background: var(--bg-primary, #fff); }
.clip-preview-unavailable {
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
  background: var(--bg-secondary, #f3f4f6);
}

/* ============================================================
   PRICING CARDS (Settings → Subscription section)
   ============================================================ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 4px;
}
.pricing-card {
  position: relative;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pricing-card--featured {
  border-color: #0d9488;
  background: #f0fdfa;
  box-shadow: 0 0 0 3px rgba(13,148,136,0.12);
}
.pricing-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: #0d9488;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.pricing-name {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}
.pricing-price {
  display: flex;
  align-items: baseline;
  gap: 3px;
}
.pricing-amount {
  font-size: 28px;
  font-weight: 800;
  color: #1e293b;
}
.pricing-period {
  font-size: 13px;
  color: #64748b;
}
.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.pricing-features li {
  font-size: 13px;
  color: #475569;
}
.pricing-upgrade-btn {
  margin-top: 4px;
  width: 100%;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: var(--space-5); }
}

/* ============================================================
   Platform Checkbox Labels (My Profile)
   ============================================================ */
#platform-checkboxes label { user-select: none; }
#platform-checkboxes label:hover { border-color: #6366f1; background: #f5f3ff; }
#platform-checkboxes label:has(input:checked) {
  border-color: #6366f1;
  background: #eef2ff;
  box-shadow: 0 0 0 1px #6366f1;
}

/* ============================================================
   Publishing Queue — Calendar View
   ============================================================ */

/* View toggle strip */
.queue-view-toggle {
  display: inline-flex;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.queue-view-btn {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.queue-view-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.queue-view-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Calendar header — month navigation */
.queue-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  margin-bottom: 8px;
}
.queue-cal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.queue-cal-nav {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.queue-cal-nav:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Calendar grid */
.queue-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.queue-cal-dayname {
  background: var(--bg-secondary);
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Individual day cell */
.queue-cal-day {
  background: var(--bg-primary);
  min-height: 90px;
  padding: 6px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.queue-cal-day:hover {
  background: var(--bg-secondary);
}
.queue-cal-day.outside {
  background: var(--bg-secondary);
  opacity: 0.4;
}
.queue-cal-day.today {
  background: rgba(99, 102, 241, 0.06);
}
.queue-cal-day.today .queue-cal-daynum {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.queue-cal-day.selected {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.queue-cal-daynum {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Post chips inside day cells */
.queue-cal-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.queue-cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity 0.15s;
}
.queue-cal-chip:hover {
  opacity: 0.8;
}
.queue-cal-chip.status-failed {
  outline: 2px solid #ef4444;
  outline-offset: -2px;
}
.queue-cal-chip.status-published {
  opacity: 0.6;
}
.queue-cal-overflow {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 1px 6px;
}

/* Day detail panel (shows below calendar when a day is clicked) */
.queue-cal-detail {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg-primary);
}
.queue-cal-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.queue-cal-detail-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.queue-cal-detail-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  padding: 4px;
}

/* Mobile calendar */
@media (max-width: 640px) {
  .queue-cal-day { min-height: 60px; padding: 4px; }
  .queue-cal-chip { font-size: 0; padding: 0; width: 8px; height: 8px; border-radius: 50%; display: block; }
  .queue-cal-chips { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .queue-cal-overflow { display: none; }
}
