/* ============================================
   Altaie Downloader - Main Stylesheet
   ============================================ */

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

:root {
  --primary: #7c3aed;
  --primary-light: #9f67ff;
  --primary-dark: #5b21b6;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #080812;
  --bg-2: #0f0f1f;
  --bg-3: #141428;
  --card: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.08);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 25px 50px rgba(0,0,0,0.5);
  --glow: 0 0 40px rgba(124,58,237,0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Tajawal', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---- Animated Background ---- */
.bg-orbs {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.18; animation: floatOrb 12s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, #7c3aed, transparent); top: -150px; right: -100px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: radial-gradient(circle, #06b6d4, transparent); bottom: 20%; left: -100px; animation-delay: -4s; }
.orb-3 { width: 300px; height: 300px; background: radial-gradient(circle, #f59e0b, transparent); top: 50%; right: 10%; animation-delay: -8s; }
.orb-4 { width: 350px; height: 350px; background: radial-gradient(circle, #ec4899, transparent); bottom: 0; left: 40%; animation-delay: -2s; }

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ---- Header ---- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8,8,18,0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  padding: 16px 0;
}
.header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; box-shadow: var(--glow);
}
.logo-text { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.gradient-text { background: linear-gradient(135deg, var(--primary-light), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.nav-links { display: flex; gap: 8px; }
.nav-link {
  color: var(--text-muted); text-decoration: none; padding: 8px 16px;
  border-radius: 8px; font-size: 0.9rem; transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--card); }

/* ---- Hero ---- */
.hero {
  position: relative; z-index: 1;
  padding: 80px 0 60px;
  text-align: center;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(124,58,237,0.15); border: 1px solid rgba(124,58,237,0.3);
  border-radius: 100px; padding: 6px 16px; font-size: 0.85rem; margin-bottom: 24px;
  color: var(--primary-light);
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); } 50% { box-shadow: 0 0 0 8px rgba(16,185,129,0); } }

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 900; line-height: 1.2; margin-bottom: 20px;
  letter-spacing: -0.02em;
}
.hero-subtitle {
  font-size: 1.1rem; color: var(--text-muted); max-width: 560px;
  margin: 0 auto 40px;
}

/* ---- Search Card ---- */
.search-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 8px;
  max-width: 780px; margin: 0 auto 24px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow), var(--glow);
  display: flex; gap: 8px; flex-wrap: wrap;
  transition: border-color 0.3s;
}
.search-card:focus-within { border-color: var(--primary); }

.search-wrapper {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  background: rgba(255,255,255,0.05);
  border-radius: 12px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.06);
}
.search-icon { color: var(--text-dim); flex-shrink: 0; }
.search-icon svg { width: 20px; height: 20px; display: block; }

.search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1rem; padding: 14px 10px;
  font-family: 'Inter', sans-serif; direction: ltr;
}
.search-input::placeholder { color: var(--text-dim); }

.paste-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 8px; border-radius: 8px; transition: all 0.2s; flex-shrink: 0;
}
.paste-btn:hover { color: var(--primary-light); background: rgba(124,58,237,0.15); }
.paste-btn svg { width: 18px; height: 18px; display: block; }

.fetch-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none; color: white; font-family: 'Tajawal', sans-serif;
  font-size: 1rem; font-weight: 700; padding: 14px 28px;
  border-radius: 12px; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.3s; position: relative; overflow: hidden;
  box-shadow: 0 8px 20px rgba(124,58,237,0.4);
}
.fetch-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(124,58,237,0.5); }
.fetch-btn:active { transform: translateY(0); }
.fetch-btn.loading .btn-text, .fetch-btn.loading .btn-icon { opacity: 0; }
.fetch-btn.loading .btn-loader { display: block; }
.btn-loader {
  display: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
}
@keyframes spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* ---- Platforms ---- */
.platforms {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.platform-label { color: var(--text-dim); font-size: 0.85rem; }
.platform-badge {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px; padding: 4px 12px; font-size: 0.8rem; color: var(--text-muted);
}
.platform-badge.youtube { background: rgba(255,0,0,0.15); border-color: rgba(255,0,0,0.3); color: #ff6b6b; }
.platform-badge.shorts { background: rgba(255,100,0,0.15); border-color: rgba(255,100,0,0.3); color: #ff9f43; }

/* ---- Loading ---- */
.loading-section, .error-section { position: relative; z-index: 1; padding: 40px 0; }
.loading-card, .error-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 60px 40px;
  text-align: center; max-width: 500px; margin: 0 auto;
  backdrop-filter: blur(20px);
}
.loading-spinner { position: relative; width: 80px; height: 80px; margin: 0 auto 30px; }
.spinner-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
.spinner-ring-2 { border-top-color: var(--secondary); animation-delay: -0.3s; border-top-color: transparent; border-right-color: var(--secondary); }
.spinner-core {
  position: absolute; inset: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.loading-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.loading-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.loading-progress { background: rgba(255,255,255,0.1); border-radius: 100px; height: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 100px; animation: progressAnim 2s ease-in-out infinite; }
@keyframes progressAnim { 0% { width: 5%; } 50% { width: 80%; } 100% { width: 95%; } }

.error-card .error-icon { font-size: 3rem; margin-bottom: 16px; }
.error-card p { color: var(--text-muted); margin-bottom: 24px; font-size: 1.05rem; }
.retry-btn {
  background: rgba(124,58,237,0.2); border: 1px solid rgba(124,58,237,0.4);
  color: var(--primary-light); padding: 10px 24px; border-radius: 10px;
  cursor: pointer; font-family: 'Tajawal', sans-serif; font-size: 1rem; transition: all 0.2s;
}
.retry-btn:hover { background: rgba(124,58,237,0.35); }

/* ---- Result Card ---- */
.result-section { position: relative; z-index: 1; padding: 40px 0; }
.result-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); overflow: hidden;
  backdrop-filter: blur(20px); box-shadow: var(--shadow);
  animation: fadeSlideUp 0.5s ease;
  max-width: 860px; margin: 0 auto;
}
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.result-header {
  display: flex; gap: 20px; padding: 24px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(255,255,255,0.02);
  flex-wrap: wrap;
}
.result-thumb {
  width: 160px; height: 90px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0; background: var(--bg-3);
}
.result-meta { flex: 1; min-width: 0; }
.result-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; line-height: 1.4; }
.result-info { display: flex; gap: 16px; flex-wrap: wrap; }
.info-chip {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 0.85rem;
}
.info-chip .icon { font-size: 14px; }

