/* Reset & Global Options */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #080710;
  --bg-card: rgba(22, 23, 34, 0.7);
  --bg-card-hover: rgba(30, 31, 46, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(79, 70, 229, 0.6);
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent-cyan: #06b6d4;
  --accent-magenta: #d946ef;
  --accent-magenta-rgb: 217, 70, 239;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-success: #10b981;
  --text-error: #ef4444;
  --text-warn: #f59e0b;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --font-sans: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background Blur Lights */
.bg-blur {
  position: absolute;
  width: 45rem;
  height: 45rem;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

.blur-cyan {
  top: -15rem;
  left: -15rem;
  background: var(--accent-cyan);
}

.blur-magenta {
  bottom: -15rem;
  right: -15rem;
  background: var(--accent-magenta);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--accent-cyan);
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo h1 span {
  background: linear-gradient(to right, var(--accent-cyan), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.badge-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

/* Downloader Main Card */
.downloader-card, .result-card, .status-card, .error-alert {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.hero-text {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-text h2 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #fff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-text p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Input Form */
.input-group-wrapper {
  margin-bottom: 2rem;
}

.input-container {
  display: flex;
  position: relative;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.375rem;
  align-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.input-icon {
  position: absolute;
  left: 1.25rem;
  color: var(--text-muted);
  width: 1.5rem;
  height: 1.5rem;
}

.input-container input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  padding: 0.75rem 1rem 0.75rem 3rem;
  font-size: 1.1rem;
  font-family: var(--font-sans);
}

.input-container input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #3b32a3);
  color: #fff;
  border: none;
  padding: 0.875rem 1.75rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #2e268f);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.875rem 1.75rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  transition: color 0.2s ease;
}

.btn-text:hover {
  color: var(--text-main);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  transition: background-color 0.2s, color 0.2s;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Advanced section */
.advanced-section {
  margin-top: 1rem;
}

#cookies-wrapper {
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1rem;
}

.field-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

#cookies-input {
  width: 100%;
  height: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.5rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: vertical;
  outline: none;
}

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

/* Platform tags */
.platform-shortcuts {
  margin-top: 2rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.shortcuts-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 1rem;
}

.shortcuts-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.platform-tag {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.platform-tag:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.all-sites-link {
  font-size: 0.875rem;
  color: var(--accent-cyan);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}

.all-sites-link:hover {
  text-decoration: underline;
}

/* Status Loading Card */
.status-card {
  text-align: center;
  padding: 3rem;
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-cyan);
  animation: spin 1s linear infinite;
}

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

/* Error alert card */
.error-alert {
  border-left: 4px solid var(--text-error);
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  align-items: flex-start;
  background: rgba(239, 68, 68, 0.05);
}

.error-icon {
  color: var(--text-error);
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.error-content {
  flex: 1;
}

.error-content h4 {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.error-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Result cards (Single view) */
.result-card {
  animation: fadeIn 0.3s ease-out;
}

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

.result-header {
  display: flex;
  gap: 2rem;
}

.media-preview-container {
  position: relative;
  flex-shrink: 0;
  width: 250px;
  border-radius: 0.75rem;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: #000;
  border: 1px solid var(--border-color);
}

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

.media-duration {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.75);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.media-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.media-details h3 {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.media-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.media-metadata span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.download-action-group {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.select-icon {
  position: absolute;
  left: 1rem;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.select-wrapper select {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.button-row {
  display: flex;
  gap: 0.75rem;
}

.btn-large {
  flex: 1;
  padding: 1rem 2rem;
}

/* Image Galleries */
.photo-action-group {
  margin-top: 1.5rem;
}

.photo-info-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.image-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gallery-preview {
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

/* Advanced Formats Table */
.advanced-formats-toggle {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.formats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.formats-table th, .formats-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.formats-table th {
  font-weight: 600;
  color: var(--text-muted);
}

.formats-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Playlist / Channel Layouts */
.playlist-info-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
  margin-bottom: 1rem;
  gap: 1.5rem;
}

.playlist-meta h3 {
  font-size: 1.35rem;
  font-weight: 700;
}

.playlist-meta p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.playlist-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.selection-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.playlist-items-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Custom scrollbars */
.playlist-items-container::-webkit-scrollbar, .queue-items-list::-webkit-scrollbar {
  width: 6px;
}

.playlist-items-container::-webkit-scrollbar-track, .queue-items-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

.playlist-items-container::-webkit-scrollbar-thumb, .queue-items-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.15);
}

.playlist-item-checkbox {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.playlist-item-thumb {
  width: 80px;
  aspect-ratio: 16/9;
  border-radius: 0.375rem;
  object-fit: cover;
  background: #000;
}

.playlist-item-details {
  flex: 1;
  min-width: 0; /* allows text-overflow */
}

.playlist-item-details h4 {
  font-size: 0.95rem;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.playlist-item-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.load-more-section {
  text-align: center;
  margin-top: 1.5rem;
}

/* User platform picker modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: #11121a;
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  width: 100%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.platform-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.platform-opt-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.platform-opt-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.opt-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--accent-cyan);
}

.platform-opt-btn:hover .opt-icon {
  color: #fff;
}

/* Batch Download Queue Drawer */
.queue-drawer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;
  background: #11121d;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  z-index: 90;
  display: flex;
  flex-direction: column;
  max-height: 400px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.queue-drawer.minimized {
  transform: translate(-50%, calc(100% - 60px));
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.queue-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-cyan);
}

.queue-title h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.queue-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.queue-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.queue-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.queue-row-thumb {
  width: 50px;
  aspect-ratio: 16/9;
  border-radius: 0.25rem;
  object-fit: cover;
  background: #000;
}

.queue-row-title {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.queue-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.queue-status-badge.queued {
  background: rgba(245, 158, 11, 0.1);
  color: var(--text-warn);
}

.queue-status-badge.working {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.queue-status-badge.done {
  background: rgba(16, 185, 129, 0.1);
  color: var(--text-success);
}

.queue-status-badge.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--text-error);
}

.btn-text-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
}

.btn-text-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Footer styling */
.app-footer {
  text-align: center;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.app-footer a {
  color: var(--text-main);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 0.5rem;
}

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

/* Responsiveness */
@media (max-width: 768px) {
  .app-container {
    padding: 1rem;
  }
  
  .app-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .downloader-card, .result-card, .status-card {
    padding: 1.5rem;
  }
  
  .hero-text h2 {
    font-size: 1.75rem;
  }
  
  .result-header {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .media-preview-container {
    width: 100%;
  }
  
  .button-row {
    flex-direction: column;
  }
  
  .playlist-info-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .playlist-controls {
    width: 100%;
    flex-direction: column;
  }
  
  .playlist-controls .select-wrapper {
    width: 100%;
  }
  
  .playlist-download-selected {
    width: 100%;
  }
  
  .platform-options-grid {
    grid-template-columns: 1fr;
  }
}
