/* Control remoto móvil del Reproductor */
:root {
  --bg: #07090e;
  --surface: #10151f;
  --card: #151c28;
  --card-hover: #1b2433;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --muted: #8d9bb0;
  --accent: #a8b9a9;
  --accent-2: #879e8b;
  --danger: #ff4d6d;
  --success: #a8b9a9;
  --warning: #ffb020;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% -10%, #162033 0%, var(--bg) 55%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.remote-app {
  min-height: 100dvh;
}

/* Puertas de conexión y login */
.gate-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.gate-card {
  width: min(430px, 100%);
  background: linear-gradient(180deg, rgba(24, 32, 46, 0.96), rgba(13, 18, 27, 0.98));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001018;
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(168, 185, 169, 0.25);
}

.gate-card h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.gate-copy {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.gate-copy strong {
  color: var(--accent);
}

.gate-hint {
  margin: 15px 0 0;
  color: #67758a;
  font-size: 0.76rem;
  line-height: 1.4;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.text-input,
.select-input {
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c1119;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field input:focus,
.text-input:focus,
.select-input:focus {
  border-color: var(--accent);
  background: #0e1621;
}

.field-error {
  min-height: 18px;
  margin: 2px 0 8px;
  color: var(--danger);
  font-size: 0.78rem;
  line-height: 1.35;
}

.primary-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001018;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 8px 22px rgba(168, 185, 169, 0.2);
}

.primary-btn:active {
  transform: scale(0.99);
}

.primary-btn.compact {
  width: auto;
  min-height: 42px;
  padding: 0 18px;
  font-size: 0.84rem;
}

.link-btn {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: underline;
}

/* Shell */
.remote-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.remote-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(8, 12, 18, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-brand > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-brand strong {
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  flex-shrink: 0;
}

.role-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.connection-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 230, 118, 0.12);
  color: var(--success);
  border: 1px solid rgba(0, 230, 118, 0.28);
  white-space: nowrap;
}

.connection-pill.offline {
  background: rgba(255, 176, 32, 0.12);
  color: var(--warning);
  border-color: rgba(255, 176, 32, 0.28);
}

.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.icon-btn.danger {
  color: var(--danger);
}

.offline-banner {
  margin: 12px 16px 0;
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.3);
  color: #ffd27a;
  font-size: 0.8rem;
  line-height: 1.4;
}

.remote-main {
  flex: 1;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px 14px calc(90px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.remote-shell.has-mini .remote-main { padding-bottom: calc(158px + env(safe-area-inset-bottom)); }
.remote-footer { position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%); width: min(760px, 100%); padding: 5px 10px calc(5px + env(safe-area-inset-bottom)); background: var(--bg); }

.panel {
  background: linear-gradient(180deg, rgba(22, 30, 44, 0.92), rgba(13, 18, 27, 0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.now-panel {
  padding: 16px 16px 14px;
}

.now-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.format-pill {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--accent);
  background: rgba(168, 185, 169, 0.12);
  border: 1px solid rgba(168, 185, 169, 0.28);
}

.format-pill.video {
  color: #ff5fa8;
  background: rgba(255, 0, 127, 0.12);
  border-color: rgba(255, 0, 127, 0.3);
}

.status-text {
  color: var(--muted);
  font-size: 0.72rem;
}

.now-title {
  margin: 0 0 3px;
  font-size: 1.2rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.now-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 18px;
  overflow-wrap: anywhere;
}

.seek-block input[type="range"],
.control-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.72rem;
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}

.transport-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.transport-btn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.transport-btn.play-btn svg { width: 27px; height: 27px; fill: currentColor; }
.jump-btn span { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 3px; font-size: 8px; font-weight: 800; }
.transport-btn svg[hidden], .mini-player svg[hidden] { display: none; }

.transport-btn.play-btn {
  width: 62px;
  height: 62px;
  background: #fff;
  color: #000;
  font-size: 1.2rem;
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.18);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.control-row input {
  flex: 1;
}

.soft-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 0.69rem;
  font-weight: 700;
  white-space: nowrap;
}

.soft-btn.active {
  color: var(--accent);
  border-color: rgba(168, 185, 169, 0.35);
  background: rgba(168, 185, 169, 0.08);
}

.queue-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
}

/* Pestañas */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(13, 18, 27, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
}

.tab-bar.admin-mode {
  grid-template-columns: repeat(4, 1fr);
}

.tab-btn,
.subtab-btn {
  min-height: 40px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.tab-btn.active,
.subtab-btn.active {
  background: var(--accent);
  color: #001018;
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.heading-actions {
  display: flex;
  gap: 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.library-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 60px;
}

.list-empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
}

.track-row,
.queue-row,
.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
}

.track-row:active,
.queue-row:active {
  background: var(--card-hover);
}

.queue-row.current {
  background: rgba(168, 185, 169, 0.1);
  border-color: rgba(168, 185, 169, 0.25);
}

