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

:root {
  --ig-orange: #f58529;
  --ig-pink:   #dd2a7b;
  --ig-purple: #8134af;
  --ig-deep:   #515bd4;
  --gradient: linear-gradient(135deg, var(--ig-orange), var(--ig-pink), var(--ig-purple));
  --surface: #ffffff;
  --surface2: #f8f8fb;
  --border: #e8e8f0;
  --text: #1a1a2e;
  --text-muted: #6b6b8a;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.14);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f0f8;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background Gradient Blobs ────────────────────────────────────────────── */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(245,133,41,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 20%, rgba(221,42,123,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 60% 90%, rgba(129,52,175,0.10) 0%, transparent 70%);
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.header, .main, .footer { position: relative; z-index: 1; }

.header {
  text-align: center;
  padding: 48px 24px 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.75rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: var(--ig-pink);
  -webkit-text-fill-color: initial;
  background: var(--gradient);
  -webkit-background-clip: unset;
  background-clip: unset;
  border-radius: 10px;
  padding: 4px;
  stroke: url(#grad);
}

/* SVG gradient trick for logo icon */
.logo-icon rect, .logo-icon circle { stroke: var(--ig-pink); }

.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 420px;
  margin: 0 auto;
}

.main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--border);
}

.hidden { display: none !important; }

/* ─── Input ─────────────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 4px 8px 4px 14px;
  transition: border-color 0.2s;
}

.input-group:focus-within {
  border-color: var(--ig-pink);
  box-shadow: 0 0 0 3px rgba(221,42,123,0.1);
}

.input-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

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

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

.btn-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.btn-clear:hover { color: var(--ig-pink); background: rgba(221,42,123,0.06); }

/* ─── Chips ─────────────────────────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.chip svg { width: 14px; height: 14px; }

.chip:hover {
  border-color: var(--ig-pink);
  color: var(--ig-pink);
  background: rgba(221,42,123,0.05);
}

.chip.active {
  background: var(--gradient);
  border-color: transparent;
  color: white;
}

/* ─── Fetch Button ──────────────────────────────────────────────────────────── */
.btn-fetch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--gradient);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
}

.btn-fetch svg { width: 18px; height: 18px; }
.btn-fetch:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-fetch:active { transform: translateY(0); }
.btn-fetch:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ─── Loading ───────────────────────────────────────────────────────────────── */
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 24px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--ig-pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loadingText { color: var(--text-muted); font-size: 0.95rem; }

/* ─── Error ─────────────────────────────────────────────────────────────────── */
.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}

.error-icon {
  width: 44px;
  height: 44px;
  color: #e53e3e;
}

#errorMsg { color: var(--text-muted); font-size: 0.95rem; }

.btn-retry {
  padding: 10px 24px;
  border-radius: 10px;
  border: 2px solid var(--ig-pink);
  background: transparent;
  color: var(--ig-pink);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-retry:hover { background: var(--ig-pink); color: white; }

/* ─── Result Card ───────────────────────────────────────────────────────────── */
.preview-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.thumbnail-wrap {
  position: relative;
  flex-shrink: 0;
  width: 90px;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
}

#thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.overlay-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta { flex: 1; min-width: 0; padding-top: 4px; }
.meta-user {
  font-weight: 700;
  font-size: 1rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.meta-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Download Items ────────────────────────────────────────────────────────── */
.download-section { display: flex; flex-direction: column; gap: 10px; }

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s;
}

.download-item:hover { border-color: var(--ig-pink); }

.dl-info { display: flex; align-items: center; gap: 12px; }

.dl-format-badge {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-mp4 { background: rgba(81,91,212,0.12); color: var(--ig-deep); }
.badge-mp3 { background: rgba(221,42,123,0.12); color: var(--ig-pink); }
.badge-jpg, .badge-jpeg { background: rgba(245,133,41,0.12); color: var(--ig-orange); }
.badge-png { background: rgba(129,52,175,0.12); color: var(--ig-purple); }
.badge-zip { background: rgba(16,185,129,0.12); color: #059669; }

.dl-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.dl-size  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.btn-download {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  background: var(--gradient);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.15s;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-download svg { width: 14px; height: 14px; }
.btn-download:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-download:active { transform: translateY(0); }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-download.loading { opacity: 0.7; }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  color: white;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}

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

.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }

/* ─── Header tagline como H1 ────────────────────────────────────────────────── */
.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
  max-width: 480px;
  margin: 6px auto 0;
  line-height: 1.5;
}

/* ─── How to use ────────────────────────────────────────────────────────────── */
.how-card h2, .features-card h2, .faq-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

.steps { list-style: none; display: flex; flex-direction: column; gap: 14px; }

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.step-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.steps li strong { font-size: 0.95rem; display: block; margin-bottom: 2px; }
.steps li p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* ─── Features grid ─────────────────────────────────────────────────────────── */
.features-grid {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.features-grid li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.features-grid li svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--ig-pink);
}

.features-grid li strong { font-size: 0.88rem; display: block; }
.features-grid li p { font-size: 0.78rem; color: var(--text-muted); margin: 2px 0 0; }

/* ─── FAQ ───────────────────────────────────────────────────────────────────── */
.faq-list { display: flex; flex-direction: column; gap: 8px; }

details {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

summary {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--ig-pink);
  transition: transform 0.2s;
  flex-shrink: 0;
}

details[open] summary::after { content: '−'; }

details p {
  padding: 0 16px 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 0 16px 40px;
  position: relative;
  z-index: 1;
}

.footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 4px;
}

.footer-note {
  font-size: 0.72rem !important;
  opacity: 0.65;
}

/* ─── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .header { padding: 32px 16px 16px; }
  .logo { font-size: 1.4rem; }
  .card { padding: 18px; }
  .chips { gap: 6px; }
  .chip { padding: 7px 11px; font-size: 0.8rem; }
  .download-item { flex-direction: column; align-items: stretch; }
  .btn-download { justify-content: center; }
  .preview-section { flex-direction: column; align-items: center; text-align: center; }
  .thumbnail-wrap { width: 120px; height: 120px; }
  .features-grid { grid-template-columns: 1fr; }
}
