/* ===========================================
   YTune - YouTube to MP3 Converter
   Neumorphism Design System
   =========================================== */

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

/* ============ CSS VARIABLES ============ */
:root {
  /* Neumorphism Base - Light Mode */
  --bg: #e0e5ec;
  --bg-secondary: #d1d9e6;
  --shadow-dark: #a3b1c6;
  --shadow-light: #ffffff;

  /* Text */
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #95a5a6;

  /* Accent */
  --accent: #6c5ce7;
  --accent-light: #a855f7;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7);
  --accent-glow: rgba(108, 92, 231, 0.3);

  /* Status */
  --success: #00b894;
  --success-gradient: linear-gradient(135deg, #00b894, #00cec9);
  --error: #e17055;
  --warning: #fdcb6e;
  --info: #74b9ff;

  /* Sizing */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* Neumorphism Shadows */
  --neu-d: 6px;
  --neu-b: 12px;
  --neu-d-lg: 10px;
  --neu-b-lg: 20px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-normal: 0.3s ease;
  --t-slow: 0.5s ease;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg: #2d2d3f;
  --bg-secondary: #252535;
  --shadow-dark: #1a1a2e;
  --shadow-light: rgba(255, 255, 255, 0.05);
  --text-primary: #e0e5ec;
  --text-secondary: #a0a0b8;
  --text-muted: #6c6c80;
  --accent-glow: rgba(108, 92, 231, 0.5);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: background-color var(--t-slow), color var(--t-slow);
  overflow-x: hidden;
  position: relative;
}

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 20%, var(--accent-glow) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ============ MAIN CONTAINER ============ */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  padding: 40px;
  border-radius: var(--radius-xl);
  background: var(--bg);
  animation: fadeInUp 0.6s ease-out;
}

/* ============ HEADER ============ */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  background: var(--accent-gradient);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    4px 4px 8px var(--shadow-dark),
    -4px -4px 8px var(--shadow-light),
    0 0 24px var(--accent-glow);
  animation: pulseGlow 3s ease-in-out infinite;
  position: relative;
}

.app-logo::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 22px;
  background: var(--accent-gradient);
  opacity: 0.2;
  filter: blur(8px);
  z-index: -1;
}

.app-logo svg {
  width: 34px;
  height: 34px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.app-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* ============ INPUT GROUP ============ */
.input-group {
  margin-bottom: 8px;
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.url-input {
  flex: 1;
  padding: 15px 20px;
  border: none;
  outline: none;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  border-radius: var(--radius-md);
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
  transition: all var(--t-normal);
}

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

.url-input:focus {
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light),
    0 0 0 2.5px var(--accent);
}

/* ============ BUTTONS ============ */
.btn-convert {
  padding: 15px 26px;
  border: none;
  outline: none;
  cursor: pointer;
  background: var(--accent-gradient);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow:
    4px 4px 8px var(--shadow-dark),
    -4px -4px 8px var(--shadow-light);
  transition: all var(--t-normal);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.btn-convert::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--t-normal);
}

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

.btn-convert:hover {
  transform: translateY(-2px);
  box-shadow:
    6px 6px 14px var(--shadow-dark),
    -6px -6px 14px var(--shadow-light),
    0 5px 20px var(--accent-glow);
}

.btn-convert:active {
  transform: translateY(0);
  box-shadow:
    inset 3px 3px 6px rgba(0,0,0,0.2),
    inset -3px -3px 6px rgba(255,255,255,0.1);
}

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

.btn-convert .spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
  flex-shrink: 0;
}

.btn-convert.loading .spinner {
  display: block;
}

/* Download Button */
.btn-download {
  width: 100%;
  padding: 16px 24px;
  border: none;
  outline: none;
  cursor: pointer;
  background: var(--success-gradient);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  transition: all var(--t-normal);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  position: relative;
  overflow: hidden;
}

.btn-download.visible {
  display: flex;
  animation: slideInUp 0.4s ease-out;
}

.btn-download::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--t-normal);
}

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

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow:
    7px 7px 14px var(--shadow-dark),
    -7px -7px 14px var(--shadow-light),
    0 5px 20px rgba(0, 184, 148, 0.35);
}

