* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1422;
  --surface: #1a1f33;
  --border: #2a2e3e;
  --gold: #c9a84c;
  --text: #e0e0e0;
  --muted: #888;
  --error: #e84a4a;
  --success: #4ade80;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.gold { color: var(--gold); }
.muted { color: var(--muted); font-size: 0.9rem; }
.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 12px;
  min-height: 20px;
}
.hidden { display: none !important; }
.duplicate-warning {
  color: #d9a441;
  background: rgba(217, 164, 65, 0.12);
  border: 1px solid rgba(217, 164, 65, 0.4);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  margin-top: -6px;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  margin: 0;
}
.checkbox-row code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--gold);
}

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: block;
  margin: 0 auto 16px;
  width: 110px;
  height: 110px;
  object-fit: contain;
  /* sombra sutil dorada detras del logo */
  filter: drop-shadow(0 4px 12px rgba(201, 168, 76, 0.25));
}
.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 1px;
}
.login-card > p {
  text-align: center;
  margin-bottom: 28px;
}

/* ── Main ───────────────────────────────────────────────────────────────── */
.main-view {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

/* Encabezado + buscador fijos mientras se hace scroll en la lista */
.main-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding-top: 24px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.5rem; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.more-menu-wrap {
  position: relative;
}
.more-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.more-menu-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.more-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold);
}

.search-bar {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
}
.search-bar input {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--gold);
}
.search-bar select {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  max-width: 220px;
}
.search-bar select:focus {
  outline: none;
  border-color: var(--gold);
}

