/* Delysium ERP 1.0.140 - Compatibilidad visual integral modulo por modulo
   Capa final para todo el sistema. No cambia logica, SQL ni estructura.
*/

/* Variables de respaldo para paginas que no cargan body.erp-theme-* */
:root{
  --erp-bg:#f4f7fb;
  --erp-bg-2:#e9eef6;
  --erp-surface:#ffffff;
  --erp-surface-2:#f1f5f9;
  --erp-surface-3:#e2e8f0;
  --erp-input:#ffffff;
  --erp-text:#0f172a;
  --erp-heading:#0f172a;
  --erp-muted:#64748b;
  --erp-primary:#2563eb;
  --erp-primary-2:#1d4ed8;
  --erp-accent:#0f766e;
  --erp-success:#15803d;
  --erp-warning:#b45309;
  --erp-danger:#b91c1c;
  --erp-info:#0369a1;
  --erp-border:rgba(15,23,42,.14);
  --erp-shadow-color:rgba(15,23,42,.10);
  --erp-radius:16px;
  --erp-radius-sm:12px;
  --erp-radius-lg:22px;
  --erp-shadow-sm:0 6px 18px var(--erp-shadow-color);
  --erp-shadow:0 14px 38px var(--erp-shadow-color);
  --erp-shadow-lg:0 24px 70px var(--erp-shadow-color);
  --erp-gradient-main:linear-gradient(135deg,var(--erp-primary),var(--erp-primary-2));
  --erp-gradient-soft:linear-gradient(180deg,var(--erp-bg),var(--erp-bg-2));
  --erp-focus:0 0 0 .2rem color-mix(in srgb,var(--erp-primary) 22%, transparent);
}