.btn-download:active {
  transform: translateY(0);
  box-shadow:
    inset 3px 3px 6px rgba(0,0,0,0.2),
    inset -3px -3px 6px rgba(255,255,255,0.1);
}

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

.btn-download svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.btn-download .dl-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;
  display: none;
}

.btn-download.loading .dl-spinner {
  display: block;
}

.btn-download.loading .dl-icon {
  display: none;
}

/* ============ VIDEO PREVIEW ============ */
.video-preview {
  display: none;
  margin-top: 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg);
  box-shadow:
    var(--neu-d) var(--neu-d) var(--neu-b) var(--shadow-dark),
    calc(var(--neu-d) * -1) calc(var(--neu-d) * -1) var(--neu-b) var(--shadow-light);
}

.video-preview.active {
  display: block;
  animation: slideInUp 0.5s ease-out;
}

.preview-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  overflow: hidden;
  background: var(--bg-secondary);
}

.preview-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.video-preview:hover .preview-thumbnail img {
  transform: scale(1.03);
}

.preview-duration {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  letter-spacing: 0.3px;
}

.preview-info {
  padding: 18px;
}

.preview-title {
  margin: 0 0 10px 0;
  font-size: 1.1rem;
  color: var(--text-color);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Format Selection UI */
.format-selection {
    width: 100%;
    margin-top: 25px;
    animation: slideUp 0.4s ease forwards;
}

.format-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
    text-align: center;
}

.format-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-format {
    background: var(--bg-color);
    border: none;
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 6px 6px 12px var(--shadow-dark),
                -6px -6px 12px var(--shadow-light);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-format:hover {
    transform: translateY(-2px);
    box-shadow: 8px 8px 15px var(--shadow-dark),
                -8px -8px 15px var(--shadow-light);
}

.btn-format:active {
    transform: translateY(0);
    box-shadow: inset 4px 4px 8px var(--shadow-dark),
                inset -4px -4px 8px var(--shadow-light);
}

.format-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.format-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary-color);
}

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

.format-size {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-color);
    background: var(--bg-color);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: inset 3px 3px 6px var(--shadow-dark),
                inset -3px -3px 6px var(--shadow-light);
}

.preview-channel {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.preview-channel svg {
  width: 15px;
  height: 15px;
  fill: var(--text-secondary);
  flex-shrink: 0;
}

/* ============ QUALITY SELECTOR ============ */
.quality-section {
  display: none;
  margin-top: 22px;
}

.quality-section.active {
  display: block;
  animation: fadeIn 0.4s ease-out;
}

.quality-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

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

.quality-option {
  padding: 9px 18px;
  border: none;
  outline: none;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  box-shadow:
    3px 3px 6px var(--shadow-dark),
    -3px -3px 6px var(--shadow-light);
  transition: all var(--t-fast);
}

.quality-option:hover {
  transform: translateY(-1px);
}

.quality-option.selected {
  background: var(--accent-gradient);
  color: white;
  box-shadow:
    inset 2px 2px 4px rgba(0,0,0,0.15),
    inset -2px -2px 4px rgba(255,255,255,0.1),
    0 0 12px var(--accent-glow);
}

.quality-option .q-size {
  display: block;
  font-size: 0.65rem;
  opacity: 0.7;
  margin-top: 2px;
  font-weight: 400;
}

/* ============ SOUND WAVE ANIMATION ============ */
.sound-wave {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 36px;
  margin: 20px 0 8px;
}

.sound-wave.active {
  display: flex;
}

.sound-wave .bar {
  width: 4px;
  min-height: 4px;
  background: var(--accent-gradient);
  border-radius: 2px;
  animation: soundwave 0.9s ease-in-out infinite;
}

.sound-wave .bar:nth-child(1) { animation-delay: 0.0s; }
.sound-wave .bar:nth-child(2) { animation-delay: 0.1s; }
.sound-wave .bar:nth-child(3) { animation-delay: 0.2s; }
.sound-wave .bar:nth-child(4) { animation-delay: 0.3s; }
.sound-wave .bar:nth-child(5) { animation-delay: 0.4s; }
.sound-wave .bar:nth-child(6) { animation-delay: 0.3s; }
.sound-wave .bar:nth-child(7) { animation-delay: 0.2s; }
.sound-wave .bar:nth-child(8) { animation-delay: 0.1s; }
.sound-wave .bar:nth-child(9) { animation-delay: 0.0s; }

/* ============ PROGRESS BAR ============ */
.progress-section {
  display: none;
  margin-top: 16px;
}

.progress-section.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

.progress-track {
  height: 8px;
  border-radius: 4px;
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 4px;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.35) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

/* ============ STATUS MESSAGES ============ */
.status-message {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.4;
}

.status-message.active {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease-out;
}

.status-message.error {
  background: rgba(225, 112, 85, 0.1);
  color: var(--error);
  border-left: 3px solid var(--error);
}

.status-message.success {
  background: rgba(0, 184, 148, 0.1);
  color: var(--success);
  border-left: 3px solid var(--success);
}

.status-message.info {
  background: rgba(116, 185, 255, 0.1);
  color: var(--info);
  border-left: 3px solid var(--info);
}

.status-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 50px;
  height: 50px;
  border: none;
  outline: none;
  cursor: pointer;
  background: var(--bg);
  border-radius: 50%;
  box-shadow:
    4px 4px 8px var(--shadow-dark),
    -4px -4px 8px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-normal);
  z-index: 100;
}

