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

:root {
  --bg-oled: #000000;
  --bg-surface: #0a0a0c;
  --bg-surface-elevated: #151518;
  
  --border-color: #1e1e24;
  --border-glow: #8b5cf6;
  
  --text-primary: #ffffff;
  --text-secondary: #9ea4b0;
  --text-muted: #535a66;
  
  --accent: #8b5cf6;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  
  /* Badges color system */
  --state-terminado-text: #10b981;
  --state-terminado-bg: rgba(16, 185, 129, 0.08);
  --state-terminado-border: rgba(16, 185, 129, 0.25);
  
  --state-dropeado-text: #ef4444;
  --state-dropeado-bg: rgba(239, 68, 68, 0.08);
  --state-dropeado-border: rgba(239, 68, 68, 0.25);
  
  --state-atrasado-text: #f59e0b;
  --state-atrasado-bg: rgba(245, 158, 11, 0.08);
  --state-atrasado-border: rgba(245, 158, 11, 0.25);
  
  --state-aldia-text: #06b6d4;
  --state-aldia-bg: rgba(6, 182, 212, 0.08);
  --state-porver-text: #a78bfa;
  --state-porver-bg: rgba(139, 92, 246, 0.1);
  --state-porver-border: rgba(139, 92, 246, 0.3);
  --state-aldia-border: rgba(6, 182, 212, 0.25);
  
  --state-ritmo-text: #a855f7;
  --state-ritmo-bg: rgba(168, 85, 247, 0.08);
  --state-ritmo-border: rgba(168, 85, 247, 0.25);
  
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  
  --state-emision-global-text: #3b82f6;
  --state-emision-global-bg: rgba(59, 130, 246, 0.08);
  --state-emision-global-border: rgba(59, 130, 246, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-oled);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Wrapper to enforce mobile scope */
.app-container {
  width: 100%;
  max-width: 480px;
  background-color: var(--bg-oled);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(80px + var(--safe-area-bottom));
}

/* Header & Dashboard */
header {
  padding: calc(15px + var(--safe-area-top)) 20px 10px 20px;
  position: sticky;
  top: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(30, 30, 36, 0.5);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.btn-settings {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.btn-settings:active {
  color: var(--accent);
}

.rating-slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rating-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
  outline: none;
}

.rating-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.rating-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.rating-slider-value {
  min-width: 76px;
  text-align: right;
  font-weight: 700;
  font-size: 1rem;
  color: #f59e0b;
  flex-shrink: 0;
}

/* Dashboard Statistics */
.dashboard-stats {
  display: flex;
  gap: 10px;
  padding: 15px 20px;
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbar Firefox */
}

.dashboard-stats::-webkit-scrollbar {
  display: none; /* Hide scrollbar Chrome/Safari */
}

.stat-card {
  flex: 0 0 calc(33.33% - 7px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 110px;
  transition: border-color 0.3s;
}

.stat-card:active {
  border-color: var(--border-glow);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-emoji {
  font-size: 1rem;
}

/* Orbs con glow para Historial / Rating 5★ / Atrasados — mismo lenguaje
   visual que el anillo de Top 5 Favs (halo de color), sin fingir una barra
   de progreso donde no hay un máximo real que medir. */
.stat-icon-orb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-icon-orb-historial {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.22) 0%, rgba(139, 92, 246, 0.04) 70%);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.25);
}

.stat-icon-orb-joyas {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.22) 0%, rgba(245, 158, 11, 0.04) 70%);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

.stat-icon-orb-atrasados {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.18) 0%, rgba(239, 68, 68, 0.05) 70%);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

/* Top 5 Favoritos — anillo de progreso futurista.
   Sustituye el emoji estático por un indicador visual que crece con cada
   favorito agregado (0 a 5), usando el gradiente de marca violeta→cian.
   El número exacto se mantiene siempre visible junto al anillo. */
.stat-value-favoritos {
  gap: 8px;
}

.fav-ring {
  flex-shrink: 0;
  transform: rotate(-90deg); /* arranca el progreso desde arriba, no desde la derecha */
}

