/* =====================================================
   CINEMATECA — HOJA DE ESTILOS
   =====================================================
   ÍNDICE
   1.  Variables y Reset
   2.  Loader
   3.  Header
   4.  Controles y Filtros
   5.  Grid de Películas
   6.  Vista Detalle
   7.  Modales — Base
   8.  Modal Añadir
   9.  Modal Edición
   10. Estadísticas
   11. Componentes Globales (FAB, Admin, Login)
   12. Responsive — Tablet (max 900px)
   13. Responsive — Móvil (max 768px)
   14. Responsive — Móvil pequeño (max 480px)
   15. Animaciones
   ===================================================== */


/* =====================================================
   1. VARIABLES Y RESET
   ===================================================== */

:root {
  --bg-dark:    #0f172a;
  --bg-panel:   #1e293b;
  --accent:     #3b82f6;
  --text-main:  #f8fafc;
  --text-muted: #94a3b8;
  --success:    #4ade80;
  --gold:       #facc15;
  --danger:     #ef4444;
  --input-bg:   #020617;
  --border:     #334155;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* =====================================================
   2. LOADER
   ===================================================== */

#loader-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg-dark);
  z-index: 100000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.5s ease-out, visibility 0.5s;
}
#loader-overlay.fade-out { opacity: 0; visibility: hidden; }

.loader-logo {
  display: flex; align-items: center;
  gap: 15px; margin-bottom: 30px;
  animation: fadeInUp 0.8s ease-out;
}
.loader-logo img { height: 60px; width: auto; filter: drop-shadow(0 0 20px rgba(59,130,246,0.3)); }
.loader-text-logo {
  font-size: 2.5rem; font-weight: 800; letter-spacing: -1px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.loading-text {
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.85rem; letter-spacing: 2px;
  text-transform: uppercase; font-weight: 600;
}


/* =====================================================
   3. HEADER
   ===================================================== */

.sticky-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  backdrop-filter: blur(12px);
}

.brand-row {
  display: flex; align-items: center;
  gap: 12px; cursor: pointer; position: relative;
}
.brand-logo-img { height: 36px; width: auto; }
.brand-text-col {
  display: flex; flex-direction: column;
  line-height: 1; margin-right: auto;
}
.brand-title { font-size: 1.5rem; font-weight: 800; color: white; margin-bottom: 2px; }
.brand-subtitle {
  font-size: 0.65rem; color: var(--accent);
  font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
}
.header-actions { display: flex; align-items: center; gap: 12px; }

.admin-badge {
  display: inline-block;
  background: rgba(250, 204, 21, 0.15);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: var(--gold);
  font-size: 0.65rem; font-weight: 700;
  padding: 4px 10px; border-radius: 6px;
  letter-spacing: 1px; cursor: pointer; user-select: none;
}
.admin-badge:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}
.admin-badge:hover::after { content: " (SALIR)"; }

.btn-add-header {
  background: var(--accent); color: white;
  border: none; font-size: 1.2rem;
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.2s;
}
.btn-add-header:hover { transform: scale(1.1); background: #2563eb; }

.login-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer; padding: 6px 12px;
  border-radius: 8px; font-size: 0.75rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.login-btn:hover {
  background: var(--accent); color: white;
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

/* Visibilidad según modo guest/admin */
body.guest-mode .admin-badge,
body.guest-mode .btn-add-header,
body.guest-mode .btn-buy { display: none !important; }
body:not(.guest-mode) .login-btn { display: none !important; }


/* =====================================================
   4. CONTROLES Y FILTROS
   ===================================================== */

.controls-section { padding: 20px 0; }

.controls-row {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 15px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 8px;
}

.mode-selector, .status-selector {
  display: flex; gap: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 40%; justify-content: center;
}

.mode-btn, .status-btn {
  flex: 1; padding: 8px 12px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: 0.2s; white-space: nowrap;
}
.mode-btn.activo {
  background: var(--accent) !important;
  color: white !important;
  box-shadow: 0 2px 10px rgba(59,130,246,0.3);
}
.status-btn.activo {
  background: white !important;
  color: #0f172a !important;
  opacity: 1 !important;
}
.status-btn:hover:not(.activo),
.mode-btn:hover:not(.activo) {
  color: white;
  background: rgba(255,255,255,0.05);
}

.toolbar { display: flex; flex-direction: column; gap: 12px; }
.search-line { display: flex; gap: 10px; align-items: stretch; }
.filters-line { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

#contador {
  text-align: left; font-size: 0.8rem;
  color: var(--text-muted); font-weight: 600;
  margin-top: 8px; margin-left: 5px; opacity: 0.7;
}

/* Inputs y Selects — altura uniforme */
input, select,
.action-btn, .btn-confirm,
.status-toggle, .btn-modal-save,
.btn-modal-back, .btn-delete-edit {
  height: 50px !important;
  min-height: 50px;
  box-sizing: border-box;
  font-size: 0.95rem;
  line-height: normal;
}

input, select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: white;
  border-radius: 10px; flex: 1;
  outline: none; transition: border 0.2s;
  appearance: none;
}
select {
  padding: 0 45px 0 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 15px) center;
}
input { padding: 0 16px; }
input:focus, select:focus { border-color: var(--accent); }

