/* SanXerife dark-mode consistency layer.
   Loaded after theme.css on every page so shared and dynamically-created
   components inherit the same palette without page-specific white fallbacks. */

html[data-theme="dark"]{
  --surface:#0d1929;
  --surface-2:#101d30;
  --surface-3:#081321;
  --surface-hover:#17253a;
  --surface-selected:#1b2c45;
  --border:rgba(255,255,255,.12);
  --border-soft:rgba(255,255,255,.08);
  --text-strong:#f3f7fc;
  --text-soft:#d8e2ee;
  --text-muted:#97a8bd;
  --control-bg:#081321;
  --control-disabled-bg:#132238;
  --control-disabled-text:#8292a7;
  --overlay-bg:rgba(2,8,18,.72);
  --focus-color:#d6a94d;
  scrollbar-color:#334155 #0b1524;
}

/* Shared form controls ------------------------------------------------------- */
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select,textarea){
  background-color:var(--control-bg)!important;
  color:var(--text-strong)!important;
  border-color:var(--border)!important;
  caret-color:var(--text-strong);
}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select,textarea):focus{
  border-color:rgba(240,212,134,.68)!important;
  box-shadow:0 0 0 3px rgba(214,169,77,.11)!important;
}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#7f91a8!important;opacity:1}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select,textarea):disabled{
  background-color:var(--control-disabled-bg)!important;
  color:var(--control-disabled-text)!important;
  border-color:var(--border-soft)!important;
  opacity:1!important;
  cursor:not-allowed;
}
html[data-theme="dark"] select option{background:#0d1929;color:#edf3fb}
html[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"]){accent-color:#d6a94d}
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus{
  -webkit-text-fill-color:#edf3fb!important;
  -webkit-box-shadow:0 0 0 1000px #081321 inset!important;
  transition:background-color 9999s ease-out 0s;
}
html[data-theme="dark"] button:disabled{cursor:not-allowed}

/* Generic overlays and dynamically-created surfaces ------------------------- */
html[data-theme="dark"] :is(.modal-card,.dialog-card){
  background-color:var(--surface)!important;
  color:var(--text-strong)!important;
  border-color:var(--border)!important;
}
html[data-theme="dark"] :is(.modal-backdrop,.sx-profile-backdrop,.sx-location-backdrop){background:var(--overlay-bg)!important}
html[data-theme="dark"] :is(.modal-head,.modal-foot,.dialog-head,.dialog-actions){border-color:var(--border-soft)!important}
html[data-theme="dark"] :is(.empty,.note,small){color:var(--text-muted)}

/* Main application details that otherwise keep light-only fills ------------- */
html[data-sx-page="app"][data-theme="dark"] .badge{background:#17253a;color:#cbd5e1}
html[data-sx-page="app"][data-theme="dark"] .badge.RECEBER{background:#102a43;color:#93c5fd}
html[data-sx-page="app"][data-theme="dark"] .badge.GUARDAR{background:#10291f;color:#86efac}
html[data-sx-page="app"][data-theme="dark"] .badge.LIBERAR{background:#31171c;color:#fca5a5}
html[data-sx-page="app"][data-theme="dark"] .badge.DEVOLVER{background:#241b3b;color:#c4b5fd}
html[data-sx-page="app"][data-theme="dark"] .badge.AJUSTAR{background:#302511;color:#fcd34d}
html[data-sx-page="app"][data-theme="dark"] .table-wrap{border-color:var(--border-soft)}
html[data-sx-page="app"][data-theme="dark"] tbody tr:hover td{background:rgba(255,255,255,.018)}

/* Manual Locations editor --------------------------------------------------- */
html[data-theme="dark"] .sx-location-card{
  background:#0d1929!important;
  color:#edf3fb!important;
  border-color:var(--border)!important;
  box-shadow:0 30px 90px rgba(0,0,0,.52)!important;
}
html[data-theme="dark"] .sx-location-head{
  background:#0d1929;
  border-bottom-color:var(--border-soft)!important;
}
html[data-theme="dark"] .sx-location-head h2{color:#f3f7fc}
html[data-theme="dark"] .sx-location-head p{color:#97a8bd!important}
html[data-theme="dark"] .sx-location-close{color:#dbe5ef!important;border-radius:9px}
html[data-theme="dark"] .sx-location-close:hover{background:#17253a!important;color:#fff!important}
html[data-theme="dark"] .sx-location-body{background:#0b1626}
html[data-theme="dark"] .sx-location-list-panel{
  background:#0a1524;
  border-color:var(--border-soft)!important;
}
html[data-theme="dark"] .sx-location-editor-panel{background:#0d1929}
html[data-theme="dark"] .sx-location-item{
  background:#101d30!important;
  color:#e8eef6!important;
  border-color:var(--border-soft)!important;
}
html[data-theme="dark"] .sx-location-item:hover{
  background:#15263c!important;
  border-color:#52677f!important;
  box-shadow:0 0 0 2px rgba(96,165,250,.08)!important;
}
html[data-theme="dark"] .sx-location-item.active{
  background:#17283f!important;
  border-color:#d6a94d!important;
  box-shadow:0 0 0 2px rgba(214,169,77,.12)!important;
}
html[data-theme="dark"] .sx-location-item strong{color:#edf3fb!important}
html[data-theme="dark"] .sx-location-item span{color:#97a8bd!important}
html[data-theme="dark"] .sx-location-badge{background:#20284a!important;color:#c7d2fe!important}
html[data-theme="dark"] .sx-location-badge.off{background:#17253a!important;color:#9fb0c6!important}
html[data-theme="dark"] .sx-location-badge.stock{background:#103124!important;color:#86efac!important}
html[data-theme="dark"] .sx-location-form label{color:#d8e2ee!important}
html[data-theme="dark"] .sx-location-check{color:#d8e2ee!important}
html[data-theme="dark"] .sx-location-check:has(input:disabled){color:#8292a7!important}
html[data-theme="dark"] .sx-location-note{
  background:#101d30!important;
  color:#9fb0c6!important;
  border-color:var(--border-soft)!important;
}
html[data-theme="dark"] .sx-location-note strong{color:#e8eef6!important}
html[data-theme="dark"] .sx-location-empty{color:#91a4bd!important}
html[data-theme="dark"] .sx-location-actions .secondary{
  background:#17253a!important;
  color:#e2e8f0!important;
  border:1px solid var(--border-soft)!important;
}
html[data-theme="dark"] .sx-location-actions .secondary:hover{background:#203149!important}

/* Keep light mode untouched. Printing remains controlled by theme.css. */
@media print{
  html[data-theme="dark"] .sx-location-modal{display:none!important}
}
