:root {
  --bg: #0e1117;
  --bg-soft: #161b24;
  --bg-card: #1a2029;
  --bg-elev: #212836;
  --border: #2a3342;
  --text: #e6ebf2;
  --text-dim: #97a3b4;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --ok: #2fbf71;
  --ok-soft: rgba(47, 191, 113, 0.15);
  --warn: #f0a92b;
  --danger: #ef5350;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(47, 191, 113, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
  padding: 20px clamp(12px, 3vw, 40px) 60px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  font-size: 34px;
  filter: drop-shadow(0 4px 10px rgba(124, 92, 255, 0.5));
}

.topbar h1 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 26px);
  letter-spacing: 0.3px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.count {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar input[type="search"] {
  flex: 1 1 260px;
}

input,
select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

/* ---------- Grid & cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0b0e13;
  overflow: hidden;
}

.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  background:
    repeating-linear-gradient(45deg, #141922, #141922 12px, #171d27 12px, #171d27 24px);
}

.estado-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: capitalize;
}

.card-media .btn-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  font-size: 17px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}

.card-media .btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.card-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-soft);
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(47, 191, 113, 0.4);
  background: var(--ok-soft);
}

.pill.warn {
  color: var(--warn);
  border-color: rgba(240, 169, 43, 0.45);
  background: rgba(240, 169, 43, 0.15);
}

/* ---------- Blocks (songs / videos) ---------- */
.block {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.row {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.row-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.row-actions audio {
  height: 32px;
  max-width: 100%;
}

.tag-ok {
  font-size: 11px;
  color: var(--ok);
  border: 1px solid rgba(47, 191, 113, 0.4);
  background: var(--ok-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.card-footer {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  font-size: 12px;
  padding: 6px 10px;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), #6746e6);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.btn-ok {
  background: var(--ok-soft);
  border-color: rgba(47, 191, 113, 0.45);
  color: var(--ok);
}

.btn-warn {
  background: rgba(240, 169, 43, 0.15);
  border-color: rgba(240, 169, 43, 0.45);
  color: var(--warn);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ---------- Pager ---------- */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 26px;
}

.pager button {
  min-width: 36px;
  justify-content: center;
}

.pager button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ---------- Empty ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
  max-width: min(420px, 90vw);
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}

.toast.ok {
  border-left-color: var(--ok);
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 70;
}

.overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 34px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
}

.overlay-card p {
  margin: 14px 0 0;
  font-size: 14px;
}

.overlay-hint {
  color: var(--text-dim);
  font-size: 12px !important;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.75);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 20px;
}

.modal-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal-box h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal-sub {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.modal-box pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
}

.modal-close:hover {
  border-color: var(--accent);
}

.modal-box-sm {
  width: min(520px, 100%);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.form input,
.form textarea,
.form select {
  width: 100%;
  font-family: inherit;
  color: var(--text);
}

.form textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.form-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.form-fieldset legend {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding: 0;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.check:hover {
  border-color: var(--accent);
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check:has(input:checked) {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.16);
}

/* ---------- Loader ---------- */
.loader {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-dim);
}

.loader .spinner {
  width: 42px;
  height: 42px;
}

/* ---------- SweetAlert ---------- */
.swal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.75);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 20px;
}

.swal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px 22px;
  width: min(430px, 100%);
  text-align: center;
  box-shadow: var(--shadow);
  animation: swal-in 0.18s ease;
}

.swal-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 12px;
}

.swal-box h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.swal-box p {
  margin: 0 0 22px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}

.swal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

@keyframes swal-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.hidden {
  display: none !important;
}

/* ---------- Buscador de personajes ---------- */
.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

.input-with-btn .btn {
  flex-shrink: 0;
  font-size: 15px;
  padding: 0 12px;
}

.personaje-picker {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.personaje-picker input[type="search"] {
  width: 100%;
}

.personaje-list {
  max-height: 260px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picker-anime {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  padding: 2px 0;
}

.picker-item {
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.picker-item:hover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.16);
}

.picker-empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px;
  text-align: center;
}

.estilo-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.estilo-add input {
  flex: 1;
}

.estilo-add .btn {
  flex-shrink: 0;
}

.estilos-historial {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.estilos-historial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.estilos-historial-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hist-chip {
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.hist-chip:hover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.16);
}

.hist-vacio {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Calendario de estrenos ---------- */
.modal-box-cal {
  width: min(680px, 100%);
}

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.cal-month {
  flex: 1;
  text-align: center;
  font-weight: 600;
  text-transform: capitalize;
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-weekdays {
  margin-bottom: 6px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-day {
  font-family: inherit;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  min-height: 58px;
  padding: 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cal-day:hover {
  border-color: var(--accent);
}

.cal-day-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
}

.cal-day-hours {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.cal-hour {
  font-size: 10px;
  background: rgba(124, 92, 255, 0.18);
  border: 1px solid rgba(124, 92, 255, 0.4);
  color: var(--accent-2);
  border-radius: 5px;
  padding: 1px 4px;
  align-self: flex-start;
}

.cal-day.today {
  border-color: var(--accent);
}

.cal-day.today .cal-day-num {
  color: var(--accent-2);
}

.cal-day.selected {
  background: rgba(124, 92, 255, 0.16);
  border-color: var(--accent);
}

.cal-day.has {
  box-shadow: inset 0 0 0 1px rgba(47, 191, 113, 0.3);
}

.cal-detail {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.cal-detail-head {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: capitalize;
}

.cal-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
}

.cal-slot input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.cal-slot.free {
  cursor: pointer;
}

.cal-slot.free:hover {
  border-color: var(--accent);
}

.cal-slot.occupied {
  cursor: not-allowed;
  opacity: 0.7;
}

.cal-slot.custom {
  cursor: pointer;
}

.cal-slot.custom input[type="time"] {
  width: auto;
  margin-left: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

.cal-slot-hora {
  font-weight: 700;
  min-width: 46px;
}

.cal-slot-info {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
}

.cal-hint {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

@media (max-width: 520px) {
  .cal-day {
    min-height: 48px;
    padding: 4px;
  }
  .cal-hour {
    display: none;
  }
}

@media (max-width: 520px) {
  .card-footer {
    flex-direction: column;
  }
}

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.login-logo {
  font-size: 44px;
  filter: drop-shadow(0 4px 10px rgba(124, 92, 255, 0.5));
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-sub {
  margin: -8px 0 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: left;
}

.login-card input {
  width: 100%;
  font-family: inherit;
}

.login-error {
  margin: 0;
  color: var(--danger);
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.login-card .btn-block {
  margin-top: 4px;
}
