@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --orange-50:  #fff4ed;
  --orange-100: #ffe0c2;
  --orange-200: #ffbf80;
  --orange-300: #ff9a3c;
  --orange-400: #f97316;
  --orange-500: #e05a00;
  --orange-600: #b84500;

  --navy-50:  #eef2f8;
  --navy-100: #c8d5e8;
  --navy-200: #91aad1;
  --navy-300: #5a7fb8;
  --navy-400: #1e3a5f;
  --navy-500: #152d4a;
  --navy-600: #0d1e33;

  --cream:    #fdf8f4;
  --white:    #ffffff;
  --gray-400: #9aa0a8;
  --gray-600: #5f6870;
  --gray-800: #1e2830;

  --shadow-sm: 0 2px 8px rgba(30, 58, 95, 0.08);
  --radius:    16px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { overflow-x: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--gray-800);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ── */
.header {
  background: var(--navy-500);
  border-bottom: 3px solid var(--orange-400);
  width: 100vw;
  box-sizing: border-box;
  padding: 0 1.5rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 1rem;
  width: 100%;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.logo span { font-style: italic; color: var(--orange-300); }

.nav { display: flex; gap: 0.2rem; flex-shrink: 0; }

.nav a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--navy-100);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.nav a:hover, .nav a.active {
  background: rgba(249, 115, 22, 0.2);
  color: var(--orange-300);
}

/* ── Main ── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ── Page header row: descripción a la izquierda, count a la derecha ── */
.page-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
  width: 100%;
}

.page-description {
  font-size: 0.95rem;
  color: var(--gray-400);
  line-height: 1.55;
  flex: 1;
}

.page-description em {
  font-style: italic;
  color: var(--orange-400);
  font-weight: 500;
}

.page-count {
  font-size: 0.88rem;
  color: var(--gray-400);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--orange-300), var(--orange-500));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(224, 90, 0, 0.35);
}

.btn-secondary {
  background: var(--orange-50);
  color: var(--orange-500);
  border: 2px solid var(--orange-100);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 2px solid var(--navy-100);
}

.btn-danger {
  background: #fff0f0;
  color: #e05555;
  border: 2px solid #ffd0d0;
}

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }

/* ── Badges de estado ── */
.estado-badge {
  padding: 0.28rem 0.85rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.estado-viendo {
  background: linear-gradient(135deg, var(--orange-300), var(--orange-500));
  color: #fff;
}

.estado-completada {
  background: var(--navy-500);
  color: var(--orange-200);
}

.estado-pendiente {
  background: var(--orange-50);
  color: var(--orange-600);
  border: 1.5px solid var(--orange-200);
}

/* ── Search ── */
.search-wrapper { position: relative; }

.search-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.8rem;
  border: 2px solid var(--navy-100);
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--white);
  color: var(--gray-800);
  outline: none;
  transition: border-color var(--transition);
}

.search-input:focus { border-color: var(--orange-300); }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

/* Selects — custom arrow, appearance:none para que el border-radius funcione */
.select-input {
  padding: 0.68rem 2.6rem 0.68rem 1.1rem;
  min-width: 175px;
  border: 2px solid var(--navy-100);
  border-radius: 999px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  background-color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa0a8' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  color: var(--gray-800);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.select-input:focus { border-color: var(--orange-300); }

/* ── Progress ── */
.progress-bar {
  height: 8px;
  background: var(--navy-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange-300), var(--orange-500));
}

/* ── Cards grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ── Serie card ── */
.serie-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 2px solid var(--navy-100);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
  animation: fadeUp 0.35s ease both;
}

.serie-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.14);
}

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

.card-image {
  width: 100%;
  height: 180px;
  position: relative;
  overflow: hidden;
  background: var(--navy-50);
}

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

.card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--navy-50), var(--navy-100));
}

.estado-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.card-body {
  padding: 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy-400);
}

.progress-section { display: flex; flex-direction: column; gap: 0.3rem; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gray-400);
}