.action-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer; font-size: 1.2rem;
  color: var(--text-muted); transition: 0.2s;
}
.action-btn:hover { background: var(--border); color: white; border-color: var(--text-muted); }

/* Menú móvil — botón cerrar */
#btnCloseMenu {
  display: none; text-align: right;
  padding: 10px; color: var(--danger);
  font-weight: 800; cursor: pointer;
}

/* FAB — botones flotantes */
.fab-btn {
  position: fixed; bottom: 30px; right: 30px;
  width: 50px; height: 50px;
  border-radius: 50%; border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: 0.3s; transform: translateY(20px);
  font-size: 1.5rem;
  background: var(--accent); color: white;
}
.fab-btn.visible { opacity: 1; pointer-events: all; transform: translateY(0); }
#btnFilters {
  bottom: 90px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  color: var(--text-muted);
  display: none;
}


/* =====================================================
   5. GRID DE PELÍCULAS
   ===================================================== */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 24px 16px;
  padding-bottom: 80px;
}

.card {
  cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0; animation: apar 0.4s ease-out forwards;
  transform: translateZ(0);
}
.card:hover { transform: translateY(-5px); }

.poster-box {
  aspect-ratio: 2/3; border-radius: 12px;
  overflow: hidden; background: var(--bg-panel);
  position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
.poster-box img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.card:hover .poster-box img { filter: brightness(1.1); transform: scale(1.05); }

.card-name {
  font-size: 0.9rem; font-weight: 600;
  text-align: center; line-height: 1.3;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.badges { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.65rem;
  padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.tag-own {
  color: #4ade80;
  border-color: rgba(74,222,128,0.2);
  background: rgba(74,222,128,0.05);
}

.placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at center, #334155 0%, var(--bg-panel) 75%);
  transition: 0.3s;
}
.ph-icon { font-size: 4rem; opacity: 0.1; filter: grayscale(1); transition: 0.3s; }
.card:hover .placeholder { filter: brightness(1.2); }
.card:hover .ph-icon { transform: scale(1.1) rotate(-10deg); opacity: 0.2; }


/* =====================================================
   6. VISTA DETALLE
   ===================================================== */

.detail-view {
  position: relative; overflow: hidden;
  background: linear-gradient(to bottom, #0f172a, #1e293b);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 2.5rem;
  display: grid; grid-template-columns: 300px 1fr;
  gap: 3rem; align-items: start; margin-bottom: 80px;
}
.detail-bg {
  position: absolute; inset: 0;
  background-size: cover;
  filter: blur(60px) brightness(0.3);
  opacity: 0.6; z-index: 0; pointer-events: none;
}
.detail-poster {
  width: 100%; aspect-ratio: 2/3;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  z-index: 1; position: relative; overflow: hidden;
}
.detail-poster img, .detail-poster .placeholder {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 12px;
}

.info { position: relative; z-index: 1; }
.info h2 { font-size: 3rem; line-height: 1.1; margin: 0 0 1.5rem; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }

.row { display: flex; border-bottom: 1px solid rgba(255,255,255,0.1); padding: 12px 0; font-size: 0.95rem; }
.lbl { width: 140px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.val { color: white; opacity: 0.9; }

.sinopsis-wrapper { margin: 1.5rem 0; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 10px; }
.sinopsis-header {
  font-weight: 700; color: var(--accent);
  font-size: 0.85rem; letter-spacing: 1px;
  margin-bottom: 8px; cursor: pointer;
  display: flex; justify-content: space-between;
}
.sinopsis-text { line-height: 1.6; opacity: 0.9; font-weight: 300; }

.action-buttons-row { display: flex; gap: 15px; margin-top: 2rem; flex-wrap: wrap; align-items: center; }
.btn-yt, .btn-buy {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 24px; border-radius: 50px;
  font-weight: 600; text-decoration: none;
  cursor: pointer; transition: 0.2s; font-size: 0.95rem;
  flex: 1; min-width: 160px; max-width: 250px;
}
.btn-yt { border: 1px solid var(--danger); color: var(--danger); }
.btn-yt:hover { background: var(--danger); color: white; }
.btn-buy { border: 1px solid var(--success); color: var(--success); background: transparent; }
.btn-buy:hover { background: var(--success); color: #064e3b; }

.back-link {
  cursor: pointer; color: var(--accent); font-weight: 600;
  margin-bottom: 20px;
  display: inline-flex; align-items: center; gap: 5px;
}
.back-link:hover { text-decoration: underline; }

.delete-btn-floating {
  position: absolute; top: 20px; right: 20px;
  background: rgba(0,0,0,0.6); color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s ease;
  backdrop-filter: blur(4px); z-index: 20; font-size: 1.2rem;
}
.delete-btn-floating:hover {
  background: #ef4444; color: white;
  transform: scale(1.1) rotate(10deg);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

#vistaTemporadas { padding-bottom: 100px; }

/* Vista series — cabecera con botón eliminar */
.header-serie-row {
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.header-serie-row h2 { margin: 0; }

.btn-eliminar-serie {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 50px; font-weight: 700;
  cursor: pointer; transition: 0.2s;
}
.btn-eliminar-serie:hover { background: var(--danger); color: white; }


/* =====================================================
   7. MODALES — BASE
   ===================================================== */

#buyOverlay, #loginOverlay, #addOverlay,
#statsOverlay, #confirmOverlay, #editOverlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 20000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: 0.3s;
}
.visible { opacity: 1 !important; pointer-events: all !important; }

.buy-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 30px; border-radius: 20px;
  width: 90%; max-width: 450px;
  max-height: 85dvh; overflow-y: auto;
  box-sizing: border-box;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: translateY(20px); transition: 0.3s;
}
.visible .buy-modal { transform: translateY(0); }

.buy-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}
.buy-header h3 { margin: 0; font-size: 1.25rem; font-weight: 700; color: white; }
.close-stats { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.close-stats:hover { color: var(--danger); }

.btn-confirm {
  width: 100%; padding: 14px;
  background: var(--success); color: #064e3b;
  border: none; border-radius: 12px;
  font-weight: 800; font-size: 1rem;
  cursor: pointer; text-transform: uppercase;
  letter-spacing: 1px; margin-top: 10px; transition: 0.2s;
}
.btn-confirm:hover { filter: brightness(1.1); transform: scale(1.02); }

/* Password Input */
.password-wrapper { position: relative; width: 100%; }
.password-wrapper input { width: 100% !important; padding-right: 45px; }
.eye-icon {
  position: absolute; right: 15px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); cursor: pointer; display: flex;
}

/* Formulario compartido */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; }
.form-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.form-label {
  font-size: 0.75rem; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; letter-spacing: 0.5px;
}

.status-toggle {
  display: flex; background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 4px; height: 56px;
}
.status-toggle button {
  flex: 1; border-radius: 6px; border: none;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; color: var(--text-muted);
  background: transparent; transition: 0.2s;
}
.status-toggle button.active {
  background: var(--bg-panel); color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.status-toggle button.active[data-val="SI"] { color: var(--success); }
.status-toggle button.active[data-val="NO"] { color: var(--gold); }


/* =====================================================
   8. MODAL AÑADIR
   ===================================================== */

.add-modal-wide {
  max-width: 650px;
  max-height: 90dvh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex; flex-direction: column;
}

.search-row-api { display: flex; gap: 10px; margin-bottom: 20px; }
#apiTypeSelect { flex: 0 0 110px; }
.search-row-api .action-btn { width: 56px !important; height: 56px !important; padding: 0; border-radius: 10px; flex-shrink: 0; }
.add-modal-wide select, .add-modal-wide input { height: 50px !important; }

/* Grid resultados TMDB */
.api-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  max-height: 400px; overflow-y: auto;
  padding-right: 5px; margin-top: 15px; min-height: 0;
}
.api-results-grid:empty { display: none; }
.api-results-grid::-webkit-scrollbar { width: 6px; }
.api-results-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.api-card { cursor: pointer; border-radius: 8px; overflow: hidden; transition: 0.2s; position: relative; }
.api-card:hover { transform: scale(1.02); }
.api-poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: #000; }
.api-title {
  font-size: 0.75rem; padding: 6px; text-align: center;
  background: rgba(0,0,0,0.8); color: white;
  position: absolute; bottom: 0; width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Estado de búsqueda (cargando / sin resultados) */
.modal-search-state {
  grid-column: 1 / -1; width: 100%;
  padding: 30px; min-height: 120px;
  text-align: center; color: var(--text-muted); font-weight: 500;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 20px; background: rgba(255,255,255,0.03);
  border-radius: 12px; margin-top: 10px;
  border: 1px dashed var(--border); box-sizing: border-box;
}
.no-results-icon { font-size: 3rem; opacity: 0.7; margin-bottom: 10px; }
.big-spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}

/* Preview selección */
.selected-preview {
  display: flex; gap: 15px; margin-bottom: 20px;
  background: rgba(255,255,255,0.03);
  padding: 15px; border-radius: 12px; border: 1px solid var(--border);
}
.mini-poster { width: 70px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; }
.preview-info { display: flex; flex-direction: column; justify-content: center; }
.preview-title { font-weight: 700; font-size: 1.1rem; color: white; margin-bottom: 4px; }
.preview-year { color: var(--text-muted); font-size: 0.9rem; }

/* Colección */
.collection-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.collection-row select {
    flex: 1;
    min-width: 0;
}
.btn-plus-col {
    width: 44px;
    height: 44px !important;
    min-height: 44px !important;
    flex: 0 0 44px;
    border-radius: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
}
.btn-plus-col:hover { background: var(--success); color: #000; }

#newCollectionInput {
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--accent);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

/* Footer modal añadir */
.modal-footer { margin-top: 25px; display: flex; gap: 12px; }
.btn-modal-back, .btn-modal-save {
  flex: 1; padding: 14px; border-radius: 10px;
  font-weight: 700; cursor: pointer; border: none;
  text-transform: uppercase; font-size: 0.9rem; transition: 0.2s;
  display: flex; align-items: center; justify-content: center; height: 50px;
}
.btn-modal-back {
  background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
}
.btn-modal-back:hover { border-color: var(--text-muted); color: white; }
.btn-modal-save { background: var(--success); color: #064e3b; }
.btn-modal-save:hover { filter: brightness(1.1); transform: translateY(-2px); }


/* =====================================================
   9. MODAL EDICIÓN
   ===================================================== */

.edit-modal {
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
}

/* Layout dos columnas en desktop */
.edit-modal .form-grid { grid-template-columns: 1fr 1fr; }
.edit-modal .form-group:first-child { grid-column: 1 / -1; }
.edit-modal #editGroupPrio { grid-column: 1 / 2; }
.edit-modal #editGroupFormato,
.edit-modal #editGroupUbicacion { grid-column: auto; }

/* Multiselect checkboxes */
.multiselect-group {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}

.check-option {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 0.9rem;
  cursor: pointer; padding: 4px 0; transition: 0.2s;
  height: auto !important; min-height: auto !important;
}
.check-option:hover { color: white; }

.multiselect-group input[type="checkbox"],
#editFormatoOptions input[type="checkbox"],
#editUbicacionOptions input[type="checkbox"] {
  all: revert;
  width: 18px !important; height: 18px !important;
  min-height: 18px !important;
  accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0;
}

/* Footer botones modal edición */
.edit-footer-btns {
  margin-top: 20px;
  display: flex; gap: 10px; align-items: center;
}

.btn-delete-edit {
  flex: 1; height: 50px !important;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 12px; color: var(--danger);
  font-weight: 700; cursor: pointer; transition: 0.2s;
}
.btn-delete-edit:hover { background: var(--danger); color: white; }

.edit-footer-btns .btn-confirm {
  flex: 2; margin-top: 0;
  height: 50px !important; min-height: 50px !important;
  display: flex; align-items: center; justify-content: center;
}


/* =====================================================
   10. ESTADÍSTICAS
   ===================================================== */

.stats-container {
  width: 95%; max-width: 800px;
  max-height: 85dvh; overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 25px;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 15px; margin-bottom: 30px;
}
.stat-card {
  background: var(--input-bg); padding: 20px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);
  text-align: center;
}
.stat-val { font-size: 2.2rem; font-weight: 800; color: var(--accent); margin-bottom: 5px; }
.stat-lbl { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }
.stat-sub { font-size: 0.9rem; color: #fff; margin-top: 5px; font-weight: 600; }

.stats-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.bar-label { width: 120px; text-align: right; color: var(--text-muted); }
.bar-track { flex: 1; background: var(--input-bg); height: 8px; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { width: 40px; color: #fff; font-weight: 600; }


/* =====================================================
   11. RESPONSIVE — TABLET (max 900px)
   ===================================================== */

@media (max-width: 900px) {
  .detail-view { grid-template-columns: 1fr; padding: 1.5rem; gap: 2rem; }
  .detail-poster { max-width: 240px; margin: 0 auto; }
  .info h2 { font-size: 2rem; text-align: center; }
  .sinopsis-text { display: none; }
  .sinopsis-wrapper.open .sinopsis-text { display: block; }
}

@media (min-width: 901px) {
  .brand-row { justify-content: center; }
  .brand-text-col { margin-right: 0; align-items: center; }
  .header-actions { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
  .sinopsis-header { display: none; }
  .sinopsis-text { display: block !important; }
}


/* =====================================================
   12. RESPONSIVE — MÓVIL (max 768px)
   ===================================================== */

@media (max-width: 768px) {
  .container { padding: 0 15px; }

  /* Grid */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 20px 12px; }

  /* Controles */
  .controls-row { flex-direction: column; gap: 10px; }
  .mode-selector, .status-selector { width: 100%; justify-content: center; }
  .search-line input { min-width: 0; }

  /* FAB */
  .fab-btn { right: 20px; bottom: 25px; }
  #btnFilters { display: flex; bottom: 85px; }

  /* Estadísticas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Inputs — evitar zoom en iPhone */
  input, select, textarea { font-size: 16px !important; }

	/* Modal edición — una columna */
	.edit-modal .form-grid { grid-template-columns: 1fr; }
	.edit-modal .form-group:first-child { grid-column: 1; }

	/* Modal añadir — una columna en móvil */	
	#stepDetails .form-grid {
		grid-template-columns: 1fr;
		width: 100%;
		max-width: 100%;
		min-width: 0;
	}
	#stepDetails .status-toggle { width: 100%; }
	#stepDetails .form-group {
		min-width: 0;
		max-width: 100%;
		width: 100%;
	}

  /* Bottom sheet filtros */
  .controls-section { display: block; margin-bottom: 20px; min-height: auto; }

  .controls-section.mobile-open {
    display: flex !important; flex-direction: column;
    position: fixed;
    bottom: 0 !important; left: 0 !important;
    top: auto; transform: none; margin: 0 !important;
    width: 100%; max-width: 100%;
    height: auto; max-height: 85vh;
    background: var(--bg-panel);
    border-top: 1px solid var(--accent);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.9);
    z-index: 20000 !important;
    padding: 55px 20px 0 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    gap: 12px; overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .controls-section.mobile-open ~ .grid,
  .controls-section.mobile-open ~ #vistaTemporadas { margin-top: 24px; }

  /* Tirador decorativo */
  .controls-section.mobile-open::before {
    content: ''; display: block;
    width: 40px; height: 4px;
    background: rgba(255,255,255,0.2); border-radius: 2px;
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  }

  /* Contador y cerrar */
  .controls-section.mobile-open #contador {
    display: block !important; position: absolute;
    top: 20px; left: 24px;
    font-size: 0.8rem; font-weight: 800;
    color: var(--text-muted); letter-spacing: 1px;
    margin: 0; pointer-events: none;
  }
  .controls-section.mobile-open #btnCloseMenu {
    display: block !important; position: absolute;
    top: 18px; right: 24px; width: auto;
    color: var(--danger); font-size: 0.8rem; font-weight: 800;
    padding: 5px; margin: 0; border: none;
  }
  .controls-section:not(.mobile-open) #btnCloseMenu { display: none !important; }

  /* Elementos del bottom sheet */
  .controls-section.mobile-open .controls-row,
  .controls-section.mobile-open .toolbar { display: contents !important; }

  .controls-section.mobile-open .search-line {
    order: 2; display: flex; flex-wrap: wrap; gap: 10px;
  }
  .controls-section.mobile-open #buscador {
    width: 100%; flex-basis: 100%; height: 50px !important;
    font-size: 1.1rem; border-color: var(--accent); background: var(--input-bg);
  }
  .controls-section.mobile-open .search-line .action-btn {
    flex: 1; height: 45px !important;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border); border-radius: 12px;
  }
  .controls-section.mobile-open .mode-selector { order: 3; width: 100% !important; margin: 0; }
  .controls-section.mobile-open .status-selector { order: 4; width: 100% !important; margin: 0; }
  .controls-section.mobile-open .mode-selector,
  .controls-section.mobile-open .status-selector {
    height: 45px !important; padding: 4px;
    background: var(--input-bg); border-radius: 12px;
  }
  .controls-section.mobile-open .mode-btn,
  .controls-section.mobile-open .status-btn {
    height: 100%; display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
  }
  .controls-section.mobile-open .filters-line {
    order: 5; display: grid;
    grid-template-columns: 1fr 1fr; gap: 10px;
    padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.1);
  }
  .controls-section.mobile-open #selOrden,
  .controls-section.mobile-open #selOrdenSeries,
  .controls-section.mobile-open #selColeccion { grid-column: 1 / -1; }
  .controls-section.mobile-open select {
    width: 100%; height: 45px !important;
    background-color: var(--bg-panel); font-size: 0.9rem;
  }
  #btnFilters {
    display: flex !important; align-items: center; justify-content: center;
    bottom: 90px; background: var(--accent); color: white;
    opacity: 0; pointer-events: none; transform: translateY(20px);
    transition: 0.3s all ease; z-index: 9999;
  }
  #btnFilters.visible { opacity: 1; pointer-events: all; transform: translateY(0); }

  /* Hovers táctiles */
  @media (hover: none) {
    .card:hover { transform: none !important; }
    .card:hover .poster-box img { transform: none !important; filter: none !important; }
    .action-btn:hover { background: var(--bg-panel); color: var(--text-muted); }
    .card:active { transform: scale(0.98) !important; transition: 0.1s; }
  }
}