html, body{
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* Base general para modulos directos y modulos con header */
body{
  color:var(--erp-text) !important;
  background:var(--erp-gradient-soft) !important;
}

body,
body p,
body span,
body div,
body li,
body td,
body th,
body label,
body .form-label,
body .col-form-label,
body .form-check-label{
  opacity:1 !important;
}

body h1,
body h2,
body h3,
body h4,
body h5,
body h6{
  color:var(--erp-heading,var(--erp-text)) !important;
  opacity:1 !important;
  font-weight:900;
}

body .text-muted,
body small,
body .small,
body .form-text,
body .help-text,
body .hint,
body .descripcion,
body .description,
body .subtext,
body .muted{
  color:var(--erp-muted) !important;
  opacity:1 !important;
}

body a:not(.btn){
  color:var(--erp-primary) !important;
}
body a:not(.btn):hover{
  color:var(--erp-primary-2) !important;
}

/* Superficies por modulo */
body :where(.card,.panel,.section,.container-form,.form-container,.module-card,.dashboard-card,.metric-card,.box,.table-container,.mm-card,.social-card,.pwa-card,.caja-card,.cliente360-card,.erp-card,.card-erp,.content-card,.page-card,.widget,.module,.list-group-item,.accordion-item,.dropdown-menu,.offcanvas,.modal-content){
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

body :where(.card,.panel,.section,.container-form,.form-container,.module-card,.dashboard-card,.metric-card,.box,.table-container,.mm-card,.social-card,.pwa-card,.caja-card,.cliente360-card,.erp-card,.card-erp,.content-card,.page-card,.widget,.module){
  border:1px solid var(--erp-border) !important;
  border-radius:var(--erp-radius) !important;
  box-shadow:var(--erp-shadow) !important;
}

body :where(.card-header,.card-footer,.panel-heading,.modal-header,.modal-footer,.offcanvas-header,.accordion-header,.list-group-item.active){
  background:var(--erp-surface-2) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

body :where(.card-body,.panel-body,.modal-body,.offcanvas-body,.accordion-body,.dropdown-menu){
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
}

/* Cualquier texto dentro de tarjetas/paneles/modales debe heredar y verse */
body :where(.card,.panel,.section,.container-form,.form-container,.modal-content,.offcanvas,.dropdown-menu,.accordion-item,.table-container) :where(p,span,div,label,strong,em,b,li,td,th,h1,h2,h3,h4,h5,h6){
  color:inherit !important;
  opacity:1 !important;
}

/* Formularios globales */
body :where(input,select,textarea,.form-control,.form-select,.input-group-text){
  background:var(--erp-input) !important;
  color:var(--erp-text) !important;
  border:1px solid var(--erp-border) !important;
  border-radius:12px !important;
  box-shadow:none !important;
  opacity:1 !important;
}

body :where(input,textarea)::placeholder{
  color:color-mix(in srgb,var(--erp-muted) 76%, transparent) !important;
  opacity:1 !important;
}

body :where(input,select,textarea,.form-control,.form-select):focus{
  border-color:var(--erp-primary) !important;
  box-shadow:var(--erp-focus) !important;
  outline:0 !important;
}

body :where(input[readonly],.form-control[readonly],input:disabled,select:disabled,textarea:disabled,.form-control:disabled,.form-select:disabled){
  background:color-mix(in srgb,var(--erp-input) 74%, var(--erp-surface-2)) !important;
  color:color-mix(in srgb,var(--erp-text) 84%, var(--erp-muted)) !important;
  opacity:1 !important;
}

body option{
  background:var(--erp-input) !important;
  color:var(--erp-text) !important;
}

/* Botones globales */
body :where(.btn,button:not(.btn-close):not(.navbar-toggler)){
  border-radius:12px !important;
  font-weight:850;
  opacity:1 !important;
}

body :where(.btn-primary,.btn-success,button.btn-primary,button.btn-success,.pwa-btn-primary,#btn-registrar,#btn-mostrar-equipo){
  background:var(--erp-gradient-main) !important;
  border-color:transparent !important;
  color:#ffffff !important;
}

body :where(.btn-primary,.btn-success,button.btn-primary,button.btn-success,.pwa-btn-primary,#btn-registrar,#btn-mostrar-equipo) *{
  color:#ffffff !important;
}

body :where(.btn-secondary,.btn-outline-secondary){
  background:var(--erp-surface-2) !important;
  border-color:var(--erp-border) !important;
  color:var(--erp-text) !important;
}

body :where(.btn-secondary,.btn-outline-secondary) *{
  color:var(--erp-text) !important;
}

body :where(.btn-outline-primary){
  color:var(--erp-primary) !important;
  background:color-mix(in srgb,var(--erp-primary) 6%, transparent) !important;
  border-color:color-mix(in srgb,var(--erp-primary) 42%, var(--erp-border)) !important;
}

body :where(.btn-outline-primary):hover{
  background:var(--erp-primary) !important;
  color:#ffffff !important;
}

body :where(.btn-danger){
  background:var(--erp-danger) !important;
  border-color:var(--erp-danger) !important;
  color:#ffffff !important;
}

body :where(.btn-warning){
  background:var(--erp-warning) !important;
  border-color:var(--erp-warning) !important;
  color:#111827 !important;
}

body :where(.btn:disabled,button:disabled){
  opacity:.72 !important;
  cursor:not-allowed !important;
}

/* Tablas y listados */
body :where(table,.table){
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
  background:var(--erp-surface) !important;
}

body :where(table th,.table th,thead th){
  background:color-mix(in srgb,var(--erp-primary) 12%, var(--erp-surface-2)) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
  font-weight:900 !important;
}

body :where(table td,.table td){
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

body :where(table tr:nth-child(even) td,.table tr:nth-child(even) td){
  background:color-mix(in srgb,var(--erp-surface-2) 62%, var(--erp-surface)) !important;
}

body :where(table tr:hover td,.table tr:hover td){
  background:color-mix(in srgb,var(--erp-primary) 7%, var(--erp-surface)) !important;
}

/* Alertas y estados */
body .alert{
  border-radius:var(--erp-radius-sm) !important;
  border:1px solid var(--erp-border) !important;
  color:var(--erp-text) !important;
  opacity:1 !important;
}

body .alert-success{background:color-mix(in srgb,var(--erp-success) 13%, var(--erp-surface)) !important;}
body .alert-danger{background:color-mix(in srgb,var(--erp-danger) 13%, var(--erp-surface)) !important;}
body .alert-warning{background:color-mix(in srgb,var(--erp-warning) 16%, var(--erp-surface)) !important;}
body .alert-info{background:color-mix(in srgb,var(--erp-info) 13%, var(--erp-surface)) !important;}

body .badge{
  border-radius:999px !important;
  font-weight:900 !important;
}

/* Header y navegación */
body :where(header,.navbar,.topbar,.erp-header-shell){
  background:color-mix(in srgb,var(--erp-surface) 92%, var(--erp-primary) 8%) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

body :where(header,.navbar,.topbar,.erp-header-shell) *{
  color:var(--erp-text) !important;
}

body :where(header,.navbar,.topbar,.erp-header-shell) i{
  color:var(--erp-accent) !important;
}

/* Iconos */
body :where(.fa,.fas,.far,.fab,.bi){
  color:var(--erp-accent) !important;
}

/* Modulos especificos */
body :where(.ventas-pro-1-0-14,.inventario-kardex,.diagnostico-ui,.mm-wrap,.social-shell,.pwa-mobile-app,.caja-pro,.backup-panel,.verificador-panel,.auditoria-panel,.cliente360,.trazabilidad-panel,.garantia-panel){
  color:var(--erp-text) !important;
}

body :where(.ventas-pro-1-0-14,.inventario-kardex,.diagnostico-ui,.mm-wrap,.social-shell,.pwa-mobile-app,.caja-pro,.backup-panel,.verificador-panel,.auditoria-panel,.cliente360,.trazabilidad-panel,.garantia-panel) :where(.card,.panel,.box,.section,.table-container){
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

/* Registro clientes y formularios publicos */
body.registro-clientes-pro-1-0-17,
body.erp-public-form-page{
  color:var(--erp-text) !important;
}

body.registro-clientes-pro-1-0-17 :where(.container-form,#registro-cliente-section,#registro-equipo-section),
body.erp-public-form-page :where(.container-form,#registro-cliente-section,#registro-equipo-section,.erp-card,.card-erp){
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

body.registro-clientes-pro-1-0-17 :where(label,h1,h2,h3,h4,h5,h6,p,span,div,small),
body.erp-public-form-page :where(label,h1,h2,h3,h4,h5,h6,p,span,div,small){
  opacity:1 !important;
}

body.registro-clientes-pro-1-0-17 :where(label,h1,h2,h3,h4,h5,h6,p,span,div),
body.erp-public-form-page :where(label,h1,h2,h3,h4,h5,h6,p,span,div){
  color:var(--erp-text) !important;
}

body.registro-clientes-pro-1-0-17 :where(small,.form-text,.text-muted),
body.erp-public-form-page :where(small,.form-text,.text-muted){
  color:var(--erp-muted) !important;
}

/* Panel Informacion y cambio de usuario */
.registro-info-card,
.erp-switch-user-card{
  background:var(--erp-surface) !important;
  color:var(--erp-text) !important;
  border:1px solid var(--erp-border) !important;
  box-shadow:var(--erp-shadow-lg) !important;
}

.registro-info-card *,
.erp-switch-user-card *{
  opacity:1 !important;
}

.registro-info-card :where(h1,h2,h3,h4,h5,h6,p,span,div,strong,label),
.erp-switch-user-card :where(h1,h2,h3,h4,h5,h6,p,span,div,strong,label){
  color:var(--erp-text) !important;
}

.registro-info-card :where(small,.text-muted,.form-text),
.erp-switch-user-card :where(small,.text-muted,.form-text){
  color:var(--erp-muted) !important;
}

.registro-info-foot .btn-primary,
.registro-info-foot .btn-primary *,
.erp-switch-user-foot .btn-primary,
.erp-switch-user-foot .btn-primary *{
  color:#ffffff !important;
}

body.erp-theme-neon .registro-info-card,
body.erp-theme-carbon .registro-info-card,
body.erp-theme-grafito .registro-info-card,
body.erp-theme-medianoche .registro-info-card,
body.erp-theme-morado .registro-info-card,
body.erp-theme-neon .erp-switch-user-card,
body.erp-theme-carbon .erp-switch-user-card,
body.erp-theme-grafito .erp-switch-user-card,
body.erp-theme-medianoche .erp-switch-user-card,
body.erp-theme-morado .erp-switch-user-card{
  background:#111827 !important;
  color:#f8fafc !important;
}

body.erp-theme-neon .registro-info-card *,
body.erp-theme-carbon .registro-info-card *,
body.erp-theme-grafito .registro-info-card *,
body.erp-theme-medianoche .registro-info-card *,
body.erp-theme-morado .registro-info-card *,
body.erp-theme-neon .erp-switch-user-card *,
body.erp-theme-carbon .erp-switch-user-card *,
body.erp-theme-grafito .erp-switch-user-card *,
body.erp-theme-medianoche .erp-switch-user-card *,
body.erp-theme-morado .erp-switch-user-card *{
  color:#f8fafc !important;
}

body.erp-theme-neon .registro-info-foot .btn-secondary,
body.erp-theme-carbon .registro-info-foot .btn-secondary,
body.erp-theme-grafito .registro-info-foot .btn-secondary,
body.erp-theme-medianoche .registro-info-foot .btn-secondary,
body.erp-theme-morado .registro-info-foot .btn-secondary{
  background:#475569 !important;
  color:#ffffff !important;
}

/* Multimedia preview, iframes y cajas internas */
body :where(.mm-preview,.social-window,.social-preview,.iframe-box,.preview-box,.upload-box,.dropzone){
  background:var(--erp-surface-2) !important;
  color:var(--erp-text) !important;
  border-color:var(--erp-border) !important;
}

/* Evitar textos blancos sobre fondo blanco en temas claros */
body:not(.erp-theme-neon):not(.erp-theme-carbon):not(.erp-theme-grafito):not(.erp-theme-medianoche):not(.erp-theme-morado) :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-white,.text-light){
  color:var(--erp-text) !important;
}

/* Evitar textos oscuros sobre fondo oscuro en temas oscuros */
body.erp-theme-neon :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-dark),
body.erp-theme-carbon :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-dark),
body.erp-theme-grafito :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-dark),
body.erp-theme-medianoche :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-dark),
body.erp-theme-morado :where(.card,.panel,.section,.container-form,.modal-content,.dropdown-menu) :where(.text-dark){
  color:var(--erp-text) !important;
}