.row-index {
  width: 22px;
  text-align: center;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.66rem;
  flex-shrink: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.row-side {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.auth-pill {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(0, 230, 118, 0.1);
  color: var(--success);
  border: 1px solid rgba(0, 230, 118, 0.25);
}

.auth-pill.locked {
  background: rgba(255, 176, 32, 0.1);
  color: var(--warning);
  border-color: rgba(255, 176, 32, 0.25);
}

.row-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 0.65rem;
  font-weight: 800;
}

.row-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.row-btn.danger {
  color: var(--danger);
}

.row-btn.success {
  color: var(--success);
}

/* Controles cómodos para pantallas táctiles. */
.track-row { flex-wrap: wrap; }
.track-row .row-main { flex: 1 1 calc(100% - 40px); }
.track-row .row-side { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
.row-title, .row-sub { white-space: normal; overflow-wrap: anywhere; }
.row-title { font-size: .95rem; }
.row-sub { font-size: .78rem; line-height: 1.4; }
.row-btn { min-height: 44px; min-width: 44px; font-size: .75rem; }
.queue-row { position: relative; flex-wrap: nowrap; gap: 4px; padding: 6px; }
.queue-row .row-main { flex: 1 1 0; }
.queue-row .drag-handle, .queue-row .queue-remove { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; background: transparent; border: 0; }
.queue-row .drag-handle { touch-action: none; cursor: grab; color: var(--muted); }
.queue-row .queue-remove { color: var(--danger); }
.queue-row button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.queue-row.drag-source { opacity: .35; }
.queue-row.drop-before::before, .queue-row.drop-after::after { content: ''; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 8px rgba(168, 185, 169, .45); z-index: 101; }
.queue-row.drop-before::before { top: -4px; }
.queue-row.drop-after::after { bottom: -4px; }
.queue-drag-preview { position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none; display: grid; gap: 3px; padding: 11px 16px; border: 1px solid var(--accent); border-radius: 9px; background: var(--card-hover); color: var(--text); box-shadow: 0 10px 24px rgba(0, 0, 0, .5); }
.queue-drag-preview strong { font-size: .95rem; overflow-wrap: anywhere; }
.queue-drag-preview span { font-size: .78rem; color: var(--muted); }
.playback-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.playback-options label { display: grid; gap: 6px; color: var(--muted); font-size: .8rem; }
.playback-options .soft-btn { min-height: 46px; font-size: .8rem; }
.remote-equalizer { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.remote-equalizer summary { min-height: 44px; cursor: pointer; font-weight: 700; }
.remote-equalizer label { display: grid; gap: 5px; color: var(--muted); font-size: .8rem; }
.eq-bands { display: grid; gap: 10px; margin-top: 14px; }
.eq-bands label { grid-template-columns: 52px 1fr 45px; align-items: center; }
.eq-bands input { width: 100%; min-height: 44px; accent-color: var(--accent); }
.tab-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tab-btn svg, .mini-player svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mini-player { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 4px; background: var(--bg); }
.mini-player button { display: grid; place-items: center; min-width: 48px; min-height: 48px; color: var(--text); background: var(--card); border-radius: 50%; }
.mini-player div { min-width: 0; flex: 1; display: grid; gap: 3px; }
.mini-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-player span { font-size: .75rem; color: var(--muted); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.queue-playlist-row {
  display: flex;
}
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.secondary-btn {
  min-height: 42px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
}

/* Admin */
.subtab-bar {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 9px;
}

.subtab-btn {
  flex: 1;
}

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.admin-form {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.admin-form h3 {
  margin: 0 0 9px;
  font-size: 0.82rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-bottom: 8px;
}

.user-row .row-main {
  min-width: 0;
}

.role-chip {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(168, 185, 169, 0.1);
  color: var(--accent);
}

.role-chip.admin {
  background: rgba(255, 0, 127, 0.1);
  color: #ff5fa8;
}

@media (min-width: 680px) {
  .remote-main {
    padding-top: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .library-filters {
    flex-direction: row;
  }

  .library-filters .select-input {
    width: 210px;
  }
}

/* Identidad compartida con el reproductor principal. */
:root {
  --bg: #141514;
  --surface: #1b1d1b;
  --card: #242724;
  --card-hover: #303430;
  --border: rgba(235, 239, 234, .12);
  --text: #f0f1ee;
  --muted: #b5bdb4;
  --accent: #a8b9a9;
  --accent-2: #879e8b;
  --success: #a8b9a9;
}
html, body { background: var(--bg); }
.remote-header, .gate-card, .panel { background: var(--surface); box-shadow: none; }
.gate-card { border-radius: 14px; }
.brand-mark, .primary-btn { background: var(--accent); color: #162018; box-shadow: none; }
.tab-btn.active, .subtab-btn.active { box-shadow: none; }
.field input, .text-input, .select-input { background: #202320; }
.gate-hint { color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid #d2ded3; outline-offset: 2px; }
.tab-btn, .icon-btn, .soft-btn, .transport-btn { min-height: 44px; }
.remote-main { min-width: 0; }
.list-container, .panel, .remote-header { min-width: 0; }
@media (max-width: 360px) {
  .remote-header { padding-left: 12px; padding-right: 12px; }
  .remote-main { padding-left: 12px; padding-right: 12px; }
  .control-row, .transport-row { gap: 4px; }
  .tab-btn { padding-left: 5px; padding-right: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