/* =====================================================
   13. RESPONSIVE — MÓVIL PEQUEÑO (max 480px)
   ===================================================== */

@media (max-width: 480px) {
  /* Grid — 2 columnas fijas */
  .grid { grid-template-columns: repeat(2, 1fr) !important; gap: 15px 10px !important; }
  .poster-box { border-radius: 8px; }
  .card-name { font-size: 0.8rem; }

  /* Ancho modal */
  .buy-modal {
    width: 92vw !important;
    padding: 20px 15px !important;
  }

  /* Búsqueda TMDB en modal añadir */
  .add-modal-wide {
    width: 95vw !important;
    padding: 20px 15px !important;
    max-height: 85dvh !important;
  }

  .search-row-api {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
  }
  .search-row-api #apiTypeSelect { grid-column: 1 / -1; width: 100%; }
  .search-row-api input { grid-column: 1; }
  .search-row-api .action-btn { grid-column: 2; width: 50px; flex-shrink: 0; }

  /* Estado búsqueda */
  .modal-search-state { flex-direction: column; padding: 20px; }

  /* Form grid — una columna */
  .form-grid { grid-template-columns: 1fr; gap: 15px; }

  /* Status toggle y form-grid dentro del modal añadir */
  .add-modal-wide .status-toggle {
    width: 100%;
    max-width: 100%;
  }
  .add-modal-wide .form-grid {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
}


/* =====================================================
   14. ANIMACIONES
   ===================================================== */

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes apar {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes slideDown {
  from { top: -50px; opacity: 0; }
  to   { top: 20px; opacity: 1; }
}