/* Design System & Custom Properties */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Color Palette - Premium Neon/Obsidian Theme */
  --bg-base: #06070b;
  --bg-surface: rgba(15, 17, 26, 0.7);
  --bg-surface-hover: rgba(25, 28, 41, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(138, 43, 226, 0.4);
  
  --primary-glow: linear-gradient(135deg, #8a2be2 0%, #da70d6 50%, #20b2aa 100%);
  --btn-gradient: linear-gradient(135deg, #8a2be2 0%, #da70d6 100%);
  --btn-gradient-hover: linear-gradient(135deg, #9b42f5 0%, #e388e0 100%);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-teal: #20b2aa;
  --accent-purple: #a855f7;
  --accent-pink: #f472b6;
  --accent-success: #10b981;
  --accent-error: #ef4444;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(138, 43, 226, 0.25);
  
  --scrollbar-thumb: #3b3f54;
  --scrollbar-track: #0e111a;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Background Glowing Accents */
body::before, body::after {
  content: '';
  position: absolute;
  width: 35vw;
  height: 35vw;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.15;
}

body::before {
  top: -10%;
  left: -10%;
  background: #8a2be2;
}

body::after {
  bottom: -10%;
  right: -10%;
  background: #20b2aa;
}

/* Scrollbar Customization */
.scroller {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

@supports not (scrollbar-color: auto) {
  .scroller::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  .scroller::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
  }
  .scroller::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

/* Global scrollbar for the page */
html {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

/* Header & Typography */
header {
  padding: 2.5rem 1rem 1.5rem 1rem;
  text-align: center;
  position: relative;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: var(--primary-glow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 2px 8px rgba(138, 43, 226, 0.2));
}

p.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 400;
  max-width: 600px;
  margin: 0 auto;
}

/* Main Container Layout */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Glassmorphic Panel Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.card:hover {
  border-color: var(--border-color-glow);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
}

.card-title svg {
  color: var(--accent-purple);
  width: 22px;
  height: 22px;
}

/* Step Accordions / Guides */
.guide-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(138, 43, 226, 0.15);
  color: var(--text-primary);
  border: 1px solid rgba(138, 43, 226, 0.3);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
  display: block;
}

.step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.step-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.step-number {
  background: var(--btn-gradient);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 0.15rem;
  box-shadow: 0 2px 6px rgba(138, 43, 226, 0.4);
}

.kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--text-primary);
}

/* Input Section Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.textarea-wrapper {
  position: relative;
  width: 100%;
}

textarea.source-input {
  width: 100%;
  height: 220px;
  background: rgba(10, 11, 16, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  scrollbar-width: thin;
}

textarea.source-input:focus {
  border-color: rgba(138, 43, 226, 0.6);
  box-shadow: 0 0 0 3px rgba(138, 43, 226, 0.15);
}

.input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
}

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

.util-btns {
  display: flex;
  gap: 0.5rem;
}

.util-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.util-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Extract Button */
.submit-btn {
  background: var(--btn-gradient);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: 0.5s;
}

.submit-btn:hover::before {
  left: 100%;
}

.submit-btn:hover {
  background: var(--btn-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(138, 43, 226, 0.5), var(--shadow-glow);
}

.submit-btn:active {
  transform: translateY(1px);
}

/* Loading Overlay */
.loading-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 3rem 1rem;
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(138, 43, 226, 0.1);
  border-top-color: var(--accent-purple);
  border-bottom-color: var(--accent-pink);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-weight: 600;
  color: var(--text-primary);
  min-height: 24px;
}

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

/* Result Section Styles */
.result-card {
  display: none; /* Controlled via JS */
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.video-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.video-title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.3;
}

.video-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.video-preview {
  width: 100%;
  max-height: 400px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-preview video {
  width: 100%;
  height: 100%;
  max-height: 400px;
  object-fit: contain;
}

.download-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 600px) {
  .download-options {
    grid-template-columns: 1fr 1fr;
  }
}

.download-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.2s ease;
}

.download-box:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}

.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  width: fit-content;
}

.quality-badge.hd {
  background: rgba(32, 178, 170, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(32, 178, 170, 0.3);
}

.quality-badge.sd {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.quality-badge.audio {
  background: rgba(244, 114, 182, 0.15);
  color: var(--accent-pink);
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.download-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-btn {
  background: var(--text-primary);
  color: var(--bg-base);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.95rem;
}

.action-btn:hover {
  filter: brightness(0.9);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* History Log Section */
.history-card {
  margin-top: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.history-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.history-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-error);
}

.empty-history {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.5rem 0;
}

/* Modal Dialog */
dialog.help-modal {
  margin: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: #0f111a;
  color: var(--text-primary);
  max-width: 450px;
  width: 90%;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  outline: none;
}

dialog.help-modal::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.modal-content code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent-teal);
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

/* Notification Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #10b981;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: 0.9rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Footer styles */
footer {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 11, 16, 0.5);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--accent-purple);
}

/* Keyframes & Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

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