.fav-ring-track {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 3;
}

.fav-ring-progress {
  fill: none;
  stroke: url(#fav-ring-gradient);
  stroke-width: 3;
  stroke-linecap: round;
  /* circunferencia de r=15.5 ≈ 97.4; stroke-dasharray se setea inline por JS */
  transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card-favoritos.is-complete .fav-ring-progress {
  filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.7));
}

/* Search and Filters */
.search-filter-container {
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px 12px 40px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  white-space: nowrap;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill.active {
  background: var(--accent-gradient);
  color: var(--text-primary);
  border-color: transparent;
}

/* Anime Catalog Grid */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  padding: 10px 20px;
}

.anime-card {
  position: relative;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 220px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.anime-card:active {
  transform: scale(0.97);
  border-color: var(--border-glow);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.25);
}

.anime-card-top h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.anime-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.anime-card-rating {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f59e0b;
}

.anime-card-contents {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Calculated State Badges */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  width: fit-content;
  border: 1px solid transparent;
}

.badge-terminado {
  color: var(--state-terminado-text);
  background-color: var(--state-terminado-bg);
  border-color: var(--state-terminado-border);
}

.badge-dropeado {
  color: var(--state-dropeado-text);
  background-color: var(--state-dropeado-bg);
  border-color: var(--state-dropeado-border);
}

.badge-atrasado {
  color: var(--state-atrasado-text);
  background-color: var(--state-atrasado-bg);
  border-color: var(--state-atrasado-border);
}

.badge-aldia {
  color: var(--state-aldia-text);
  background-color: var(--state-aldia-bg);
  border-color: var(--state-aldia-border);
}

.badge-ritmo {
  color: var(--state-ritmo-text);
  background-color: var(--state-ritmo-bg);
  border-color: var(--state-ritmo-border);
}

.badge-porver {
  color: var(--state-porver-text);
  background-color: var(--state-porver-bg);
  border-color: var(--state-porver-border);
}

/* Floating Action Button (FAB) */
.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-area-bottom));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  cursor: pointer;
  z-index: 90;
  transition: transform 0.2s active, box-shadow 0.2s;
}

.fab:active {
  transform: scale(0.9) rotate(90deg);
}

/* Navigation Layers (iOS style bottom sheets) */
.layer {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  height: 100%;
  background-color: var(--bg-oled);
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.1, 0.76, 0.55, 0.94);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-color);
  padding-bottom: var(--safe-area-bottom);
}

.layer.active {
  transform: translateX(-50%) translateY(0);
}

.layer-header {
  padding: calc(15px + var(--safe-area-top)) 20px 15px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 15px;
  position: sticky;
  top: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  z-index: 10;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
}

.btn-back:active {
  color: var(--accent);
}

.layer-title {
  font-size: 1.15rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.layer-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Capa 2: Ficha Anime Styling */
.anime-detail-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.anime-detail-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.detail-notes-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 15px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.detail-notes-card:empty::before {
  content: "No hay notas guardadas para esta franquicia. 💭";
  color: var(--text-muted);
  font-style: italic;
}

.collection-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}