/* ── Lista de canciones ─────────────────────────────────────────────────── */
.songs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.song-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  transition: border-color 0.15s;
}
.song-item:hover { border-color: var(--gold); }
.song-info { flex: 1; min-width: 0; }
.song-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-badge {
  font-size: 0.85rem;
}
.song-file {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-actions {
  display: flex;
  gap: 6px;
}
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

/* ── Botones ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost, .btn-icon {
  cursor: pointer;
  font-size: 0.9rem;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 500;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primary {
  background: var(--gold);
  color: var(--bg);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--gold);
}
.btn-icon {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.85rem;
}
.btn-icon:hover { color: var(--gold); }

.catalog-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.catalog-toggle-btn {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  transition: background 0.15s, color 0.15s;
}
.catalog-toggle-btn + .catalog-toggle-btn {
  border-left: 1px solid var(--border);
}
.catalog-toggle-btn.is-active {
  background: var(--gold);
  color: var(--bg);
}
.btn-icon.danger:hover { color: var(--error); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 16px; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="file"] {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
input:focus {
  outline: none;
  border-color: var(--gold);
}
input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-content h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ── PDF Modal (vista previa) ───────────────────────────────────────────── */
.pdf-modal {
  padding: 0;
  z-index: 150;
}
.pdf-modal-content {
  width: 100%;
  height: 100%;
  max-width: 1100px;
  max-height: 95vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pdf-modal-header h2 {
  font-size: 1.1rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.pdf-modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pdf-modal-actions a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.pdf-modal-body {
  flex: 1;
  background: #000;
  min-height: 0;
}
.pdf-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

@media (max-width: 600px) {
  .pdf-modal-content {
    max-height: 100vh;
    border-radius: 0;
  }
  .pdf-modal-header h2 { font-size: 0.95rem; }
}

/* ── Modal Multi-upload ─────────────────────────────────────────────────── */
.bulk-modal-content {
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.bulk-file-label {
  display: block;
  cursor: pointer;
  margin-top: 12px;
}
.bulk-file-label input[type="file"] {
  display: none;
}
.bulk-file-label .btn-primary {
  display: inline-block;
  cursor: pointer;
  text-align: center;
  width: 100%;
}
.bulk-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.bulk-list-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bulk-list-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bulk-list-header-actions select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}
.bulk-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
}
.bulk-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.bulk-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bulk-row-file {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.bulk-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.bulk-row-view,
.bulk-row-replace,
.bulk-row-remove {
  padding: 4px 10px !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
}
.bulk-row-view:hover,
.bulk-row-replace:hover {
  background: var(--surface) !important;
  color: var(--gold) !important;
}
.bulk-row-remove {
  font-size: 0.95rem !important;
  line-height: 1;
}

.voices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.voice-label {
  font-weight: 600;
  width: 70px;
  flex-shrink: 0;
}
.voice-status {
  color: var(--muted);
  font-size: 0.85rem;
  flex: 1;
}
.voice-upload-btn,
.voice-delete-btn {
  padding: 4px 10px !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
}

.english-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.english-row .btn-ghost.danger,
.btn-ghost.danger {
  color: var(--error);
  border-color: var(--error);
}
.lote-fields.hidden { display: none; }
.lote-tipo-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.lote-tipo-btn {
  padding: 14px 10px;
  border-radius: 10px;
  border: 1px solid var(--border, #333);
  background: transparent;
  color: inherit;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}
.lote-tipo-btn:hover { border-color: var(--gold, #d4a945); }
.lote-tipo-btn.is-active {
  border-color: var(--gold, #d4a945);
  background: rgba(212, 169, 69, 0.12);
  font-weight: 600;
}
.bulk-row-remove:hover {
  background: rgba(232, 74, 74, 0.12) !important;
  color: var(--error) !important;
}
.bulk-row-name {
  padding: 8px 10px !important;
  font-size: 0.95rem !important;
}
.bulk-row-category {
  padding: 6px 10px;
  font-size: 0.85rem;
}
.bulk-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.bulk-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bulk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #d4b562);
  transition: width 0.3s;
  width: 0%;
}
.bulk-progress-errors {
  margin-top: 12px;
  padding: 12px;
  background: rgba(232, 74, 74, 0.1);
  border: 1px solid var(--error);
  border-radius: 8px;
  font-size: 0.85rem;
  color: #ff8a8a;
  max-height: 200px;
  overflow-y: auto;
}
.bulk-progress-errors:empty {
  display: none;
}

/* ── Modal Descargar todos ──────────────────────────────────────────────── */
.download-all-modal-content {
  max-width: 520px;
}
.download-info-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--gold);
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  max-width: 90%;
}
.toast.error { border-color: var(--error); }
.toast.success { border-color: var(--success); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: space-between; }
  .song-item { flex-wrap: wrap; }
  .song-actions { width: 100%; justify-content: flex-end; }
}

/* ── Historial de actividad ───────────────────────────────────────────── */
.history-modal-content {
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.history-filters {
  display: flex;
  gap: 8px;
  margin: 14px 0 10px;
  flex-wrap: wrap;
}
.history-filter.is-active {
  border-color: var(--gold);
  color: var(--gold);
}
.history-list {
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-icon {
  flex-shrink: 0;
  font-size: 1.05rem;
  line-height: 1.4;
}
.history-body {
  flex: 1;
  min-width: 0;
}
.history-summary {
  word-break: break-word;
  line-height: 1.4;
}
.history-extra {
  margin-top: 3px;
  font-size: 0.82rem;
  word-break: break-word;
}
.history-date {
  flex-shrink: 0;
  font-size: 0.78rem;
  white-space: nowrap;
  padding-top: 2px;
}
.history-item--error .history-summary { color: var(--error); }

@media (max-width: 520px) {
  .history-item { flex-wrap: wrap; }
  .history-date { width: 100%; padding-left: 30px; }
}

/* Diagnostico de topics de un token */
.token-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

/* Interruptor de disponibilidad en iOS */
.ios-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  margin-right: 4px;
}
.ios-toggle input { cursor: pointer; margin: 0; }
.ios-toggle input:checked + span { color: var(--gold); }
.ios-count { margin-left: 4px; }

.song-category {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--gold);
  background: rgba(201, 168, 76, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Gestion de categorias */
.category-add-form {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
}
.category-add-form input {
  flex: 1;
}
.categories-list {
  overflow-y: auto;
  max-height: 400px;
}
.category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.category-row:last-child { border-bottom: none; }
.category-name {
  flex: 1;
  font-weight: 500;
}
.category-count {
  font-size: 0.85rem;
  min-width: 24px;
  text-align: right;
}

/* Chip de filtro por categoria en la lista principal */
.category-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(201, 168, 76, 0.12);
  border: 1px solid var(--gold);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text);
}
.category-filter-chip strong { color: var(--gold); }
.category-filter-chip button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
}
.category-filter-chip button:hover { color: var(--text); }
.category-name {
  cursor: pointer;
}
.category-name:hover { color: var(--gold); }

/* Gestion de insignias (vitrina de honor) */
.insignia-add-form {
  flex-wrap: wrap;
}
.insignia-add-form input[type="text"] {
  flex: 1;
  min-width: 160px;
}
.insignias-admin-list {
  overflow-y: auto;
  max-height: 400px;
}
.insignia-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.insignia-row:last-child { border-bottom: none; }
.insignia-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}
.insignia-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.insignia-name {
  font-weight: 500;
}
.insignia-ventana {
  font-size: 0.78rem;
}
.insignia-date-label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 2px;
}

/* ── Balance de regalías (compartido entre panel admin y balance.html) ──── */
.balance-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.balance-filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
}
.balance-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.balance-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.balance-card .label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}
.balance-card .value {
  font-size: 1.25rem;
  font-weight: 700;
}
.balance-card.destacado {
  border-color: var(--gold);
}
.balance-card.destacado .value {
  color: var(--gold);
}
.plan-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}
.plan-table th, .plan-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.plan-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
}
.plan-table tr:last-child td { border-bottom: none; }
.section-title {
  margin: 20px 0 10px;
  font-size: 1rem;
  font-weight: 700;
}