.theme-toggle:hover {
  transform: scale(1.08);
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
}

.theme-toggle:active {
  transform: scale(0.95);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
  fill: var(--text-secondary);
  transition: all var(--t-normal);
}

.theme-toggle .icon-sun { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; fill: #fdcb6e; }

/* ============ FOOTER ============ */
.app-footer {
  margin-top: 28px;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--bg-secondary);
}

.app-footer p {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 400;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 10px;
  letter-spacing: 0.3px;
  background: var(--bg);
  color: var(--text-secondary);
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
}

.mode-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: blink 2s ease-in-out infinite;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(300%); }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow:
      4px 4px 8px var(--shadow-dark),
      -4px -4px 8px var(--shadow-light),
      0 0 24px var(--accent-glow);
  }
  50% {
    box-shadow:
      4px 4px 8px var(--shadow-dark),
      -4px -4px 8px var(--shadow-light),
      0 0 40px var(--accent-glow);
  }
}

@keyframes soundwave {
  0%, 100% { height: 4px; }
  50%      { height: 24px; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

@keyframes bounceIn {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.05); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  body {
    padding: 16px;
    justify-content: flex-start;
    padding-top: 70px;
  }

  .app-container {
    padding: 28px 22px;
    border-radius: var(--radius-lg);
  }

  .input-wrapper {
    flex-direction: column;
  }

  .btn-convert {
    justify-content: center;
    padding: 14px 20px;
  }

  .theme-toggle {
    top: 14px;
    right: 14px;
    width: 42px;
    height: 42px;
  }

  .theme-toggle svg {
    width: 18px;
    height: 18px;
  }

  .app-title {
    font-size: 1.3rem;
  }

  .app-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .app-logo svg {
    width: 28px;
    height: 28px;
  }

  .quality-options {
    gap: 6px;
  }

  .quality-option {
    padding: 8px 14px;
    font-size: 0.75rem;
  }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--shadow-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============ SELECTION ============ */
::selection {
  background: var(--accent);
  color: white;
}

/* Divider and Disclaimer */
.input-divider {
    border: none;
    height: 2px;
    background: transparent;
    border-top: 1px solid var(--shadow-dark);
    border-bottom: 1px solid var(--shadow-light);
    margin: 24px 0 16px 0;
    opacity: 0.3;
}

.input-disclaimer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 16px;
    margin-bottom: 0;
}

/* Background Overlay */
.bg-overlay {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    filter: blur(20px) brightness(0.7);
    pointer-events: none;
}
.bg-overlay.show {
    opacity: 1;
}

/* Fix button text color in dark mode */
button, .btn-format, .format-name {
    color: var(--text-primary);
}
