/* ═══════════════════════════════════════════════════════
   YouTube Pipeline — Shared Design System (MD3 Dark)
   Manrope + Inter, Material Design 3 color tokens
   ═══════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* ── MD3 Design Tokens ── */
:root {
  /* Surfaces */
  --bg:                     #111317;
  --surface:                #111317;
  --surface-dim:            #111317;
  --surface-bright:         #37393e;
  --surface-container-lowest:#0c0e12;
  --surface-container-low:  #1a1c20;
  --surface-container:      #1e2024;
  --surface-container-high: #282a2e;
  --surface-container-highest:#333539;
  --surface-variant:        #333539;

  /* Old aliases (backward compat) */
  --card:                   #1e2024;
  --card2:                  #282a2e;
  --border:                 #424754;
  --border-light:           #424754;

  /* Text */
  --text:                   #e2e2e8;
  --text2:                  #c2c6d6;
  --muted:                  #8c909f;
  --on-surface:             #e2e2e8;
  --on-surface-variant:     #c2c6d6;

  /* Primary */
  --primary:                #adc6ff;
  --primary-container:      #4d8eff;
  --on-primary:             #002e6a;
  --on-primary-fixed:       #001a42;
  --blue:                   #4d8eff;
  --accent:                 #adc6ff;

  /* Secondary */
  --secondary:              #b1c6f9;
  --secondary-container:    #304671;

  /* Tertiary */
  --tertiary:               #d0bcff;
  --tertiary-container:     #a078ff;
  --purple:                 #d0bcff;

  /* Error */
  --error:                  #ffb4ab;
  --error-container:        #93000a;
  --red:                    #ffb4ab;

  /* Functional */
  --green:                  #34d399;
  --orange:                 #fbbf24;
  --magenta:                #ec4899;
  --yellow:                 #ffc107;

  /* Outline */
  --outline:                #8c909f;
  --outline-variant:        #424754;

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

  /* Radii (MD3 style) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 50%;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-xl: 0 12px 48px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 15px rgba(173,198,255,0.1);

  /* Typography */
  --font-headline: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', sans-serif;
}

/* ── Material Symbols defaults ── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}

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

/* ── Base ── */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

/* ── Utility classes ── */
.glass-panel {
  background: rgba(51, 53, 57, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(66, 71, 84, 0.2);
}
.ai-glow {
  box-shadow: 0 0 15px rgba(173, 198, 255, 0.1);
}

/* ── Buttons ── */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.4;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-blue { background: var(--primary-container); color: var(--on-primary-fixed); }
.btn-blue:hover { background: #5a94ff; }
.btn-red { background: var(--error-container); color: var(--error); }
.btn-red:hover { filter: brightness(1.2); }
.btn-green { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.3); }
.btn-green:hover { background: rgba(52,211,153,0.25); filter: none; }
.btn-orange { background: rgba(251,191,36,0.15); color: var(--orange); border: 1px solid rgba(251,191,36,0.3); }
.btn-orange:hover { background: rgba(251,191,36,0.25); filter: none; }
.btn-purple { background: rgba(208,188,255,0.15); color: var(--tertiary); border: 1px solid rgba(208,188,255,0.3); }
.btn-purple:hover { background: rgba(208,188,255,0.25); filter: none; }
.btn-magenta { background: var(--magenta); color: #fff; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--outline-variant);
  color: var(--on-surface-variant);
}
.btn-outline:hover {
  border-color: var(--outline);
  background: var(--surface-container);
  color: var(--text);
  filter: none;
}

.btn-primary {
  background: var(--primary-container);
  color: var(--on-primary-fixed);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(77,142,255,0.2);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(77,142,255,0.3); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; }

/* ── Form Controls ── */
input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-container-highest);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: all 0.2s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(173,198,255,0.15);
}
input::placeholder, textarea::placeholder {
  color: var(--muted);
}
textarea {
  resize: vertical;
  min-height: 60px;
}

label {
  display: block;
  font-size: 10px;
  color: var(--on-surface-variant);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  font-family: var(--font-body);
}

/* ── Card ── */
.card {
  background: var(--surface-container);
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: background 0.2s ease;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface-container-high);
  border: none;
  border-radius: var(--radius-2xl);
  padding: 32px;
  width: 480px;
  max-width: 90vw;
  box-shadow: var(--shadow-xl);
}
.modal h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: var(--space-5);
  letter-spacing: -0.02em;
}
.modal .actions { display: flex; gap: var(--space-2); margin-top: var(--space-5); justify-content: flex-end; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(51,53,57,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  display: none;
  box-shadow: var(--shadow-lg);
  color: var(--on-surface);
}
.toast.show { display: block; animation: fadeIn 0.25s ease-out; }
.toast.error { background: rgba(147,0,10,0.3); color: var(--error); }

/* ── Loading Spinner ── */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── Option Cards (title/description selection) ── */
.option-card {
  background: var(--surface-container-low);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.option-card:hover { background: var(--surface-container); }
.option-card.selected {
  border-color: var(--primary);
  background: rgba(173,198,255,0.06);
  box-shadow: var(--shadow-glow);
}
.option-card .check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--surface-container-highest);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s ease;
}
.option-card.selected .check {
  background: var(--primary-container);
  border-color: var(--primary-container);
  color: var(--on-primary-fixed);
}
.option-card .title-text {
  font-size: 14px;
  font-weight: 600;
  padding-right: 32px;
  line-height: 1.4;
}
.option-card .desc-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--on-surface-variant);
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
}
.option-card .char-count {
  font-size: 10px;
  color: var(--muted);
  margin-top: var(--space-1);
}
.option-card .card-actions {
  position: absolute;
  top: 10px;
  right: 38px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.option-card:hover .card-actions { opacity: 1; }
.option-card .card-actions button {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--surface-container-high);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.option-card .card-actions button:hover {
  background: var(--surface-container-highest);
  color: var(--text);
}
.option-card .card-actions button.btn-delete:hover {
  background: rgba(255,180,171,0.15);
  color: var(--error);
}

/* ── Cover Cards ── */
.covers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: var(--space-3);
}
.cover-card {
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: var(--surface-container-low);
}
.cover-card:hover { background: var(--surface-container); }
.cover-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(52,211,153,0.25);
}
.cover-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.cover-card .cover-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cover-card:hover .cover-actions { opacity: 1; }

