/* ========================================
   VidGrab — Premium Video Downloader UI
   ======================================== */

/* --- CSS Variables / Design Tokens --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(124, 58, 237, 0.3);

  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-purple: #7C3AED;
  --accent-pink: #EC4899;
  --accent-blue: #3B82F6;
  --accent-green: #10B981;
  --accent-red: #EF4444;
  --accent-orange: #F59E0B;

  --gradient-primary: linear-gradient(135deg, #7C3AED 0%, #EC4899 100%);
  --gradient-secondary: linear-gradient(135deg, #3B82F6 0%, #7C3AED 100%);
  --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
                 radial-gradient(ellipse at 80% 20%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
                 radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

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

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

/* --- Animated Background --- */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-bg);
  z-index: 0;
  pointer-events: none;
}

.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(124, 58, 237, 0.3);
  border-radius: 50%;
  animation: float-particle linear infinite;
}

@keyframes float-particle {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* --- Container --- */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* --- Glass Card --- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 0;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-smooth);
}

.logo:hover .logo-icon {
  transform: scale(1.1) rotate(-5deg);
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-orange);
  animation: pulse-dot 2s infinite;
}

.status-dot.online {
  background: var(--accent-green);
}

.status-dot.offline {
  background: var(--accent-red);
  animation: none;
}

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

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 60px 0 40px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 400;
}

/* --- URL Input Section --- */
.input-section {
  margin-bottom: 24px;
}

.input-card {
  padding: 8px;
}

.url-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 12px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.input-wrapper:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.input-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  margin-right: 10px;
  flex-shrink: 0;
}

.url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  padding: 12px 0;
  width: 100%;
}

.url-input::placeholder {
  color: var(--text-muted);
}

.paste-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.paste-btn:hover {
  color: var(--accent-purple);
  background: rgba(124, 58, 237, 0.1);
}

.fetch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.fetch-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.fetch-btn:hover::before {
  opacity: 1;
}

.fetch-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.fetch-btn:active {
  transform: translateY(0);
}

.fetch-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* --- Spinner --- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Error Message --- */
.error-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: #FCA5A5;
  font-size: 0.9rem;
  margin-bottom: 24px;
  animation: slide-in 0.3s ease-out;
}

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

/* --- Video Info Card --- */
.video-info {
  margin-bottom: 24px;
  animation: fade-up 0.5s ease-out;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.video-card {
  padding: 24px;
}

.video-preview {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.thumbnail-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
  aspect-ratio: 16/9;
}

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.video-details {
  flex: 1;
  min-width: 0;
}

.video-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.source-badge {
  padding: 3px 10px;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: var(--radius-full);
  color: #B794F4;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Quality Selection --- */
.quality-section {
  margin-bottom: 20px;
}

.quality-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quality-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quality-btn {
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.quality-btn:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
  color: var(--text-primary);
}

.quality-btn.active {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent-purple);
  color: white;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.2);
}

.quality-btn .quality-label {
  font-size: 0.95rem;
  font-weight: 700;
}

.quality-btn .quality-size {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.quality-btn.active .quality-size {
  color: rgba(255, 255, 255, 0.6);
}

.quality-btn.best-quality {
  border-color: rgba(236, 72, 153, 0.3);
}

.quality-btn.best-quality.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(236, 72, 153, 0.2));
  border-color: var(--accent-pink);
}

.quality-btn.audio-quality {
  border-color: rgba(16, 185, 129, 0.3);
}

.quality-btn.audio-quality.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-green);
}

/* --- Download Section --- */
.download-section {
  text-align: center;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 40px;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.download-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s ease;
}

.download-btn:hover:not(:disabled)::before {
  left: 100%;
}

.download-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.4);
}

.download-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.download-hint {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Download Progress --- */
.download-progress {
  margin-bottom: 24px;
  animation: fade-up 0.4s ease-out;
}

.progress-card {
  padding: 40px;
  text-align: center;
}

.progress-icon {
  margin-bottom: 20px;
}

.download-animation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.1);
  border: 2px solid rgba(124, 58, 237, 0.2);
  color: var(--accent-purple);
  animation: bounce-gentle 2s ease-in-out infinite;
}

@keyframes bounce-gentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.progress-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.progress-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.progress-bar-wrapper {
  max-width: 400px;
  margin: 0 auto;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  width: 0%;
  animation: progress-indeterminate 2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { width: 0%; margin-left: 0%; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* --- Supported Sites --- */
.supported-sites {
  padding: 50px 0 30px;
  text-align: center;
}

.sites-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.sites-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.site-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition-normal);
}

.site-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.site-icon {
  font-size: 1rem;
}

.more-chip {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.2);
  color: var(--accent-purple);
}

/* --- Footer --- */
.footer {
  padding: 30px 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .hero {
    padding: 40px 0 30px;
  }

  .hero-title {
    font-size: 1.8rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .url-form {
    flex-direction: column;
  }

  .input-wrapper {
    width: 100%;
  }

  .fetch-btn {
    width: 100%;
    justify-content: center;
    padding: 14px;
  }

  .video-preview {
    flex-direction: column;
  }

  .thumbnail-wrapper {
    width: 100%;
  }

  .video-card {
    padding: 16px;
  }

  .quality-options {
    justify-content: center;
  }

  .download-btn {
    width: 100%;
    justify-content: center;
    padding: 16px;
  }
}
/* Donate Button */
.donate-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(236, 72, 153, 0.1);
  color: #EC4899;
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 1rem;
}

.donate-btn:hover {
  background: rgba(236, 72, 153, 0.2);
  transform: translateY(-1px);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1.5rem;
  padding: 2.5rem;
  width: 90%;
  max-width: 360px;
  text-align: center;
  position: relative;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-title {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.qr-container {
  background: white;
  padding: 1rem;
  border-radius: 1rem;
  display: inline-block;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.qr-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  display: block;
}

.modal-footer-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Binance Section */
.binance-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--card-border);
}

.binance-title {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.binance-id-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-main);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-weight: 600;
  font-family: monospace;
  font-size: 1.1rem;
}

.copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 0.4rem;
  transition: all 0.2s;
}

.copy-btn:hover {
  color: var(--primary);
  background: rgba(236, 72, 153, 0.1);
}