.collection-title-row h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-add-child {
  background: none;
  border: none;
  color: var(--accent-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-add-child:active {
  opacity: 0.7;
}

.collection-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.collection-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.collection-item:active {
  border-color: var(--border-glow);
}

.collection-item-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding-right: 10px;
}

.collection-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.collection-item-notes {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-item-rating {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.collection-item-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  margin-right: 2px;
}

.collection-empty {
  text-align: center;
  padding: 30px;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-input:disabled {
  background-color: rgba(30, 30, 36, 0.4);
  color: var(--text-muted);
  border-color: rgba(30, 30, 36, 0.5);
  cursor: not-allowed;
}

/* Campo de fecha con botón de limpiar — iOS Safari no trae una "x" nativa
   en inputs type="date" como sí ocurre en escritorio, así que se agrega aquí. */
.date-input-with-clear {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.date-input-with-clear .form-input {
  flex: 1;
}

.btn-clear-date {
  flex-shrink: 0;
  width: 44px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-clear-date:active {
  border-color: var(--state-dropeado-border);
  color: var(--state-dropeado-text);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Segmented Control for Yes/No/Dropeado */
.segmented-control {
  display: flex;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 3px;
  width: 100%;
}

.segment-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.segment-btn.active {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.05);
}

.segment-btn.active[data-value="Terminado"],
.segment-btn.active[data-value="Sí"] {
  color: var(--state-terminado-text);
  border-color: var(--state-terminado-border);
}

.segment-btn.active[data-value="Dropeado"] {
  color: var(--state-dropeado-text);
  border-color: var(--state-dropeado-border);
}

.segment-btn.active[data-value="Viendo"],
.segment-btn.active[data-value="No"] {
  color: var(--accent-secondary);
  border-color: rgba(6, 182, 212, 0.3);
}

/* Interactive Star Rating Component */
.star-rating-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stars-interactive {
  display: flex;
  gap: 12px;
  font-size: 2.2rem;
}

.stars-interactive span {
  cursor: pointer;
  color: #222226;
  transition: color 0.15s, transform 0.1s;
}

.stars-interactive span.active {
  color: #f59e0b;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.stars-interactive span:active {
  transform: scale(1.3);
}

/* Buttons */
.btn-primary {
  background: var(--accent-gradient);
  border: none;
  border-radius: 10px;
  color: var(--text-primary);
  padding: 14px 20px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-danger-outline {
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--state-dropeado-text);
  padding: 12px 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
}

.btn-danger-outline:active {
  background-color: rgba(239, 68, 68, 0.08);
}

/* Settings Modal & Sections */
.settings-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-btn-row {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  flex: 1;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:active {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-glow);
}

.textarea-json {
  font-family: monospace;
  font-size: 0.75rem;
  background-color: #030303;
  color: #39eb39;
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 8px;
  width: 100%;
  height: 120px;
  outline: none;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-area-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-glow);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Utility classes */
.flex-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

/* Nuevos estilos para la integración de pósters y autocompletado */

.anime-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.7) 60%, #000000 100%);
  z-index: 1;
}

.anime-card-content {
  position: relative;
  z-index: 2;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  width: 100%;
  gap: 8px;
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 110;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.autocomplete-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background-color 0.2s;
}

.autocomplete-suggestion:last-child {
  border-bottom: none;
}

.autocomplete-suggestion:hover, .autocomplete-suggestion:active {
  background-color: rgba(139, 92, 246, 0.15);
}

.autocomplete-suggestion img {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.autocomplete-suggestion-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.autocomplete-suggestion-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-suggestion-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.anime-detail-poster-row {
  display: flex;
  flex-direction: column;
  margin: -20px -20px 20px -20px;
}

.anime-detail-poster-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  object-position: center top;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 8px 20px rgba(0,0,0,0.55);
  flex-shrink: 0;
  display: block;
}

.anime-detail-info-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  padding: 14px 16px 0 16px;
}

.btn-inline-api {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--accent-secondary);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 5px;
  width: fit-content;
}

.btn-inline-api:active {
  background-color: rgba(6, 182, 212, 0.08);
  border-color: var(--accent-secondary);
}

/* Botón de Acción Rápida: Visto Hoy */
.btn-visto-hoy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
  color: #10b981;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 6px;
  width: fit-content;
  letter-spacing: 0.2px;
}

.btn-visto-hoy:active {
  transform: scale(0.95);
  background: rgba(16, 185, 129, 0.25);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

/* NUEVOS ESTILOS FASE 4 */

/* Dropdown de Ordenamiento */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow: visible;
}

.sort-container {
  position: relative;
  display: inline-block;
  z-index: 20;
}

.btn-sort {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 1.15rem;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  flex-shrink: 0;
}

