/* ==========================================================================
   D4U Video Downloader - Modern Technology UI Stylesheet
   Supports Light & Dark Modes, Glassmorphism, Micro-Animations & Responsiveness
   ========================================================================== */

:root {
  /* Color Palette - Light Theme */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #6366f1;

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

  --accent-cyan: #06b6d4;
  --accent-fb: #1877f2;
  --accent-ig-start: #f09433;
  --accent-ig-end: #bc1888;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --card-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --card-shadow-hover: 0 20px 35px -5px rgba(99, 102, 241, 0.12), 0 10px 12px -6px rgba(15, 23, 42, 0.08);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Color Palette - Dark Theme */
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-subtle: #1a2234;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #818cf8;

  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --card-shadow-hover: 0 20px 40px -5px rgba(99, 102, 241, 0.25), 0 0 1px 1px rgba(99, 102, 241, 0.4);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Brand Logo Treatment */
.brand-logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-badge {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

/* Navbar */
.navbar-custom {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--transition);
}

.nav-link-custom {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-muted) !important;
  padding: 8px 14px !important;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-link-custom:hover,
.nav-link-custom.active {
  color: var(--primary) !important;
  background-color: var(--bg-card-subtle);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--border-color);
  transform: scale(1.05);
}

/* Hero Section */
.hero-section {
  padding: 60px 0 40px;
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.hero-heading {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto 36px;
}

/* Downloader Main Card */
.downloader-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--card-shadow);
  position: relative;
  transition: var(--transition);
}

.input-glow-group {
  display: flex;
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  gap: 8px;
  transition: var(--transition);
  position: relative;
}

.input-glow-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.05rem;
  padding: 12px 16px;
  outline: none;
  width: 100%;
}

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

.btn-paste-shortcut {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-paste-shortcut:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.btn-analyze {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: var(--transition);
}

.btn-analyze:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-analyze:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Quick Platform Pills */
.platform-pills {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pill-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.pill-fb i {
  color: var(--accent-fb);
}

.pill-ig i {
  color: #e1306c;
}

/* Compliance Notice */
.compliance-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Loading Animation State */
.loading-box {
  display: none;
  text-align: center;
  padding: 36px 20px;
}

.spinner-pulse {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-text {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-main);
}

.loading-subtext {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Video Result Card */
.result-box {
  display: none;
  margin-top: 28px;
  border-top: 1px solid var(--border-color);
  padding-top: 28px;
  animation: fadeIn 0.4s ease-out;
}

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

.result-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  gap: 24px;
  align-items: center;
}

.media-thumbnail-wrap {
  width: 180px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: #000;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.thumb-play-overlay {
  position: absolute;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
}

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

.media-platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.media-platform-badge.facebook {
  background: rgba(24, 119, 242, 0.12);
  color: var(--accent-fb);
}

.media-platform-badge.instagram {
  background: rgba(225, 48, 108, 0.12);
  color: #e1306c;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta-row {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.result-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-download-trigger {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
}

.btn-download-trigger:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

/* Custom Alert Message */
.d4u-alert {
  display: none;
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  align-items: flex-start;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

.d4u-alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.d4u-alert.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--success);
}

.d4u-alert.info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary);
}

/* Feature Cards & Sections */
.section-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  color: var(--text-main);
}

.section-lead {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 36px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  height: 100%;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--primary);
}

.feature-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 18px;
}

.feature-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.feature-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0;
}

/* Step Cards */
.step-number {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 10px;
  display: inline-block;
}

/* FAQ Accordion Styling */
.accordion-item {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 14px;
  overflow: hidden;
}

.accordion-button {
  background-color: var(--bg-card) !important;
  color: var(--text-main) !important;
  font-weight: 600;
  font-size: 1.02rem;
  box-shadow: none !important;
  padding: 18px 22px;
}

.accordion-button:not(.collapsed) {
  color: var(--primary) !important;
  background-color: var(--bg-card-subtle) !important;
}

.accordion-body {
  background-color: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 20px 22px;
}

/* Accessibility: Visible Focus States */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -120px;
  left: 16px;
  background: var(--primary);
  color: #ffffff !important;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  z-index: 99999;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
}

/* AdSense Placement Container (Responsive, Distinct & Compliant) */
.ad-wrapper {
  margin: 36px auto;
  max-width: 728px;
  text-align: center;
}

.ad-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  user-select: none;
}

.ad-container-slot {
  margin: 0 auto;
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  background: var(--bg-card-subtle);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  padding: 12px;
}

/* How It Works Specific Component Styles */
.tool-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  height: 100%;
}

.tool-guide-card:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: var(--border-focus);
}

.guide-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 12px;
  flex-shrink: 0;
}

.limitations-box {
  background: rgba(239, 68, 68, 0.06);
  border-left: 3px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin-top: 18px;
}

.highlight-box {
  background: rgba(99, 102, 241, 0.06);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin-top: 18px;
}

/* Footer Styling */
.footer-custom {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 50px 0 25px;
  margin-top: auto;
}

.footer-heading {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-main);
  margin-bottom: 18px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 10px;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.footer-links a:hover {
  color: var(--primary);
  padding-left: 3px;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  margin-top: 36px;
  padding-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Touch-friendly Minimum Targets */
.theme-toggle-btn,
.navbar-toggler,
.btn-paste-shortcut {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Mobile Responsive Optimizations */
@media (max-width: 768px) {
  /* Prevent iOS automatic zoom on text inputs */
  .url-input,
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px !important;
  }

  .hero-heading {
    font-size: 2rem;
  }
  
  .hero-lead {
    font-size: 1rem;
  }

  .downloader-card {
    padding: 20px 16px;
  }

  .input-glow-group {
    flex-direction: column;
    padding: 10px;
  }

  .btn-analyze {
    width: 100%;
    padding: 14px 20px;
    min-height: 48px;
  }

  .result-card {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .media-thumbnail-wrap {
    width: 100%;
    height: 180px;
  }

  .result-meta-row {
    justify-content: center;
  }

  .btn-download-trigger {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .tool-guide-card {
    padding: 22px 18px;
  }
}

@media (max-width: 414px) {
  .hero-heading {
    font-size: 1.7rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Google AdSense Policy Compliant Advertisement Containers
   ========================================================================== */
.ad-placement-wrap {
  width: 100%;
  clear: both;
}

.ad-wrapper {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  transition: var(--transition);
  max-width: 100%;
}

.ad-wrapper:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.ad-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  opacity: 0.75;
  margin-bottom: 6px;
}

.ad-inner-box {
  min-height: 50px;
  width: 100%;
  overflow: hidden;
}

.ad-header-container {
  max-width: 970px;
}

.ad-footer-container {
  max-width: 970px;
}

/* Platform-Specific Video & Reel Styling Accents */
.media-platform-badge.instagram {
  background: linear-gradient(135deg, rgba(240, 148, 51, 0.15), rgba(188, 24, 136, 0.15));
  color: #bc1888;
  border-color: rgba(225, 48, 108, 0.3);
}

[data-theme="dark"] .media-platform-badge.instagram {
  color: #f472b6;
}

.pill-item.pill-fb:hover {
  background: rgba(24, 119, 242, 0.15);
  border-color: #1877f2;
}

.pill-item.pill-ig:hover {
  background: rgba(225, 48, 108, 0.15);
  border-color: #e1306c;
}

