/* ==========================================================================
   Radio Restaurantes â€” Panel de AdministraciÃ³n (Dark Theme)
   Mobile-first, tablet y desktop. Animaciones fluidas para barras y transiciones.
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1e2530;
  --border: #2b3442;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #2ea043;
  --accent-2: #3fb950;
  --accent-soft: rgba(63, 185, 80, 0.15);
  --danger: #f85149;
  --warn: #d29922;
  --info: #58a6ff;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --maxw: 1100px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(46, 160, 67, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(88, 166, 255, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 20px;
  position: sticky; top: 0; z-index: 20;
  background: rgba(13, 17, 23, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; }
.topbar__logo { font-size: 28px; }
.topbar__title h1 { font-size: 18px; margin: 0; letter-spacing: 0.3px; }
.topbar__subtitle { font-size: 12px; color: var(--text-dim); }
.topbar__status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Status pill ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.status-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); transition: background 0.25s ease;
}
.status-pill--on { color: var(--accent-2); border-color: rgba(63,185,80,0.4); background: var(--accent-soft); }
.status-pill--on::before { background: var(--accent-2); box-shadow: 0 0 8px 1px rgba(63,185,80,0.6); }
.status-pill--off { color: var(--text-dim); }
.status-pill--err { color: var(--danger); border-color: rgba(248,81,73,0.4); background: rgba(248,81,73,0.10); }
.status-pill--err::before { background: var(--danger); }

/* ---------- Layout ---------- */
.layout {
  max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 60px;
  display: grid; grid-template-columns: 1fr; gap: 18px;
}
@media (min-width: 820px) {
  .layout { grid-template-columns: 1.2fr 1fr; }
  .nowplaying { grid-column: 1 / -1; }
  .jobs { grid-column: 1 / -1; }
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.card h2 { font-size: 15px; margin: 0 0 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; }

/* ---------- Now Playing ---------- */
.nowplaying__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.listeners-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid rgba(63,185,80,0.35);
  font-size: 13px; font-weight: 600; color: var(--accent-2);
}
.listeners-badge__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63,185,80,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

.nowplaying__body { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nowplaying__cover {
  width: 120px; height: 120px; border-radius: 12px; object-fit: cover;
  border: 1px solid var(--border); background: var(--bg-elev); flex: 0 0 auto;
  transition: transform 0.3s ease;
}
.nowplaying__cover.is-live { animation: disc 20s linear infinite; }
@keyframes disc { to { transform: rotate(360deg); } }

.nowplaying__meta { flex: 1 1 260px; min-width: 0; }
.nowplaying__title { font-size: 19px; font-weight: 700; margin: 0 0 4px; word-break: break-word; }
.nowplaying__artist { font-size: 14px; color: var(--text-dim); margin: 0 0 12px; }
.nowplaying__progress { height: 6px; border-radius: 999px; background: var(--bg-elev); overflow: hidden; }
.nowplaying__bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s ease; }
.nowplaying__time { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- Import form ---------- */
.field { display: block; font-size: 12px; color: var(--text-dim); margin: 14px 0 6px; font-weight: 600; }
.import__form input, .import__form select, .modal__form input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.import__form input:focus, .import__form select:focus, .modal__form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.import__feedback { min-height: 20px; margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }
.import__feedback.is-err { color: var(--danger); }
.import__feedback.is-ok { color: var(--accent-2); }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  cursor: pointer; width: auto;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: var(--accent); color: #04120a; }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; margin-top: 8px; }
.import__form .btn--primary { width: 100%; margin-top: 18px; }
.btn--secondary {
  font-size: 14px; padding: 9px 14px;
  color: var(--info); border-color: rgba(88,166,255,0.4); background: rgba(88,166,255,0.10);
}
.btn--secondary:hover { background: rgba(88,166,255,0.18); }
.btn--secondary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(88,166,255,0.25); }
.btn--secondary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn--secondary.is-loading { opacity: 0.8; }
.btn--secondary.is-loading::before {
  content: ""; display: inline-block; vertical-align: -2px; margin-right: 7px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--info); border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* ---------- Jobs list ---------- */
.jobs__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.jobs__list { display: grid; gap: 12px; margin-top: 6px; }
.jobs__empty { color: var(--text-dim); margin: 8px 0; font-size: 14px; }

.job { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--bg); animation: slidein 0.35s ease; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.job__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.job__cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.job__status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.job__status--queued { color: var(--info); background: rgba(88,166,255,0.12); }
.job__status--downloading, .job__status--normalizing { color: var(--warn); background: rgba(210,153,34,0.14); }
.job__status--completed { color: var(--accent-2); background: var(--accent-soft); }
.job__status--failed { color: var(--danger); background: rgba(248,81,73,0.14); }
.job__msg { margin: 10px 0; font-size: 13px; color: var(--text-dim); word-break: break-word; }
.job__meta { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }

