/* Design Tokens & Custom Variables */
:root {
  --bg-primary: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.65);
  --bg-card-hover: rgba(21, 30, 49, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: rgba(96, 165, 250, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --gradient-accent: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);
  --gradient-glow: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 25px rgba(139, 92, 246, 0.25);

  --font-main: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background Ambient Glows */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
}

.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  top: -10%;
  left: -10%;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
}

.bg-glow-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-pink) 0%, transparent 70%);
  top: 40%;
  left: 60%;
  opacity: 0.2;
}

/* Main Container Layout */
.container {
  width: 100%;
  max-width: 700px;
  padding: 24px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header Styling */
.header {
  text-align: center;
  margin-bottom: 8px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-blue);
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

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

.title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Premium Card Style (Glassmorphism) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-smooth);
}

.downloader-card:focus-within {
  border-color: var(--border-color-focus);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Input Form Layout */
.input-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.input-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  height: 52px;
  padding: 0 16px 0 48px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  outline: none;
  transition: var(--transition-smooth);
}

.input-wrapper input:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.4);
}

/* Interactive Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 24px;
  border-radius: 12px;
  border: none;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 100%;
  margin-top: 8px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Loading & Status Indicator */
.status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  animation: fadeIn 0.3s ease;
}

.spinner-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
}

.spinner {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(59, 130, 246, 0.1);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.spinner-inner {
  position: absolute;
  width: 70%;
  height: 70%;
  top: 15%;
  left: 15%;
  border: 3px solid transparent;
  border-bottom-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin-reverse 1.2s infinite linear;
}

#status-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Error Container */
.error-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  margin-top: 20px;
  color: #fca5a5;
  animation: shake 0.4s ease;
}

.error-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.error-container p {
  font-size: 14px;
  font-weight: 500;
}

/* Results Section */
.results-card {
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.results-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
}

.thumbnail-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  aspect-ratio: 16/9;
  border: 1px solid var(--border-color);
  max-height: 120px;
}

.video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: var(--transition-smooth);
}

.overlay-icon {
  width: 28px;
  height: 28px;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.video-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.video-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.source-icon {
  width: 14px;
  height: 14px;
}

/* Download Action Buttons Grid */
.download-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  border-radius: 12px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition-smooth);
}

.btn-download:hover {
  background: var(--gradient-glow);
  border-color: var(--border-color-focus);
  transform: translateX(4px);
}

.download-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quality-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.btn-download-icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.btn-download:hover .btn-download-icon {
  color: var(--accent-blue);
  transform: translateY(2px);
}

/* Footer Details */
.footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Keyframes / Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spin-reverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Responsive Rules */
@media (max-width: 600px) {
  .results-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .thumbnail-wrapper {
    max-height: 160px;
  }
  .input-group {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}
