/* Delysium ERP 1.0.157 - Compatibilidad visual global para TODOS los temas
   Cubre temas claros y oscuros en todos los modulos existentes.
   No redefine paletas: usa las variables actuales de cada tema.
*/

/* Base universal: si la clase del tema vive en html o en body, todo hereda bien */
html[class*="erp-theme-"],
html[class*="erp-theme-"] body,
body[class*="erp-theme-"]{
  background:var(--erp-gradient-soft)!important;
  color:var(--erp-text)!important;
  min-height:100%;
}

html[class*="erp-theme-"] body{
  color:var(--erp-text)!important;
}

/* Contenedores principales comunes */
html[class*="erp-theme-"] body .main-content,
html[class*="erp-theme-"] body main,
html[class*="erp-theme-"] body .container-form,
html[class*="erp-theme-"] body .main-container,
html[class*="erp-theme-"] body .wrapper,
html[class*="erp-theme-"] body .page-wrapper,
html[class*="erp-theme-"] body .content-wrapper{
  color:var(--erp-text)!important;
}

/* Superficies: tarjetas, paneles, boxes, modales y acordeones */
html[class*="erp-theme-"] body .card,
html[class*="erp-theme-"] body .card-body,
html[class*="erp-theme-"] body .card-footer,
html[class*="erp-theme-"] body .panel,
html[class*="erp-theme-"] body .box,
html[class*="erp-theme-"] body .well,
html[class*="erp-theme-"] body .modal-content,
html[class*="erp-theme-"] body .modal-header,
html[class*="erp-theme-"] body .modal-body,
html[class*="erp-theme-"] body .modal-footer,
html[class*="erp-theme-"] body .accordion-item,
html[class*="erp-theme-"] body .accordion-body,
html[class*="erp-theme-"] body .accordion-button,
html[class*="erp-theme-"] body .dropdown-menu,
html[class*="erp-theme-"] body .list-group-item,
html[class*="erp-theme-"] body .toast,
html[class*="erp-theme-"] body .offcanvas,
html[class*="erp-theme-"] body .tab-content,
html[class*="erp-theme-"] body .table-responsive,
html[class*="erp-theme-"] body .form-container,
html[class*="erp-theme-"] body .search-box,
html[class*="erp-theme-"] body .filter-box,
html[class*="erp-theme-"] body .summary-box,
html[class*="erp-theme-"] body .stats-card,
html[class*="erp-theme-"] body .metric,
html[class*="erp-theme-"] body .metric-card,
html[class*="erp-theme-"] body .info-card,
html[class*="erp-theme-"] body .notas-info-card,
html[class*="erp-theme-"] body .notas-form-card,
html[class*="erp-theme-"] body .social-card,
html[class*="erp-theme-"] body .social-panel,
html[class*="erp-theme-"] body .bk-stat,
html[class*="erp-theme-"] body .bk-hero,
html[class*="erp-theme-"] body .mm-card,
html[class*="erp-theme-"] body .mm-panel,
html[class*="erp-theme-"] body .sedes-card,
html[class*="erp-theme-"] body .inv-sub-card,
html[class*="erp-theme-"] body .inv-sub-table-card,
html[class*="erp-theme-"] body .ventas-report-card,
html[class*="erp-theme-"] body .ventas-report-table-card,
html[class*="erp-theme-"] body .chart-card{
  background:var(--erp-surface)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

/* Encabezados internos de tarjetas/paneles */
html[class*="erp-theme-"] body .card-header,
html[class*="erp-theme-"] body .panel-heading,
html[class*="erp-theme-"] body .table-header,
html[class*="erp-theme-"] body .section-header,
html[class*="erp-theme-"] body .modal-header,
html[class*="erp-theme-"] body .accordion-header,
html[class*="erp-theme-"] body .inv-sub-table-head,
html[class*="erp-theme-"] body .ventas-report-table-head{
  background:var(--erp-surface-2)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

/* Texto global: evitar negros/blancos hardcodeados ilegibles */
html[class*="erp-theme-"] body h1,
html[class*="erp-theme-"] body h2,
html[class*="erp-theme-"] body h3,
html[class*="erp-theme-"] body h4,
html[class*="erp-theme-"] body h5,
html[class*="erp-theme-"] body h6,
html[class*="erp-theme-"] body p,
html[class*="erp-theme-"] body label,
html[class*="erp-theme-"] body span,
html[class*="erp-theme-"] body small,
html[class*="erp-theme-"] body strong,
html[class*="erp-theme-"] body b,
html[class*="erp-theme-"] body li,
html[class*="erp-theme-"] body td,
html[class*="erp-theme-"] body th,
html[class*="erp-theme-"] body div:not(.badge):not(.btn):not([class*="icon"]){
  color:inherit;
}

html[class*="erp-theme-"] body .text-muted,
html[class*="erp-theme-"] body .muted,
html[class*="erp-theme-"] body .help-text,
html[class*="erp-theme-"] body .field-help,
html[class*="erp-theme-"] body .form-text,
html[class*="erp-theme-"] body .small,
html[class*="erp-theme-"] body small{
  color:var(--erp-muted)!important;
  opacity:1!important;
}

/* Formularios */
html[class*="erp-theme-"] body input,
html[class*="erp-theme-"] body select,
html[class*="erp-theme-"] body textarea,
html[class*="erp-theme-"] body .form-control,
html[class*="erp-theme-"] body .form-select,
html[class*="erp-theme-"] body .input-group-text,
html[class*="erp-theme-"] body .select2-selection,
html[class*="erp-theme-"] body .choices,
html[class*="erp-theme-"] body .choices__inner{
  background:var(--erp-input)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body input::placeholder,
html[class*="erp-theme-"] body textarea::placeholder{
  color:var(--erp-muted)!important;
  opacity:.78!important;
}

html[class*="erp-theme-"] body input:focus,
html[class*="erp-theme-"] body select:focus,
html[class*="erp-theme-"] body textarea:focus,
html[class*="erp-theme-"] body .form-control:focus,
html[class*="erp-theme-"] body .form-select:focus{
  background:var(--erp-input)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-primary)!important;
  box-shadow:var(--erp-focus)!important;
}

/* Inputs readonly/disabled */
html[class*="erp-theme-"] body input[readonly],
html[class*="erp-theme-"] body input:disabled,
html[class*="erp-theme-"] body select:disabled,
html[class*="erp-theme-"] body textarea:disabled,
html[class*="erp-theme-"] body .form-control:disabled{
  background:var(--erp-surface-2)!important;
  color:var(--erp-muted)!important;
  border-color:var(--erp-border)!important;
  opacity:1!important;
}

/* Tablas: todas las variantes, temas claros y oscuros */
html[class*="erp-theme-"] body table,
html[class*="erp-theme-"] body .table{
  --bs-table-bg:var(--erp-surface)!important;
  --bs-table-color:var(--erp-text)!important;
  --bs-table-striped-bg:var(--erp-surface-2)!important;
  --bs-table-striped-color:var(--erp-text)!important;
  --bs-table-hover-bg:color-mix(in srgb,var(--erp-primary) 12%, var(--erp-surface-2))!important;
  --bs-table-hover-color:var(--erp-text)!important;
  background:var(--erp-surface)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body table thead,
html[class*="erp-theme-"] body table thead tr,
html[class*="erp-theme-"] body table thead th,
html[class*="erp-theme-"] body .table thead,
html[class*="erp-theme-"] body .table thead tr,
html[class*="erp-theme-"] body .table thead th{
  background:color-mix(in srgb,var(--erp-primary) 18%, var(--erp-surface-2))!important;
  color:var(--erp-heading)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body table tbody tr,
html[class*="erp-theme-"] body .table tbody tr{
  background:var(--erp-surface)!important;
  color:var(--erp-text)!important;
}

html[class*="erp-theme-"] body table tbody tr:nth-child(even),
html[class*="erp-theme-"] body .table tbody tr:nth-child(even){
  background:var(--erp-surface-2)!important;
  color:var(--erp-text)!important;
}

html[class*="erp-theme-"] body table tbody tr:hover,
html[class*="erp-theme-"] body .table tbody tr:hover{
  background:color-mix(in srgb,var(--erp-primary) 12%, var(--erp-surface-2))!important;
  color:var(--erp-text)!important;
}

html[class*="erp-theme-"] body table td,
html[class*="erp-theme-"] body table th,
html[class*="erp-theme-"] body .table td,
html[class*="erp-theme-"] body .table th{
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body table td *,
html[class*="erp-theme-"] body .table td *{
  color:inherit;
}

/* Alertas: conservar intención sin romper tema */
html[class*="erp-theme-"] body .alert{
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body .alert-info{
  background:color-mix(in srgb,var(--erp-info) 13%, var(--erp-surface))!important;
}
html[class*="erp-theme-"] body .alert-success{
  background:color-mix(in srgb,var(--erp-success) 13%, var(--erp-surface))!important;
}
html[class*="erp-theme-"] body .alert-warning{
  background:color-mix(in srgb,var(--erp-warning) 15%, var(--erp-surface))!important;
}
html[class*="erp-theme-"] body .alert-danger{
  background:color-mix(in srgb,var(--erp-danger) 13%, var(--erp-surface))!important;
}
html[class*="erp-theme-"] body .alert-secondary,
html[class*="erp-theme-"] body .alert-light,
html[class*="erp-theme-"] body .alert-dark{
  background:var(--erp-surface-2)!important;
}

/* Botones: respetar clases Bootstrap, solo garantizar contraste */
html[class*="erp-theme-"] body .btn-primary,
html[class*="erp-theme-"] body button.btn-primary,
html[class*="erp-theme-"] body input[type="submit"].btn-primary{
  background:var(--erp-gradient-main)!important;
  border-color:var(--erp-primary)!important;
  color:#fff!important;
}

html[class*="erp-theme-"] body .btn-outline-primary{
  color:var(--erp-primary)!important;
  border-color:var(--erp-primary)!important;
  background:transparent!important;
}

html[class*="erp-theme-"] body .btn-outline-primary:hover{
  background:var(--erp-primary)!important;
  color:#fff!important;
}

html[class*="erp-theme-"] body .btn-secondary,
html[class*="erp-theme-"] body .btn-outline-secondary{
  border-color:var(--erp-border)!important;
}

/* Badges y chips */
html[class*="erp-theme-"] body .badge,
html[class*="erp-theme-"] body .badge-soft,
html[class*="erp-theme-"] body .chip,
html[class*="erp-theme-"] body .pill,
html[class*="erp-theme-"] body .status-badge{
  border-color:var(--erp-border)!important;
}

/* Links */
html[class*="erp-theme-"] body a:not(.btn):not(.nav-link):not(.dropdown-item){
  color:var(--erp-primary)!important;
}
html[class*="erp-theme-"] body a:not(.btn):not(.nav-link):not(.dropdown-item):hover{
  color:var(--erp-primary-2)!important;
}

/* Tabs/navs internos */
html[class*="erp-theme-"] body .nav-tabs,
html[class*="erp-theme-"] body .nav-pills,
html[class*="erp-theme-"] body .tabs,
html[class*="erp-theme-"] body .social-tabs{
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body .nav-tabs .nav-link,
html[class*="erp-theme-"] body .tab,
html[class*="erp-theme-"] body .social-tab{
  background:var(--erp-surface-2)!important;
  color:var(--erp-text)!important;
  border-color:var(--erp-border)!important;
}

html[class*="erp-theme-"] body .nav-tabs .nav-link.active,
html[class*="erp-theme-"] body .tab.active,
html[class*="erp-theme-"] body .social-tab.active{
  background:var(--erp-gradient-main)!important;
  color:#fff!important;
  border-color:var(--erp-primary)!important;
}

/* Charts/canvas wrappers */
html[class*="erp-theme-"] body canvas{
  color:var(--erp-text)!important;
}

/* Scrollbars en navegadores webkit */
html[class*="erp-theme-"] body ::-webkit-scrollbar{
  width:10px;
  height:10px;
}
html[class*="erp-theme-"] body ::-webkit-scrollbar-track{
  background:var(--erp-surface-2);
}
html[class*="erp-theme-"] body ::-webkit-scrollbar-thumb{
  background:color-mix(in srgb,var(--erp-primary) 34%, var(--erp-muted));
  border-radius:999px;
}

/* Evitar bloques blancos heredados por clases inline antiguas */
html[class*="erp-theme-"] body [style*="background:#fff"],
html[class*="erp-theme-"] body [style*="background: #fff"],
html[class*="erp-theme-"] body [style*="background:white"],
html[class*="erp-theme-"] body [style*="background: white"],
html[class*="erp-theme-"] body [style*="background-color:#fff"],
html[class*="erp-theme-"] body [style*="background-color: #fff"],
html[class*="erp-theme-"] body [style*="background-color:white"],
html[class*="erp-theme-"] body [style*="background-color: white"]{
  background:var(--erp-surface)!important;
  color:var(--erp-text)!important;
}

/* Evitar texto negro/blanco fijo cuando contradice el tema */
html[class*="erp-theme-"] body [style*="color:#000"],
html[class*="erp-theme-"] body [style*="color: #000"],
html[class*="erp-theme-"] body [style*="color:black"],
html[class*="erp-theme-"] body [style*="color: black"]{
  color:var(--erp-text)!important;
}

html[class*="erp-theme-"] body [style*="color:#fff"],
html[class*="erp-theme-"] body [style*="color: #fff"],
html[class*="erp-theme-"] body [style*="color:white"],
html[class*="erp-theme-"] body [style*="color: white"]{
  color:var(--erp-heading)!important;
}

/* Modo impresion: no afectar comprobantes al imprimir */
@media print{
  html[class*="erp-theme-"] body,
  html[class*="erp-theme-"] body *{
    box-shadow:none!important;
  }
}
