/* ==========================================================================
   Descargador de miniaturas de YouTube - Estilos Canónicos
   ========================================================================== */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Modo oscuro por defecto */
  --bg-app: #0a0e17;
  --bg-card: #111726;
  --bg-card-hover: #162035;
  --bg-input: #0d1322;
  --bg-secondary: #1a2238;
  --border-color: #232f48;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-red-glow: rgba(239, 68, 68, 0.25);

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-secondary: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;

  --accent-red-glow: rgba(239, 68, 68, 0.15);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.12);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

/* Layout y Contención */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1.25rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
}

.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2.5rem;
  transition: border-color 0.2s ease;
}

/* Sección de Búsqueda / Input */
.yt-search-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.yt-input-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.yt-input-group {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.yt-input-wrapper {
  flex: 1 1 320px;
  position: relative;
  display: flex;
  align-items: center;
}

.yt-input-icon {
  position: absolute;
  left: 14px;
  color: var(--accent-red);
  pointer-events: none;
  flex-shrink: 0;
}

.yt-text-input {
  width: 100%;
  height: 48px;
  padding: 0 2.75rem 0 2.85rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

.yt-text-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-input-clear {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: color 0.15s ease;
}

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

/* Botones de acción */
.btn-action-primary,
.btn-action-secondary {
  height: 48px;
  padding: 0 1.35rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-action-primary {
  background-color: var(--accent-red);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-red-glow);
}

.btn-action-primary:hover {
  background-color: var(--accent-red-hover);
  transform: translateY(-1px);
}

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

.btn-action-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-action-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

/* Presets rápidos */
.yt-presets-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  padding-top: 0.25rem;
}

.presets-caption {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.chip-preset {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-preset:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Banners de feedback */
.feedback-banner {
  margin-top: 1.25rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.feedback-banner.error {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.feedback-banner.info {
  background-color: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* Panel de Información del Vídeo */
.yt-video-card {
  margin-top: 1.5rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease;
}

.video-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.badge-code {
  font-family: var(--font-mono);
  background-color: var(--bg-input);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--accent-blue);
  font-weight: 600;
}

.video-title {
  font-size: 1.2rem;
  color: var(--text-main);
  line-height: 1.35;
}

.video-links-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.link-yt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.link-yt-chip:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--text-main);
}

.link-yt-chip.chip-highlight {
  background-color: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.link-yt-chip.chip-highlight:hover {
  background-color: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
}

/* Espacio de trabajo de miniaturas */
.thumbnails-workspace {
  margin-top: 2rem;
  animation: fadeIn 0.35s ease;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

.section-badge {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Cuadrícula de tarjetas de miniaturas */
.thumbnails-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.thumb-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.thumb-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.thumb-header {
  padding: 0.85rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.thumb-badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-quality {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-1080p {
  background-color: #ef4444;
  color: #ffffff;
}

.badge-720p {
  background-color: #3b82f6;
  color: #ffffff;
}

.badge-hq {
  background-color: #10b981;
  color: #ffffff;
}

.badge-mq {
  background-color: #64748b;
  color: #ffffff;
}

.badge-res {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.thumb-cdn-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Contenedor de la previsualización */
.thumb-preview-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.thumb-preview-wrapper:hover .thumb-img {
  transform: scale(1.03);
}

.thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.thumb-preview-wrapper:hover .thumb-overlay {
  opacity: 1;
}

.btn-zoom-overlay {
  background: rgba(17, 23, 38, 0.85);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.thumb-warning-strip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(245, 158, 11, 0.95);
  color: #000000;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 2;
}

/* Botones de acción en la tarjeta */
.thumb-actions {
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.5rem;
  background-color: var(--bg-card);
  align-items: center;
}

.btn-thumb-action {
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

.btn-thumb-action.btn-download {
  flex: 1 1 0%;
  background-color: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.btn-thumb-action.btn-download:hover {
  background-color: var(--accent-red-hover);
}

.btn-thumb-action.btn-copy {
  flex: 1 1 0%;
}

.btn-thumb-action.btn-copy:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-thumb-action.btn-copy-link {
  width: 40px;
  padding: 0;
  flex: 0 0 40px;
}

.btn-thumb-action.btn-copy-link:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

/* Sección de Fotogramas Clave */
.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.frame-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.frame-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.frame-img-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

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

.frame-actions {
  display: flex;
  gap: 0.45rem;
}

.btn-frame-download {
  flex: 1 1 0%;
  height: 34px;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-frame-download:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* Paleta cromática */
.palette-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.palette-swatches {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 52px;
  align-items: center;
}

.palette-swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.palette-swatch-item:hover {
  transform: translateY(-2px);
}

.palette-color-circle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.palette-hex-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

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

.palette-summary {
  font-size: 0.82rem;
  color: var(--text-light);
}

/* Historial reciente */
.yt-history-container {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border-color);
}

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

.history-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-text-small {
  background: transparent;
  border: none;
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: underline;
  padding: 2px 6px;
}

.btn-text-small:hover {
  color: var(--accent-red);
}

.history-grid {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.history-item-card {
  flex: 0 0 160px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.history-item-card:hover {
  border-color: var(--accent-blue);
}

.history-item-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}

.history-item-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
  text-align: center;
}

/* Guía SEO y Artículos */
.seo-guide-section {
  margin-top: 2.5rem;
}

.seo-guide-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.seo-guide-title {
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.seo-guide-subtitle {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  margin-bottom: 0.65rem;
}

.seo-guide-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.seo-table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

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

.seo-table th {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  font-weight: 600;
}

.seo-table td {
  color: var(--text-muted);
}

.seo-table tr:last-child td {
  border-bottom: none;
}

.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.seo-faq-item {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.seo-faq-q {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.seo-faq-a {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0 !important;
}

/* Modales */
.custom-modal-backdrop,
.zoom-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.custom-modal-backdrop.active,
.zoom-modal-backdrop.active {
  display: flex;
}

.custom-modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.custom-modal-title {
  font-size: 1.1rem;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

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

.custom-modal-body {
  padding: 1.35rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.custom-modal-footer {
  padding: 1rem 1.35rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Modal de Zoom */
.zoom-modal-container {
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.zoom-modal-topbar {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.zoom-meta-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.btn-close-zoom {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

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

.zoom-modal-content {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
  padding: 1rem;
}

.zoom-modal-display-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 4px;
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsividad Móvil */
@media (max-width: 768px) {
  .tool-layout {
    padding: 0 0.85rem;
    margin: 1rem auto 2.5rem;
  }

  .card-main {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }

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

  .yt-input-wrapper {
    flex: 1 1 100%;
    width: 100%;
  }

  .btn-action-primary,
  .btn-action-secondary {
    width: 100%;
    height: 44px;
  }

  .thumbnails-grid {
    grid-template-columns: 1fr;
  }

  .thumb-actions {
    flex-wrap: wrap;
  }

  .btn-thumb-action.btn-download,
  .btn-thumb-action.btn-copy {
    flex: 1 1 45%;
  }

  .video-links-row {
    flex-direction: column;
    align-items: stretch;
  }

  .link-yt-chip {
    justify-content: center;
  }
}
