body.dark-mode {
  background-color: #121212 !important;
  color: #f0f0f0;
}

body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .list-group-item,
body.dark-mode .border {
  background-color: #1e1e1e !important;
  color: #f0f0f0 !important;
  border-color: #444 !important;
}

body.dark-mode .btn-outline-primary,
body.dark-mode .btn-outline-secondary,
body.dark-mode .btn-outline-danger {
  border-color: #888 !important;
  color: #f0f0f0 !important;
}

.select2-container .select2-selection--single {
  min-height: 50px;
  display: flex;
  align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered img {
  height: 30px;
  width: auto;
  margin-right: 5px;
  vertical-align: middle;
}

.select2-results__option img {
  height: 30px;
  margin-right: 5px;
  vertical-align: middle;
}

body.dark-mode .modal-content {
  background-color: #1e1e1e !important;
  color: #f0f0f0 !important;
  border-color: #444;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  border-color: #333;
}

body.dark-mode .modal .form-control {
  background-color: #2a2a2a !important;
  color: #f0f0f0 !important;
  border-color: #555;
}

body.dark-mode .modal .btn-close {
  filter: invert(1);
}

/* Hide any stray dark-mode toggle if present */
#darkModeToggle { display: none; }

/* Dark mode adjustments for shell/sidebar */
body.app-shell.dark-mode {
  background-color: #0b1020;
  color: #e5e7eb;
}

.sidebar-accordion {
  margin-top: 8px;
}

.sidebar-accordion__toggle {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.06);
  color: #e5e7eb;
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-accordion__panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  display: none;
}

.sidebar-accordion__panel.show { display: block; }

.sidebar-accordion__toggle .chevron {
  font-size: 12px;
}

.form-label-sm {
  font-size: 12px;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.sidebar-accordion input.form-control-sm {
  background: #0b1220;
  color: #e5e7eb;
  border-color: #1f2937;
}

.sidebar-accordion input.form-control-sm:focus {
  background: #0b1220;
  color: #e5e7eb;
}

body.dark-mode .app-main {
  background: #0f172a;
  color: #e5e7eb;
}

body.dark-mode .app-sidebar {
  background: #0b1220;
  color: #e5e7eb;
  box-shadow: 4px 0 16px rgba(0,0,0,0.35);
}

body.dark-mode .card {
  background-color: #111827 !important;
  color: #e5e7eb !important;
  border-color: #1f2937 !important;
}

body.dark-mode .card-header,
body.dark-mode .card-footer {
  background-color: #0f172a !important;
  border-color: #1f2937 !important;
}

body.dark-mode .table {
  color: #e5e7eb;
  background-color: #111827;
}

body.dark-mode .table > :not(caption) > * > * {
  background-color: transparent;
  color: inherit;
  border-color: #1f2937;
}

body.dark-mode .badge.bg-secondary { background-color: #4b5563 !important; }
body.dark-mode .badge.bg-success { background-color: #10b981 !important; }

body.dark-mode .text-muted { color: #9ca3af !important; }


body.dark-mode .sidebar-link {
  color: #e5e7eb;
}

body.dark-mode .sidebar-link:hover,
body.dark-mode .sidebar-link:focus {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

body.dark-mode .container {
  color: #e5e7eb;
}

/* --- App shell with persistent sidebar --- */
body.app-shell {
  display: flex;
  min-height: 100vh;
  background-color: #f7f7f9;
}

.app-sidebar {
  width: 220px;
  background: #0f172a;
  color: #e5e7eb;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px;
  box-shadow: 4px 0 16px rgba(0,0,0,0.08);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-link {
  color: #e5e7eb;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s ease, color 0.2s ease;
  font-weight: 600;
}

.sidebar-link:hover,
.sidebar-link:focus {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.app-main {
  flex: 1;
  background: #fff;
  min-height: 100vh;
}

/* Top sticky bar for global controls */
.top-bar-fixed {
  position: fixed;
  top: 0;
  left: 220px; /* will be adjusted at runtime if sidebar absent */
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 8px 18px;
  background: rgba(15,23,42,0.95);
  color: #e5e7eb;
  z-index: 9999; /* higher to ensure visibility */
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  will-change: left, width;
}

@media (max-width: 992px) {
  .top-bar-fixed { left: 180px; }
}

@media (max-width: 768px) {
  .top-bar-fixed { left: 0; position: fixed; }
}

@media (max-width: 992px) {
  .app-sidebar {
    width: 180px;
  }
}

@media (max-width: 768px) {
  body.app-shell {
    flex-direction: column;
  }
  .app-sidebar {
    position: relative;
    height: auto;
    width: 100%;
    box-shadow: none;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .sidebar-link {
    padding: 8px 10px;
  }
}

/* Sonidos admin grid styles */
.sound-admin-grid {
  gap: 8px;
  width: 100%;
}
.sound-admin-cell {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: rgba(15,23,42,0.25);
}
.sound-admin-label { font-weight: 700; color: #fff; margin-bottom: 6px; text-align:center; }
.sound-admin-file { font-size: 12px; color: #d1d5db; text-align:center; max-width: 100%; }
.sound-admin-actions { position: absolute; bottom: 6px; right: 6px; display:flex; gap:6px; }
.sound-admin-actions .btn { padding: 4px 6px; font-size: 12px; }

/* ensure grid is visible on dark backgrounds */
.sound-admin-cell:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }

/* Pantalla view: force sidebar fixed to avoid movement when main content scrolls */
.pantalla-view {
  margin: 0;
  padding: 0;
}

.pantalla-view .controls-drawer {
  position: relative;
  z-index: 2;
  background: rgba(15,23,42,0.9);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.pantalla-view .overlay-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.pantalla-view .overlay-card h5 { margin: 0 0 8px 0; }

/* Pantalla preview: keep it tall and responsive even when navigated via PJAX */
.pantalla-view .preview-frame {
  width: 100%;
  min-height: 520px;
  height: calc(100vh - 260px);
  max-height: calc(100vh - 140px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: #000;
  box-sizing: border-box;
  display: block;
}

@media (max-width: 768px) {
  .pantalla-view .preview-frame { height: calc(100vh - 320px); }
}

.pantalla-view .app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  /* keep existing visual style */
  background: #0f172a;
  box-shadow: 4px 0 16px rgba(0,0,0,0.35);
}

.pantalla-view .app-main {
  margin-left: 220px; /* match sidebar width */
}

@media (max-width: 992px) {
  .pantalla-view .app-main { margin-left: 180px; }
}

@media (max-width: 768px) {
  .pantalla-view .app-sidebar { position: relative; height: auto; }
  .pantalla-view .app-main { margin-left: 0; }
}
