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

:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --accent: #00cec9;
  --bg-start: #0f0c29;
  --bg-mid: #302b63;
  --bg-end: #24243e;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text: #f0f0f0;
  --text-muted: #a0a0b0;
  --success: #00b894;
  --error: #e74c3c;
  --warning: #fdcb6e;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Animated background shapes === */
.background-shapes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  right: -100px;
  animation: float 8s ease-in-out infinite;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: var(--accent);
  bottom: -80px;
  left: -80px;
  animation: float 10s ease-in-out infinite reverse;
}

.shape-3 {
  width: 200px;
  height: 200px;
  background: #e84393;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: float 12s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* === Layout === */
.container {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.logo {
  font-size: 2.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  font-size: 1.4rem;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* === Glass Card === */
.card {
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
}

/* === Input Section === */
.input-card {
  margin-bottom: 20px;
}

.input-group {
  display: flex;
  gap: 10px;
}

#url-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s;
}

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

#url-input:focus {
  border-color: var(--primary);
}

#fetch-btn {
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

#fetch-btn:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

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

#fetch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

/* === Loader spinner === */
.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* === Status Messages === */
.status {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  animation: slideIn 0.3s ease;
}

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

.status.status-loading {
  background: rgba(108, 92, 231, 0.2);
  border: 1px solid rgba(108, 92, 231, 0.4);
  color: #b8b0f0;
}

.status.status-success {
  background: rgba(0, 184, 148, 0.2);
  border: 1px solid rgba(0, 184, 148, 0.4);
  color: var(--success);
}

.status.status-error {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #f0a0a0;
}

/* === Video Preview === */
.preview-card {
  animation: slideIn 0.4s ease;
}

.preview-content {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

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

.thumbnail-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

.duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

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

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

.video-author {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* === Quality Selector === */
.quality-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.quality-label {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.quality-select {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
}

.quality-select option {
  background: #1e1e3a;
  color: var(--text);
}

/* === Download Button === */
.download-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #00b894);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 206, 201, 0.3);
}

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

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.dl-icon {
  font-size: 1.3rem;
}

/* === Footer === */
.footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* === Responsive === */
@media (max-width: 500px) {
  .container {
    padding: 24px 14px;
  }

  .logo {
    font-size: 1.7rem;
  }

  .logo-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

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

  #fetch-btn {
    justify-content: center;
  }

  .preview-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .thumbnail-wrapper {
    width: 100%;
    max-width: 320px;
  }

  .video-title {
    font-size: 0.95rem;
  }

  .quality-section {
    flex-direction: column;
    align-items: stretch;
  }
}