.result-body { padding: 24px; }
.format-tabs {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.tab-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--card-border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-family: 'Tajawal', sans-serif; font-size: 0.95rem; font-weight: 600;
  transition: all 0.2s;
}
.tab-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: transparent; color: white; }
.tab-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary-light); }

.formats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.format-item {
  border: 1px solid var(--card-border); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; transition: all 0.2s; background: rgba(255,255,255,0.03);
  display: flex; flex-direction: column; gap: 4px;
}
.format-item:hover { border-color: var(--primary); background: rgba(124,58,237,0.1); transform: translateY(-2px); }
.format-item.selected { border-color: var(--primary); background: rgba(124,58,237,0.15); box-shadow: 0 4px 16px rgba(124,58,237,0.25); }
.format-quality { font-weight: 700; font-size: 1rem; color: var(--text); }
.format-type { font-size: 0.75rem; color: var(--text-muted); }
.format-size { font-size: 0.75rem; color: var(--text-dim); }

.download-action {
  margin-top: 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.selected-info { color: var(--text-muted); font-size: 0.9rem; }
.selected-info strong { color: var(--primary-light); }

.download-btn {
  background: linear-gradient(135deg, var(--success), #059669);
  border: none; color: white; font-family: 'Tajawal', sans-serif;
  font-size: 1.05rem; font-weight: 700; padding: 14px 32px;
  border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: all 0.3s; box-shadow: 0 8px 20px rgba(16,185,129,0.35);
}
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(16,185,129,0.45); }
.download-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---- Features ---- */
.features-section { position: relative; z-index: 1; padding: 80px 0; }
.section-title { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; text-align: center; margin-bottom: 48px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.feature-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 28px 20px; text-align: center;
  transition: all 0.3s; cursor: default;
}
.feature-card:hover { transform: translateY(-6px); border-color: rgba(124,58,237,0.4); box-shadow: 0 16px 40px rgba(0,0,0,0.3); }
.feature-icon { font-size: 2.2rem; margin-bottom: 14px; }
.feature-card h3 { font-weight: 700; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: 0.88rem; }

/* ---- How To ---- */
.howto-section { position: relative; z-index: 1; padding: 60px 0; }
.steps-grid { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; max-width: 800px; margin: 0 auto; }
.step-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 32px 24px; text-align: center; flex: 1; min-width: 180px;
  transition: all 0.3s;
}
.step-card:hover { border-color: rgba(124,58,237,0.4); transform: translateY(-4px); }
.step-num { font-size: 2.5rem; font-weight: 900; background: linear-gradient(135deg, var(--primary-light), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 12px; }
.step-card h3 { font-weight: 700; margin-bottom: 8px; }
.step-card p { color: var(--text-muted); font-size: 0.88rem; }
.step-arrow { font-size: 1.5rem; color: var(--text-dim); flex-shrink: 0; }

/* ---- Stats ---- */
.stats-section { position: relative; z-index: 1; padding: 60px 0; }
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 40px;
  backdrop-filter: blur(20px);
}
.stat-item { text-align: center; }
.stat-num { font-size: 2.2rem; font-weight: 900; background: linear-gradient(135deg, var(--primary-light), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }

/* ---- Footer ---- */
.footer {
  position: relative; z-index: 1;
  border-top: 1px solid var(--card-border);
  padding: 48px 0 24px; margin-top: 40px;
}
.footer-content { display: flex; justify-content: space-between; align-items: flex-start; gap: 32px; flex-wrap: wrap; margin-bottom: 32px; }
.footer-brand p { color: var(--text-muted); font-size: 0.88rem; margin-top: 12px; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-link { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.footer-link:hover { color: var(--primary-light); }
.footer-bottom { border-top: 1px solid var(--card-border); padding-top: 24px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer-bottom p { color: var(--text-dim); font-size: 0.82rem; }
.footer-disclaimer { color: var(--text-dim); font-size: 0.8rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 36px; max-width: 480px; width: 100%;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: rgba(30,30,50,0.95); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 12px 24px; color: var(--text);
  font-family: 'Tajawal', sans-serif; font-size: 0.95rem;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 300; backdrop-filter: blur(20px); white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hero { padding: 50px 0 40px; }
  .search-card { flex-direction: column; }
  .fetch-btn { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .step-arrow { display: none; }
  .result-header { flex-direction: column; }
  .result-thumb { width: 100%; height: 200px; }
  .footer-content { flex-direction: column; }
}
