/* ==========================================================================
   PROJECT 03 &bull; YOUTUBE MEDIA DOWNLOADER & STREAM PARSER ENGINE
   Designer: Sohaib Ahmer (NID Postgraduate Alumnus)
   Design System: Deep Slate Noir, Indigo-Violet Brand Accents & Glassmorphism
   ========================================================================== */

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

:root {
  /* COLOR PALETTE & HARMONY (COLOR WHEEL ANALOGOUS-COMPLEMENTARY SYSTEM) */
  --bg-dark: #0B0F19;           /* Deep Slate Noir Canvas */
  --bg-card: rgba(18, 24, 38, 0.7); /* Frosted Glass Surface */
  --bg-card-hover: rgba(28, 36, 56, 0.8);
  --bg-input: #111726;          /* Deep Input Surface */
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35); /* Indigo Accent Glow */
  --border-glow-focus: rgba(99, 102, 241, 0.6);

  --accent-primary: #6366F1;     /* Indigo Primary */
  --accent-secondary: #8B5CF6;   /* Violet Secondary */
  --accent-warm: #F59E0B;        /* Warm Amber Accent */
  --accent-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #DB2777 100%);

  --text-primary: #F8FAFC;      /* High contrast slate white */
  --text-secondary: #CBD5E1;    /* Mid slate */
  --text-tertiary: #64748B;     /* Muted slate */
  --text-accent: #818CF8;       /* Light indigo text */

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

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 32px rgba(99, 102, 241, 0.2);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.8) 0%, var(--bg-dark) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* FLOATING HEADER NAV WITH EXIT BUTTON */
.floating-header-nav {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 1040px;
  height: 60px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.brand-stamp {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-stamp-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.brand-stamp-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-exit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-exit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* WIDE MAIN PAGE CONTAINER (EXPANDED TO 1040px) */
.page-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 130px 24px 80px;
}

/* HERO INTRO SECTION */
.hero-section {
  text-align: center;
  margin-bottom: 40px;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-pill);
  color: var(--text-accent);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.main-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #FFFFFF;
  line-height: 1.15;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #FFFFFF 0%, #CBD5E1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-sub {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* YOUTUBE INPUT CARD CONTAINER */
.youtube-input-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  margin-bottom: 32px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.youtube-input-card:focus-within {
  border-color: var(--border-glow-focus);
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.3), var(--shadow-lg);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 6px 6px 6px 16px;
}

.yt-icon-prefix {
  display: flex;
  align-items: center;
  color: #FF0000;
  opacity: 0.9;
}

.yt-url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
}

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

/* CLEAR BUTTON */
.btn-clear {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-pill);
  color: #FCA5A5;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-clear.active {
  display: inline-flex;
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #FFFFFF;
}

/* PASTE BUTTON */
.btn-paste {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-paste:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

/* "GO" ACTION BUTTON */
.btn-parse {
  padding: 10px 24px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-pill);
  color: #FFFFFF;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  white-space: nowrap;
}

.btn-parse:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

/* DYNAMIC PARSING SKELETON LOADER ANIMATION */
.parsing-loader-card {
  display: none;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 28px;
  animation: fadeIn 0.3s ease-out forwards;
}

.parsing-loader-card.active {
  display: block;
}

.loader-spinner-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.glowing-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-status-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-accent);
}

.skeleton-shimmer-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.skeleton-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
}

.skeleton-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.skeleton-line {
  height: 18px;
  border-radius: 6px;
}

.skeleton-line.title-line {
  width: 85%;
  height: 24px;
}

.skeleton-line.channel-line {
  width: 55%;
}

.skeleton-chips {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.skeleton-chip {
  width: 90px;
  height: 24px;
  border-radius: var(--radius-pill);
}

.skeleton-rows {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.skeleton-row {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-md);
}

/* SHIMMER WAVE ANIMATION */
.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(99, 102, 241, 0.15) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: shimmerWave 1.6s infinite ease-in-out;
}

@keyframes shimmerWave {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

/* PARSED MEDIA RESULTS CARD (EXPANDED NO-SCROLL) */
.result-card {
  display: none;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.result-card.active {
  display: block;
}

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

/* VIDEO HEADER METADATA */
.video-header-meta {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  margin-bottom: 28px;
}

.video-thumb-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #000;
}

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

.thumb-duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.video-info-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.video-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin-bottom: 10px;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-channel {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-accent);
  margin-bottom: 16px;
}

.meta-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-chip {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
}

/* FORMAT TABS BAR */
.format-tabs-bar {
  display: flex;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.format-tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-tertiary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-tab-btn.active {
  background: var(--accent-primary);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* 2-COLUMN FORMATS GRID (NO INNER SCROLLBAR) */
.formats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
  /* Removed inner scrollbar and fixed height so card expands naturally! */
  max-height: none;
  overflow-y: visible;
}

.format-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-row-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
}

.format-row-item.selected {
  background: rgba(99, 102, 241, 0.14);
  border-color: var(--accent-primary);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.15);
}

.format-quality-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

.format-quality-label input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

.quality-badge {
  padding: 2px 7px;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  font-size: 10px;
  color: #A5B4FC;
  text-transform: uppercase;
}

.format-size-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* DOWNLOAD ACTION BUTTON */
.btn-download-action {
  width: 100%;
  padding: 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.btn-download-action:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.55);
}

/* DOWNLOAD PROGRESS CONTAINER */
.download-progress-container {
  display: none;
  margin-top: 20px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.download-progress-container.active {
  display: block;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-pill);
  transition: width 0.15s ease-out;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* APP FOOTER */
.app-footer {
  text-align: center;
  margin-top: 60px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
  .floating-header-nav {
    position: fixed !important;
    top: 10px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    transform: none !important;
    padding: 8px 12px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }
  .page-container {
    width: 100% !important;
    max-width: 100vw !important;
    padding: 80px 16px 40px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  .youtube-input-card { width: 100%; padding: 18px 14px; margin: 0 auto 24px; }
  .input-row { flex-direction: column; align-items: stretch; padding: 10px; gap: 10px; }
  .yt-url-input { width: 100%; font-size: 14px; }
  .btn-paste, .btn-fetch { width: 100%; justify-content: center; }
  .result-card { width: 100%; padding: 18px 14px; }
  .video-header-meta { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .video-thumbnail-box { margin: 0 auto; width: 100%; max-width: 280px; height: auto; aspect-ratio: 16/9; }
  .formats-grid, .skeleton-rows { grid-template-columns: 1fr; gap: 10px; }
  .skeleton-shimmer-layout { grid-template-columns: 1fr; }
  .main-title { font-size: 26px; }
}

@media (max-width: 480px) {
  .main-title { font-size: 22px; }
  .header-exit-btn span:first-child { display: none; }
  .format-download-btn { font-size: 11.5px; padding: 8px 10px; }
}
