/* ==========================================================================
   VideoDown — Mobile App Design System (v3)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Colors */
  --bg:          #080c17;
  --bg-surface:  rgba(16, 22, 38, 0.85);
  --bg-card:     rgba(20, 27, 46, 0.9);
  --bg-elevated: rgba(28, 38, 62, 0.95);

  --border:      rgba(255, 255, 255, 0.07);
  --border-focus:rgba(99, 102, 241, 0.55);

  --primary:     #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow:  rgba(99,102,241,0.35);

  --green:       #10b981;
  --green-hover: #059669;
  --green-glow:  rgba(16,185,129,0.35);

  --red:         #ef4444;
  --yt-red:      #ef4444;
  --tk-cyan:     #00f2fe;
  --fb-blue:     #1877f2;

  --text:        #f0f4ff;
  --text-2:      #8b99b5;
  --text-3:      #56637a;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 9999px;

  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 28px rgba(0,0,0,0.5);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.65);
  --shadow-glow: 0 0 28px var(--primary-glow);
  --shadow-green: 0 0 28px var(--green-glow);

  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);

  /* Safe areas for notched devices */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;

  /* Rich animated background */
  background-image:
    radial-gradient(ellipse at 10% 5%,  rgba(99,102,241,0.18) 0%, transparent 45%),
    radial-gradient(ellipse at 90% 20%, rgba(168,85,247,0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 90%, rgba(6,182,212,0.1)   0%, transparent 50%);
  background-attachment: fixed;
}

/* ── App Shell ───────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

/* ── Status Bar ───────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 20px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 0.7rem;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ── App Header ──────────────────────────────────────────────────────────── */
.app-header {
  padding: 4px 0 10px;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.app-brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px var(--primary-glow);
  color: #fff;
  flex-shrink: 0;
}

.app-brand-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 40%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-menu-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
}

.app-menu-btn:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

/* ── Main Scroll View ────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(90px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.app-hero {
  text-align: center;
  padding: 20px 0 24px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.3);
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: #a5b4fc;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a5b4fc;
  box-shadow: 0 0 8px rgba(99,102,241,0.8);
  animation: pulse-dot 1.5s infinite ease-in-out;
}

.hero-title {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.04em;
  margin-bottom: 10px;
}

.gradient-text {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.hero-sub {
  font-size: 0.9rem;
  color: var(--text-2);
  letter-spacing: 0.03em;
}

/* ── Platform Tabs ───────────────────────────────────────────────────────── */
.platform-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.platform-tabs::-webkit-scrollbar { display: none; }

.platform-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  font-family: var(--font);
}

.platform-tab:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

.platform-tab.active {
  background: rgba(99,102,241,0.18);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 14px var(--primary-glow);
}

.platform-tab[data-platform="youtube"].active {
  background: rgba(239,68,68,0.18);
  border-color: var(--yt-red);
  box-shadow: 0 0 14px rgba(239,68,68,0.3);
}

.platform-tab[data-platform="tiktok"].active {
  background: rgba(0,242,254,0.12);
  border-color: var(--tk-cyan);
  box-shadow: 0 0 14px rgba(0,242,254,0.25);
}

.platform-tab[data-platform="facebook"].active {
  background: rgba(24,119,242,0.18);
  border-color: var(--fb-blue);
  box-shadow: 0 0 14px rgba(24,119,242,0.3);
}

/* ── Downloader Card ─────────────────────────────────────────────────────── */
.downloader-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

/* Input row */
.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
  flex-shrink: 0;
}

.video-input {
  width: 100%;
  background: rgba(8, 12, 23, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 36px 12px 40px;
  font-size: 0.9rem;
  color: var(--text);
  font-family: var(--font);
  transition: var(--transition);
  -webkit-appearance: none;
}

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

.video-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(8, 12, 23, 0.9);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.clear-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* Fetch button — icon only on mobile */
.btn-fetch {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border: none;
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: var(--transition);
}

.btn-fetch:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 22px rgba(99,102,241,0.55);
}

.btn-fetch:active { transform: scale(0.96); }

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

/* ── Error Banner ────────────────────────────────────────────────────────── */
.error-banner {
  display: none;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-top: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fadeUp 0.25s ease-out;
}

/* ── Result Section ──────────────────────────────────────────────────────── */
.result-section {
  display: none;
  margin-top: 14px;
  animation: fadeUp 0.3s ease-out forwards;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.video-result-card {
  display: flex;
  gap: 12px;
  background: rgba(8,12,24,0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  margin-bottom: 12px;
}

/* Thumbnail */
.result-thumb-wrap {
  position: relative;
  width: 120px;
  height: 80px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.result-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.result-thumb-wrap:hover .result-thumb { transform: scale(1.06); }

.duration-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.82);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
}

.result-thumb-wrap:hover .thumb-overlay { opacity: 1; }

.play-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Info */
.result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}

.result-meta {
  font-size: 0.75rem;
  color: var(--text-2);
}

/* Quality label */
.quality-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Format grid — pill buttons */
.format-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.format-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.format-pill:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
}

.format-pill.active {
  background: rgba(99,102,241,0.22);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Download button — full width, prominent */
.download-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--green), var(--green-hover));
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--r-lg);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px var(--green-glow);
  transition: var(--transition);
  letter-spacing: 0.01em;
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(16,185,129,0.55);
}

.download-btn:active { transform: scale(0.97); }

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

/* ── Features ────────────────────────────────────────────────────────────── */
.features-section {
  padding: 8px 0 16px;
}

.features-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.features-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.feature-card:hover {
  background: var(--bg-elevated);
  border-color: rgba(255,255,255,0.12);
  transform: translateX(4px);
}

.feature-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feature-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.feature-card-desc {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.4;
}

/* ── Bottom Navigation ───────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex;
  justify-content: space-around;
  z-index: 100;
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--r-md);
  transition: var(--transition);
  letter-spacing: 0.03em;
}

.bottom-nav-btn:hover,
.bottom-nav-btn.active {
  color: var(--primary);
}

.bottom-nav-btn.active svg {
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

/* ── Loading Spinner ─────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Fetch button loading */
.animate-spin {
  animation: spin 0.8s linear infinite;
}

/* ── Responsive for larger screens ───────────────────────────────────────── */
@media (min-width: 521px) {
  .app-shell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 100vh;
  }

  .bottom-nav {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }

  .hero-title { font-size: 2.5rem; }
  .app-hero   { padding: 32px 0 30px; }
}

@media (min-width: 768px) {
  .app-main { padding-left: 24px; padding-right: 24px; }

  .video-result-card {
    flex-direction: row;
  }

  .result-thumb-wrap {
    width: 160px;
    height: 110px;
  }
}

/* ── Scrollbar styling ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
