:root {
  --bg: #12141c;
  --bg-alt: #1a1d29;
  --card: #1e2230;
  --border: #2c3145;
  --cream: #f2ede3;
  --muted: #a3a8bd;
  --gold: #e8a33d;
  --gold-dim: #b9812f;
  --teal: #5aa9a3;
  --danger: #d9694f;
  --shadow: 0 10px 30px rgba(0,0,0,0.4);
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
}

h1, h2 { font-family: 'Playfair Display', Georgia, serif; margin: 0; }

/* Tira de fotogramas: elemento distintivo de marca */
.filmstrip {
  height: 14px;
  background:
    repeating-linear-gradient(90deg, #000 0 10px, transparent 10px 22px),
    var(--gold);
  background-blend-mode: normal;
  position: relative;
}
.filmstrip::before, .filmstrip::after { content: none; }

.app-header {
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.logo {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--cream);
  letter-spacing: 0.3px;
}
.logo span { color: var(--gold); }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--cream);
  padding: 10px 14px;
  border-radius: 999px;
  min-width: 260px;
  font-family: inherit;
}
.search-input:focus { outline: 2px solid var(--gold); }

.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn-primary { background: var(--gold); color: #201203; }
.btn-secondary { background: var(--teal); color: #05201d; }
.btn-ghost { background: transparent; color: var(--cream); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #2a0a03; }

.grid {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 22px;
}

.movie-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.movie-card:hover { transform: translateY(-4px); border-color: var(--gold-dim); }
.movie-card .poster-wrap {
  aspect-ratio: 2/3;
  background: #0d0f16;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.movie-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.movie-card .no-poster { color: var(--muted); font-size: 2rem; }
.movie-card .card-body { padding: 10px 12px 14px; }
.movie-card .card-title { font-weight: 700; font-size: 0.95rem; line-height: 1.25; }
.movie-card .card-meta { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

.empty-state { text-align: center; color: var(--muted); margin-top: 60px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,7,11,0.72);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
  backdrop-filter: blur(2px);
}
/* El atributo hidden debe ganar siempre a display:flex de arriba;
   si no, los modales quedan visibles aunque JS los marque como ocultos. */
.modal-overlay[hidden] {
  display: none !important;
}
.modal {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 860px; width: 100%;
  box-shadow: var(--shadow);
  padding: 24px 28px 28px;
}
.modal-small { max-width: 480px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.btn-close {
  background: none; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}
.btn-close:hover { color: var(--cream); }

.lookup-bar {
  display: flex; gap: 8px; margin-bottom: 8px;
  background: var(--card); padding: 10px; border-radius: 10px; border: 1px solid var(--border);
}
.lookup-bar select {
  background: var(--bg); color: var(--cream); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px;
}
.lookup-bar input {
  flex: 1; background: var(--bg); color: var(--cream);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
.lookup-results {
  display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 16px;
}
.lookup-result-card {
  min-width: 110px; max-width: 110px; cursor: pointer; text-align: center;
  color: var(--muted); font-size: 0.75rem;
}
.lookup-result-card img {
  width: 100%; height: 150px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border);
  background: #0d0f16;
}
.lookup-result-card:hover img { border-color: var(--gold); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.78rem; color: var(--muted); }
.field input, .field textarea {
  background: var(--card); border: 1px solid var(--border); color: var(--cream);
  border-radius: 7px; padding: 9px 10px; font-family: inherit; font-size: 0.9rem;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--gold); }

.poster-field { grid-row: span 2; }
.poster-preview {
  width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); margin-bottom: 4px;
}

.section-divider {
  grid-column: 1 / -1;
  font-family: 'Playfair Display', serif;
  color: var(--gold);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 8px 0 2px;
}

.modal-footer {
  display: flex; align-items: center; gap: 10px; margin-top: 20px;
}
.modal-footer .spacer { flex: 1; }

.fields-admin-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field-admin-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
}
.field-admin-row button {
  background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem;
}
.add-field-form { display: flex; gap: 8px; }
.add-field-form input {
  flex: 1; background: var(--card); border: 1px solid var(--border); color: var(--cream);
  border-radius: 7px; padding: 9px 10px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #201203; font-weight: 600;
  padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 100;
}
.toast.error { background: var(--danger); color: #2a0a03; }

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .poster-field { grid-column: 1 / -1; grid-row: auto; max-width: 200px; }
  .header-inner { flex-direction: column; align-items: stretch; }
  .search-input { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