.episodio-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.episodio-controls span {
  font-size: 0.82rem;
  color: var(--gray-400);
  flex: 1;
  text-align: center;
}

.card-rating {
  font-size: 0.85rem;
  color: var(--gray-400);
}

.card-footer {
  padding: 0.8rem 1.1rem;
  border-top: 2px solid var(--navy-50);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--gray-400);
  grid-column: 1 / -1;
}

.empty-state .icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state p { font-size: 1rem; margin-bottom: 1.5rem; }
.empty-state strong { color: var(--navy-400); }

/* ── Paginación ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
}

.page-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--navy-100);
  background: var(--white);
  color: var(--gray-600);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.page-btn:hover { background: var(--navy-50); color: var(--navy-400); border-color: var(--navy-300); }
.page-btn.active { background: var(--navy-400); color: var(--white); border-color: var(--navy-400); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 45, 74, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  border: 2px solid var(--navy-100);
  box-shadow: 0 16px 48px rgba(21, 45, 74, 0.2);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy-400);
}

.modal-close {
  background: var(--navy-50);
  border: none;
  color: var(--gray-600);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover { background: var(--navy-100); color: var(--navy-400); }

.modal-body { padding: 1.5rem; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.form-label { font-size: 0.85rem; font-weight: 500; color: var(--gray-600); }

.form-input, .form-select {
  padding: 0.75rem 1rem;
  border: 2px solid var(--navy-100);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus, .form-select:focus {
  border-color: var(--orange-300);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error { font-size: 0.8rem; color: #e05555; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── Toasts ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  font-size: 0.88rem;
  color: var(--gray-800);
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.14);
  animation: slideIn 0.3s ease;
}

.toast.success { border-color: #b8f0cc; background: #f0fff5; color: #1a6b35; }
.toast.error   { border-color: #ffd0d0; background: #fff5f5; color: #b03030; }

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

/* ── Page card (crear) ── */
.page-card {
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  max-width: 600px;
  margin: 0 auto;
}

/* ── Crear / página interna: título de página ── */
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--navy-400);
}
.page-title em { font-style: italic; color: var(--orange-400); }
.page-subtitle { font-size: 0.95rem; color: var(--gray-400); margin-bottom: 2rem; }

/* ── Detalle hero ── */
.detalle-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.detalle-poster {
  width: 220px;
  height: 300px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.detalle-poster-placeholder {
  width: 220px;
  height: 300px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--navy-50), var(--navy-100));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.detalle-info {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.detalle-titulo {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy-400);
  line-height: 1.2;
}

.detalle-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.meta-chip {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--navy-50);
  color: var(--navy-400);
  border: 1px solid var(--navy-100);
}

.meta-chip.orange {
  background: var(--orange-50);
  color: var(--orange-500);
  border-color: var(--orange-100);
}

/* ── Detalle controles ── */
.detalle-controles {
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

/* ── Ratings ── */
.ratings-section {
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.ratings-section h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--navy-400);
  margin-bottom: 1.25rem;
}

.rating-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--navy-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-100);
}

.rating-big {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--orange-400);
  line-height: 1;
}

.rating-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--navy-50);
}

.rating-item:last-child { border-bottom: none; }

.rating-item-score {
  font-weight: 700;
  color: var(--orange-500);
  font-size: 1.1rem;
  min-width: 36px;
}

.rating-item-comment { font-size: 0.9rem; color: var(--gray-600); flex: 1; }

.rating-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.rating-item-date {
  font-size: 0.75rem;
  color: var(--gray-400);
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 1.5rem 1rem; }
  .page-header-row { flex-direction: column; gap: 0.5rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .form-row { grid-template-columns: 1fr; }
  .detalle-hero { grid-template-columns: 1fr; }
  .detalle-poster, .detalle-poster-placeholder { width: 100%; height: 220px; }
  .select-input { min-width: unset; width: 100%; }
}