.btn-sort:active, .btn-sort.active {
  border-color: var(--accent);
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.sort-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 190px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 120;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

.sort-option {
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.sort-option:hover, .sort-option:active {
  background-color: rgba(139, 92, 246, 0.15);
  color: var(--text-primary);
}

.sort-option.active {
  color: var(--accent-secondary);
  background-color: rgba(6, 182, 212, 0.08);
}

/* Nuevo badge para emisión occidental */
.badge-emision-occidental {
  color: var(--state-emision-global-text);
  background-color: var(--state-emision-global-bg);
  border-color: var(--state-emision-global-border);
}

/* Badge de tracking en hijos */
.collection-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-child {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 600;
  display: inline-block;
}

/* Estrella de favorito en la card principal */
.anime-card-fav-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  border: 1px solid #f59e0b;
  color: #f59e0b;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  z-index: 3;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Modales de Favoritos y Rating 5 */
.favorites-list, .rating5-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-bottom: 20px;
}

.fav-item, .rating5-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.2s;
}

.fav-item:active, .rating5-item:active {
  border-color: var(--border-glow);
}

.fav-item-info, .rating5-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
  cursor: pointer;
}

.fav-item-thumb, .rating5-item-thumb {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

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

.btn-fav-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
}

.btn-fav-toggle.active {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.btn-fav-toggle:active {
  transform: scale(1.2);
}

/* Botón visto hoy rápido en hijos */
.btn-child-visto {
  background: none;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 6px;
  color: #10b981;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
  width: fit-content;
}

.btn-child-visto:active {
  background-color: rgba(16, 185, 129, 0.1);
  transform: scale(0.95);
}


/* ═══════════════════════════════════════════
   SISTEMA DE RECOMENDACIONES PERSONALIZADAS
   ═══════════════════════════════════════════ */

/* Steps de carga */
.rec-loading-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rec-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.rec-step-active {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.07);
  color: var(--text-primary);
}

.rec-step-active .rec-step-icon {
  animation: rec-pulse 1.2s ease-in-out infinite;
}

.rec-step-done {
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--text-secondary);
}

.rec-step-done::after {
  content: '✓';
  margin-left: auto;
  color: #06b6d4;
  font-size: 0.85rem;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* Grid de tarjetas de recomendaciones */
.rec-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rec-card {
  display: flex;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.rec-card:active {
  border-color: rgba(139, 92, 246, 0.4);
}

/* Poster */
.rec-card-poster {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  min-height: 110px;
  background: var(--bg-card);
  overflow: hidden;
}

.rec-card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rec-card-poster-placeholder {
  width: 100%;
  height: 100%;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: linear-gradient(135deg, #1e1040 0%, #0d0820 100%);
}

.rec-badge-prioridad {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(0,0,0,0.7);
  padding: 3px 0;
  letter-spacing: 0.02em;
}

/* Info de la tarjeta */
.rec-card-info {
  flex: 1;
  padding: 12px 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.rec-card-nombre {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0;
  /* Truncar a 2 líneas si es muy largo */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rec-card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
}

.rec-card-generos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rec-genero-tag {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--accent-primary);
  white-space: nowrap;
}

.rec-card-razon {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 2px 0 0;
}

.rec-card-basado {
  font-size: 0.72rem;
  margin: 0;
  line-height: 1.3;
}

/* ════════════════════════════════
   PROGRESO DE EPISODIOS (hijo)
   ════════════════════════════════ */

.ep-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ep-input {
  width: 72px !important;
  text-align: center;
  padding: 8px 6px !important;
  -moz-appearance: textfield;
}
.ep-input::-webkit-outer-spin-button,
.ep-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ep-separator {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
}

.ep-progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 2px;
}

.ep-progress-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.ep-progress-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ep-progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
  transition: width 0.4s ease;
}

/* ════════════════════════════════
   TUTORIAL / ONBOARDING
   ════════════════════════════════ */

.tutorial-intro {
  background: rgba(139, 92, 246, 0.07);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tutorial-section {
  margin-bottom: 22px;
}

.tutorial-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.tutorial-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.tutorial-card strong {
  font-size: 0.88rem;
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.tutorial-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.tutorial-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.tutorial-badge-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.tutorial-badge-row .badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  margin-top: 1px;
}

.tutorial-badge-row p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}