.progress { height: 10px; border-radius: 999px; background: var(--bg-elev); overflow: hidden; }
.progress__bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.5s ease; }
.progress.is-animating .progress__bar { background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: 200% 0; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; }
.modal.is-open { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); }
.modal__panel {
  position: relative; z-index: 1; max-width: 420px; margin: 12vh auto;
  padding: 26px; border-radius: 16px;
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-elev-2));
  border: 1px solid var(--border); box-shadow: var(--shadow); animation: slidein 0.3s ease;
}
.modal__title { margin: 0 0 6px; font-size: 20px; }
.modal__desc { margin: 0 0 6px; color: var(--text-dim); font-size: 14px; }
.modal__error { min-height: 20px; margin: 12px 0 0; font-size: 13px; color: var(--danger); }
.modal__form .field:first-of-type { margin-top: 8px; }

/* Oculta el panel de administraciÃ³n cuando no hay sesiÃ³n activa */
body.auth-required .layout { display: none; }
body.auth-required .topbar__status .btn { display: none; }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; max-width: min(92vw, 380px);
}
.toast {
  padding: 13px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-elev-2); box-shadow: var(--shadow); font-size: 14px;
  animation: toastin 0.3s ease; display: flex; align-items: center; gap: 10px;
}
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.is-leaving { animation: toastout 0.3s ease forwards; }
@keyframes toastout { to { opacity: 0; transform: translateX(20px); } }
.toast--success { border-color: rgba(63,185,80,0.5); }
.toast--success::before { content: "âœ…"; }
.toast--error { border-color: rgba(248,81,73,0.5); }
.toast--error::before { content: "âš ï¸"; }
.toast--info { border-color: rgba(88,166,255,0.5); }
.toast--info::before { content: "â„¹ï¸"; }

/* ---------- CatÃ¡logo de MÃºsica (T03_b) ---------- */
.catalog { min-width: 0; }
.catalog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.catalog__head h2 { margin-bottom: 4px; }
.catalog__help { margin: 0 0 12px; font-size: 13.5px; line-height: 1.45; color: var(--text-dim); }
.catalog__help strong { color: var(--accent-2); }

.catalog__search { position: relative; margin: 4px 0 8px; }
.catalog__search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: 0.7; pointer-events: none;
}
.catalog__search input {
  width: 100%; padding: 12px 14px 12px 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 15px; font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.catalog__search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.catalog__search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.catalog__feedback { min-height: 18px; margin: 0 0 10px; font-size: 13px; color: var(--text-dim); }
.catalog__feedback.is-ok { color: var(--accent-2); }
.catalog__feedback.is-err { color: var(--danger); }

.catalog__list { display: grid; gap: 10px; min-height: 40px; }
.catalog__empty { margin: 4px 0; color: var(--text-dim); font-size: 14px; }

.catalog__loader { display: flex; align-items: center; gap: 12px; padding: 12px 4px; color: var(--text-dim); font-size: 14px; }
.catalog__spinner {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  border: 3px solid var(--border); border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.track {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; background: var(--bg);
  transition: border-color 0.2s ease, background 0.2s ease;
  animation: slidein 0.35s ease;
}
.track:hover { border-color: rgba(63,185,80,0.45); background: var(--bg-elev); }
.track__index {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  background: var(--bg-elev); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.track__meta { flex: 1 1 200px; min-width: 0; }
.track__title { margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track__artist { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track__duration {
  flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--info);
  background: rgba(88,166,255,0.10); border: 1px solid rgba(88,166,255,0.30);
  padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums;
}

/* BotÃ³n "â–¶ Tocar a continuaciÃ³n" â€” hover, focus, disabled y loading */
.btn-queue-immediate {
  flex: 0 0 auto; font-size: 13.5px; padding: 9px 14px; border-radius: 9px;
  color: var(--accent-2); border-color: rgba(63,185,80,0.4); background: var(--accent-soft);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn-queue-immediate:hover { background: rgba(63,185,80,0.25); filter: brightness(1.05); }
.btn-queue-immediate:focus-visible { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-queue-immediate:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-queue-immediate.is-loading { opacity: 0.8; }
.btn-queue-immediate.is-loading::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--accent-2); border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn--queue,
.btn-queue-immediate {
  cursor: pointer;
}
.btn-queue-immediate.is-queued {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.6);
  color: var(--accent-2);
  cursor: default;
  opacity: 0.9;
}
@media (max-width: 560px) {
  .track { flex-wrap: wrap; }
  .track .btn-queue-immediate { flex: 1 1 100%; justify-content: center; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 520px) {
  .topbar { padding: 12px 14px; }
  .topbar__title h1 { font-size: 16px; }
  .layout { padding: 14px 12px 50px; }
  .card { padding: 14px; }
  .nowplaying__cover { width: 84px; height: 84px; }
  .nowplaying__title { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}