/* ─── Variables de diseño ─────────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1e1e1e;
  --bg-card-hover: #2a2a2a;
  --accent-red: #e63946;
  --accent-gold: #f4a261;
  --accent-gold-dark: #c97d3e;
  --text-primary: #f1f1f1;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --border: #2e2e2e;
  --border-accent: #3a3a3a;
  --success: #2a9d8f;
  --error: #e63946;
  --warning: #f4a261;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 0 20px rgba(244, 162, 97, 0.15);
  --transition: 0.2s ease;
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ─── Reset y base ────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Tipografía ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
}

h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.6rem); }
h3 { font-size: clamp(1rem, 2.5vw, 1.2rem); }

/* ─── Layout principal ────────────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a0a0a 100%);
  border-bottom: 2px solid var(--accent-red);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(230, 57, 70, 0.2);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(244, 162, 97, 0.6));
}

.logo-text {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

/* ─── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-main);
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-red), #c1121f);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #f04e5a, var(--accent-red));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
  color: #1a0a00;
}

.btn-gold:hover:not(:disabled) {
  background: linear-gradient(135deg, #f7b77a, var(--accent-gold));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(244, 162, 97, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-accent);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent-gold);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--accent-red);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
}

/* ─── Tarjetas ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-accent {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow), var(--shadow-accent);
}

/* ─── Formularios ─────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-main);
  padding: 0.7rem 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-row .form-input {
  flex: 1;
}

/* ─── Sección "Reproduciendo ahora" ──────────────────────────────────────── */
.now-playing {
  background: linear-gradient(135deg, #1a0a00 0%, var(--bg-card) 100%);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow), var(--shadow-accent);
}

.now-playing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent-gold);
  color: #1a0a00;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.now-playing-badge .pulse {
  width: 6px;
  height: 6px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.now-playing-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid var(--border-accent);
}

.now-playing-info {
  flex: 1;
  min-width: 0;
}

.now-playing-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.now-playing-sub {
  font-size: 0.78rem;
  color: var(--accent-gold);
  margin-top: 0.15rem;
}

/* ─── Cola de canciones ───────────────────────────────────────────────────── */
.queue-section {
  margin-top: 1.5rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.queue-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background var(--transition), border-color var(--transition);
}

.queue-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.queue-item.dragging {
  opacity: 0.5;
  border: 2px dashed var(--accent-gold);
}

.queue-item.drag-over {
  border-color: var(--accent-gold);
  background: rgba(244, 162, 97, 0.08);
}

.queue-position {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 1.5rem;
  text-align: center;
}

.queue-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.queue-info {
  flex: 1;
  min-width: 0;
}

.queue-title {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.queue-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.queue-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.25rem;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

/* ─── Resultados de búsqueda ──────────────────────────────────────────────── */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
  margin-top: 0.75rem;
}

.result-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background var(--transition), border-color var(--transition);
}

.result-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.result-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* ─── Mensajes de estado ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.empty-state-sub {
  font-size: 0.85rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.3);
  color: #ff8a8a;
}

.alert-success {
  background: rgba(42, 157, 143, 0.12);
  border: 1px solid rgba(42, 157, 143, 0.3);
  color: #5ecfc4;
}

.alert-warning {
  background: rgba(244, 162, 97, 0.12);
  border: 1px solid rgba(244, 162, 97, 0.3);
  color: var(--accent-gold);
}

/* ─── Spinner / Loading ───────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Badge de posición en cola ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-gold {
  background: rgba(244, 162, 97, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(244, 162, 97, 0.3);
}

.badge-red {
  background: rgba(230, 57, 70, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(230, 57, 70, 0.3);
}

/* ─── Sección de búsqueda ─────────────────────────────────────────────────── */
.search-section {
  margin-top: 1.5rem;
}

/* ─── Panel del operador ──────────────────────────────────────────────────── */
.operator-header {
  background: linear-gradient(135deg, #0a0a1a 0%, var(--bg-secondary) 100%);
  border-bottom: 2px solid var(--accent-gold);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(244, 162, 97, 0.15);
}

.operator-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.operator-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.playback-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.playback-state-badge.playing {
  background: rgba(42, 157, 143, 0.15);
  color: #5ecfc4;
  border: 1px solid rgba(42, 157, 143, 0.3);
}

.playback-state-badge.paused {
  background: rgba(244, 162, 97, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(244, 162, 97, 0.3);
}

/* ─── Pantalla del local (screen.html) ───────────────────────────────────── */
.screen-body {
  background: #000;
  overflow: hidden;
}

#yt-player-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

#yt-player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.screen-overlay.hidden {
  display: none;
}

.screen-overlay-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.screen-overlay-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 800;
  color: #fff;
  text-align: center;
  margin-bottom: 0.5rem;
}

.screen-overlay-sub {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.screen-waiting {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a0a00 0%, #000 70%);
  text-align: center;
  padding: 2rem;
}

.screen-waiting.hidden {
  display: none;
}

.screen-waiting-icon {
  font-size: clamp(4rem, 10vw, 8rem);
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0 30px rgba(244, 162, 97, 0.5));
  animation: float 4s ease-in-out infinite;
}

.screen-waiting-title {
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.screen-waiting-sub {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 2rem;
}

.screen-url {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(244, 162, 97, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 2rem;
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.05em;
  word-break: break-all;
}

.screen-pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.screen-pause-overlay.hidden {
  display: none;
}

.screen-pause-icon {
  font-size: clamp(4rem, 12vw, 8rem);
  opacity: 0.8;
  filter: drop-shadow(0 0 20px rgba(244, 162, 97, 0.6));
}

.screen-disconnect {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  background: rgba(230, 57, 70, 0.9);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.screen-disconnect.hidden {
  display: none;
}

/* ─── Utilidades ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--accent-gold); }
.text-red { color: var(--accent-red); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .operator-header .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .operator-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .result-thumb {
    width: 60px;
    height: 45px;
  }

  .now-playing-thumb {
    width: 52px;
    height: 39px;
  }

  .queue-thumb {
    width: 48px;
    height: 36px;
  }

  .search-row {
    flex-direction: column;
  }

  .queue-actions .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 0 1.5rem;
  }
}

@media (min-width: 1280px) {
  .container {
    padding: 0 2rem;
  }
}
