/* ═══════════════════════════════════════════════════════════════════
   AdAutomate Video Generator — Stylesheet
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --accent: #10B981;
  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --dark-bg: #1E293B;
  --text: #334155;
  --text-light: #64748B;
  --border: #E2E8F0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary), #8B5CF6);
  color: white;
  padding: 2rem 1.5rem;
  text-align: center;
}
header h1 { font-size: 1.8rem; margin-bottom: 0.25rem; }
header p { opacity: 0.85; font-size: 0.95rem; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  position: sticky; top: 0; z-index: 10;
}
.tab {
  flex: 1;
  padding: 1rem;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Main ────────────────────────────────────────────────────────── */
main { max-width: 720px; margin: 0 auto; padding: 1.5rem; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Form ────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}
label:first-child { margin-top: 0; }
input[type="text"], textarea, select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
textarea { resize: vertical; min-height: 54px; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin-top: 0.25rem; }

/* ── Duration Buttons ────────────────────────────────────────────── */
.duration-btns { display: flex; gap: 0.5rem; }
.dur-btn {
  flex: 1;
  padding: 0.55rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.dur-btn:hover { border-color: var(--primary); color: var(--primary); }
.dur-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Chips ───────────────────────────────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.chip {
  padding: 0.45rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Generate Button ─────────────────────────────────────────────── */
.generate-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary), #8B5CF6);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.generate-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.3); }
.generate-btn:active { transform: translateY(0); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Loading ─────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 3rem 1rem; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ───────────────────────────────────────────────────────── */
.error-msg {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* ── Results ─────────────────────────────────────────────────────── */
#results-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.results-header h2 { font-size: 1.15rem; }
.results-actions { display: flex; gap: 0.5rem; }
.action-btn {
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Timeline ────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute; left: 10px; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 2px;
}
.timeline-segment {
  position: relative;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 10px;
  border-left: 4px solid var(--primary);
  transition: all 0.2s;
}
.timeline-segment:hover { transform: translateX(4px); box-shadow: var(--shadow); }
.timeline-segment::before {
  content: '';
  position: absolute; left: -2.35rem; top: 1rem;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--card-bg);
}
.timeline-segment:last-child { margin-bottom: 0; }
.segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.segment-timestamp {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.tone-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}
.tone-energetic, .tone-Енергично { background: #EF4444; }
.tone-authentic, .tone-Автентично { background: #10B981; }
.tone-humorous, .tone-Забавно { background: #F59E0B; }
.tone-emotional, .tone-Емоционално { background: #8B5CF6; }
.tone-narrative, .tone-Разказ { background: #3B82F6; }
.tone-demonstrative, .tone-Демонстрация { background: #06B6D4; }
.tone-social_proof, .tone-Social-Proof { background: #F97316; }
.tone-confident, .tone-Уверено { background: #6366F1; }
.tone-shocking, .tone-Шокиращо { background: #DC2626; }
.tone-questioning, .tone-Въпросително { background: #7C3AED; }
.tone-explanatory, .tone-Обяснително { background: #0891B2; }
.tone-friendly, .tone-Приятелски { background: #059669; }
.tone-feature, .tone-Функция { background: #0D9488; }

.segment-text {
  font-size: 0.9rem;
  line-height: 1.55;
  padding-right: 0.5rem;
  margin-bottom: 0.5rem;
}
.copy-btn {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
}
.timeline-segment:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* ── Hashtags ────────────────────────────────────────────────────── */
.hashtags-section { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.hashtags-section h3 { font-size: 0.85rem; margin-bottom: 0.5rem; color: var(--text-light); }
.hashtag-chip {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  margin: 0.2rem;
  background: #EEF2FF;
  color: var(--primary);
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.hashtag-chip:hover { background: var(--primary); color: white; }

/* ── Voiceover ───────────────────────────────────────────────────── */
.voiceover-callout {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-left: 4px solid #F59E0B;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #92400E;
}
.voiceover-callout strong { display: block; margin-bottom: 0.2rem; }

/* ── Hooks List ──────────────────────────────────────────────────── */
.hooks-list { counter-reset: hook-counter; }
.hook-card {
  counter-increment: hook-counter;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border-radius: 10px;
  border: 2px solid var(--border);
  transition: all 0.2s;
}
.hook-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.hook-card.best { border-color: #F59E0B; background: #FFFBEB; }
.hook-number {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-light);
  min-width: 24px;
}
.hook-card.best .hook-number { color: #B45309; }
.hook-card.best::after {
  content: '⭐ BEST';
  font-size: 0.65rem;
  font-weight: 800;
  color: #B45309;
  background: #FEF3C7;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}
.hook-content { flex: 1; }
.hook-text { font-size: 0.9rem; line-height: 1.5; margin-bottom: 0.35rem; }
.hook-meta { display: flex; gap: 0.5rem; align-items: center; }
.hook-type-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #EEF2FF;
  color: var(--primary);
}
.hook-score {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--dark-bg);
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}
.toast.show { opacity: 1; }

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* ── Dark Mode ───────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F172A;
    --card-bg: #1E293B;
    --text: #E2E8F0;
    --text-light: #94A3B8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);
  }
  input, textarea, select { background: var(--dark-bg); color: var(--text); }
  .chip { background: var(--dark-bg); }
  .timeline-segment { background: var(--dark-bg); }
  .hook-card { background: var(--dark-bg); }
  .hook-card.best { background: #281c00; }
  .hashtag-chip { background: #1e1b4b; }
  .voiceover-callout { background: #2b2000; color: #FDE68A; }
  .error-msg { background: #3B1111; color: #FCA5A5; border-color: #7F1D1D; }
  .action-btn, .copy-btn { background: var(--dark-bg); }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  main { padding: 0.75rem; }
  header { padding: 1.25rem 1rem; }
  header h1 { font-size: 1.3rem; }
  .results-header { flex-direction: column; align-items: flex-start; }
  .timeline { padding-left: 1.5rem; }
  .timeline-segment::before { left: -1.8rem; }
  .tab { font-size: 0.85rem; padding: 0.75rem 0.5rem; }
}
