/* ================================================================
   TranscriptGrab — Design System
   Premium dark UI inspired by Linear / Raycast
   ================================================================ */

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  --bg:        #0b0b11;
  --surface:   #13131d;
  --surface-2: #1a1a28;
  --border:    rgba(255, 255, 255, 0.07);
  --border-hl: rgba(255, 255, 255, 0.12);

  --text:      #eaeaf0;
  --text-2:    #a0a0b8;
  --text-3:    #62627a;

  --primary:   #ff3366;
  --primary-2: #ff6633;
  --gradient:  linear-gradient(135deg, var(--primary), var(--primary-2));

  --green:     #00d4aa;
  --red:       #ff4757;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0, 0, 0, 0.4);

  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* subtle radial glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255, 51, 102, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── App Shell ───────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeUp 0.6s ease;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-2);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ── Input Section ───────────────────────────────────────── */
.input-section {
  margin-bottom: 24px;
  animation: fadeUp 0.6s ease 0.1s both;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 16px;
  gap: 8px;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 51, 102, 0.12);
}

.input-icon {
  color: var(--text-3);
  flex-shrink: 0;
}

#urlInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 12px 0;
}

#urlInput::placeholder {
  color: var(--text-3);
}

.fetch-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.15s;
}

.fetch-btn:hover { opacity: 0.9; transform: scale(1.02); }
.fetch-btn:active { transform: scale(0.98); }

.fetch-btn.loading .fetch-btn-text  { display: none; }
.fetch-btn.loading .fetch-btn-loader { display: block; animation: spin 0.8s linear infinite; }
.fetch-btn-loader { display: none; }

.hint {
  margin-top: 10px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ── Error Banner ────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 71, 87, 0.08);
  border: 1px solid rgba(255, 71, 87, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  color: #ff6b7a;
  font-size: 0.88rem;
  animation: fadeUp 0.3s ease;
}

/* ── Video Preview ───────────────────────────────────────── */
.video-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 20px;
  animation: fadeUp 0.4s ease;
}

.thumbnail {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.video-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-channel {
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 4px;
  display: block;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeUp 0.4s ease 0.05s both;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.tool-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hl);
}

.tool-btn.copied {
  color: var(--green);
  border-color: rgba(0, 212, 170, 0.3);
}

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  transition: border-color 0.25s;
}

.search-box:focus-within {
  border-color: var(--primary);
}

.search-box svg {
  color: var(--text-3);
  flex-shrink: 0;
}

.search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 7px 0;
  width: 120px;
}

.search-input::placeholder {
  color: var(--text-3);
}

/* Toggle */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle input { display: none; }

.toggle-slider {
  width: 34px;
  height: 18px;
  background: var(--text-3);
  border-radius: 10px;
  position: relative;
  transition: background 0.25s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.8rem;
  color: var(--text-2);
  font-weight: 500;
}

/* ── Transcript Container ────────────────────────────────── */
.transcript-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 20px;
  animation: fadeUp 0.4s ease 0.1s both;
}

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

.transcript-lines {
  padding: 8px 0;
}

.transcript-line {
  display: flex;
  gap: 12px;
  padding: 6px 20px;
  font-size: 0.88rem;
  line-height: 1.65;
  transition: background 0.15s;
}

.transcript-line:hover {
  background: rgba(255, 255, 255, 0.03);
}

.line-time {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 500;
  min-width: 58px;
  flex-shrink: 0;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
  opacity: 1;
  transition: opacity 0.3s, width 0.3s, min-width 0.3s, margin 0.3s;
}

.hide-timestamps .line-time {
  opacity: 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  margin: 0;
}

.line-text {
  color: var(--text);
}

.line-text mark {
  background: rgba(255, 51, 102, 0.25);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

.transcript-line.hidden {
  display: none;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
  font-size: 0.9rem;
}

/* ── Stats ───────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
  animation: fadeUp 0.4s ease 0.15s both;
}

.stat {
  text-align: center;
  padding: 16px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding-top: 8px;
  color: var(--text-3);
  font-size: 0.78rem;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border-hl);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Skeleton Loading ────────────────────────────────────── */
.skeleton-line {
  display: flex;
  gap: 12px;
  padding: 8px 20px;
}

.skeleton-block {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255,255,255,0.05) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-time  { width: 50px; flex-shrink: 0; }
.skeleton-text  { flex: 1; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .app { padding: 32px 16px 24px; }

  .logo h1 { font-size: 1.4rem; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-left, .toolbar-right {
    justify-content: center;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .video-preview {
    flex-direction: column;
    text-align: center;
  }

  .thumbnail {
    width: 100%;
    max-width: 280px;
  }

  .search-input {
    width: 100px;
  }
}