/* ── Tags ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(173,198,255,0.1);
  border: 1px solid rgba(173,198,255,0.2);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}
.tag .tag-x {
  cursor: pointer;
  opacity: 0.6;
  font-size: 13px;
}
.tag .tag-x:hover { opacity: 1; }

/* ── Status Indicators ── */
.status-bar { display: flex; gap: 4px; margin-bottom: var(--space-4); }
.status-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-container-highest);
  transition: background 0.3s ease;
}
.status-step.active { background: var(--primary-container); }
.status-step.done { background: var(--green); }

/* ── Prompt Cards (thumbnail approval) ── */
.prompt-card {
  background: var(--surface-container-low);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: all 0.15s ease;
  position: relative;
}
.prompt-card.approved {
  border-color: var(--green);
  background: rgba(52,211,153,0.04);
  box-shadow: 0 0 12px rgba(52,211,153,0.1);
}
.prompt-card.rejected {
  opacity: 0.4;
}
.prompt-card .prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.prompt-card .prompt-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--tertiary);
}
.prompt-card .prompt-actions {
  display: flex;
  gap: var(--space-1);
}
.prompt-card textarea {
  font-size: 12px;
  min-height: 80px;
  background: var(--surface-container);
}
.prompt-card .prompt-meta {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--muted);
}

/* ── Split Test Matrix ── */
.matrix-preview {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.matrix-cell {
  background: var(--surface-container-low);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: 12px;
}
.matrix-cell img {
  width: 64px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

/* ── Section ── */
.section {
  background: var(--surface-container);
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-7);
  margin-bottom: var(--space-5);
}
.section h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-headline);
}
.section h2 .num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-container);
  color: var(--on-primary-fixed);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.3s ease;
}
.section h2 .num.done { background: var(--green); color: #fff; }

/* ── Actions Bar ── */
.actions-bar {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

/* ── Topbar (shared between express + editor) ── */
.topbar {
  height: 52px;
  background: rgba(12,14,18,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: none;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.topbar .back-btn {
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all 0.15s;
}
.topbar .back-btn:hover {
  background: var(--surface-container-high);
  color: var(--text);
  text-decoration: none;
}
.topbar h1 { font-size: 16px; font-weight: 700; }
.topbar .spacer { flex: 1; }

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

.sidebar {
  width: 256px;
  background: var(--surface-container-lowest);
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  font-family: var(--font-headline);
}
.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo h1 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--primary);
}
.sidebar-logo h1 span { color: var(--primary); }
.sidebar-logo .ops-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav a, .sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
  font-family: var(--font-headline);
  letter-spacing: -0.01em;
}
.sidebar-nav a:hover, .sidebar-nav button:hover {
  background: var(--surface-container);
  color: var(--on-surface);
  text-decoration: none;
}
.sidebar-nav a.active, .sidebar-nav button.active {
  background: rgba(173,198,255,0.1);
  color: var(--primary);
}
.sidebar-nav .nav-icon {
  width: 24px;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-bottom {
  padding: 16px 12px;
  border-top: none;
  background: var(--surface-container-low);
  margin: 0 8px 8px;
  border-radius: var(--radius-lg);
}

.main-content {
  flex: 1;
  margin-left: 256px;
}

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-7) var(--space-8);
}

/* ── Settings Grid ── */
.settings-section {
  background: var(--surface-container);
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-7);
  margin-bottom: var(--space-5);
}
.settings-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-5);
  font-family: var(--font-headline);
  letter-spacing: -0.02em;
}
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.settings-field label {
  font-size: 10px;
  margin-bottom: 6px;
}
.social-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-2);
}
.social-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  background: var(--surface-container-high);
}

/* ── Options Grid ── */
.options-grid {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ── Keyframes ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Scrollbar (MD3 style) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-container-highest); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .container { padding: 16px; }
  .section { padding: 16px; }
  .covers-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .toast { bottom: 12px; right: 12px; left: 12px; text-align: center; }
  .btn { min-height: 44px; }
  .modal { width: 95vw; padding: 20px; }
  .actions-bar { flex-direction: column; }
  .actions-bar .btn { width: 100%; }
  .settings-row { grid-template-columns: 1fr; }
}
