/* Delysium ERP 1.0.156 - Organizacion visual integral de modulos
   Ajustes solo de orden, centrado, espaciado, ancho, tablas responsive y alineacion.
   No cambia colores ni logica.
*/

:root{
  --erp-layout-max-xs: 760px;
  --erp-layout-max-sm: 980px;
  --erp-layout-max-md: 1180px;
  --erp-layout-max-lg: 1280px;
  --erp-layout-page-pad: clamp(12px, 1.8vw, 24px);
  --erp-layout-gap: clamp(12px, 1.6vw, 20px);
}

/* Base organizativa */
.erp-layout-polish *,
.erp-layout-polish *::before,
.erp-layout-polish *::after,
body[class*="page"] *,
body[class*="page"] *::before,
body[class*="page"] *::after{
  box-sizing:border-box;
}

body.erp-ui-global-1-0-18 .main-content,
body[class*="page"] .main-content,
body .main-content.layout-polished{
  width:100% !important;
  max-width:none !important;
  margin:0 auto !important;
  padding:var(--erp-layout-page-pad) !important;
}

/* Contenedores principales: centrados sin tocar colores */
body .main-content > .container,
body .main-content > .container-fluid,
body .container-form,
body .container-main,
body .page-container,
body .content-wrap,
body .admin-page-wrap,
body .ventas-report-wrap,
body .inv-sub-wrap,
body .sedes-wrap,
body .trazabilidad-wrap,
body .mm-wrap,
body .social-central-wrap,
body .orden-add-wrap,
body .chat-admin-shell,
body .chat-admin-top{
  max-width:var(--erp-layout-max-lg) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body .container-form,
body .container-main,
body .page-container,
body .content-wrap,
body .admin-page-wrap,
body .ventas-report-wrap,
body .inv-sub-wrap,
body .sedes-wrap,
body .trazabilidad-wrap,
body .mm-wrap,
body .social-central-wrap{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
}

/* Tarjetas y bloques con espaciado uniforme */
body .card,
body .panel,
body .box,
body .container-form,
body .container-main,
body .page-card,
body .erp-card,
body .mm-card,
body .mm-panel,
body .social-panel,
body .social-card,
body .sedes-card,
body .inv-sub-card,
body .ventas-report-card,
body .ventas-report-table-card,
body .caja-card,
body .bk-card,
body .theme-card,
body .diagnostico-save-card,
body .trazabilidad-card,
body .orden-card{
  margin-bottom:var(--erp-layout-gap);
}

body .card-body,
body .panel-body,
body .box-body,
body .container-form,
body .page-card,
body .erp-card{
  overflow-wrap:anywhere;
}

/* Formularios ordenados */
body form .row,
body .form-row,
body .filters-row,
body .filter-row,
body .search-row{
  row-gap:var(--erp-layout-gap) !important;
}

body label{
  line-height:1.25;
}

body input,
body select,
body textarea,
body .form-control,
body .form-select{
  max-width:100% !important;
}

body textarea{
  min-height:110px;
  resize:vertical;
}

body .btn,
body button,
body [type="submit"]{
  max-width:100%;
}

/* Tablas: nunca salirse del modulo */
body table{
  max-width:100%;
}

body .table-responsive,
body .table-wrap,
body .scroll-table,
body .ventas-report-scroll,
body .inv-scroll,
body .sedes-table-wrap,
body .social-table-scroll,
body .bk-table-wrap,
body .auditoria-table-wrap,
body .actualizaciones-table-wrap{
  width:100% !important;
  max-width:100% !important;
  overflow-x:auto !important;
  overflow-y:visible !important;
}

/* Encabezados de pagina */
body h1,
body h2,
body h3{
  overflow-wrap:anywhere;
}

body .page-title,
body .section-title,
body .ventas-report-hero,
body .inv-sub-hero,
body .sedes-hero,
body .social-hero,
body .bk-hero,
body .orden-add-title{
  text-align:left;
}

/* Bloque 1 */
body.balance-page .container-form,
body.notas-page .main-content > .container,
body.equipos-page .container-form,
body.social-central-page .social-central-wrap,
body.backups-page .main-content > .container-fluid,
body.marketing-page .container,
body.multimedia-page .mm-wrap,
body.registro-usuarios-page .main-container,
body.egresos-page .main-content > .container,
body.temas-page .main-content{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.notas-page .main-content,
body.equipos-page .main-content,
body.registro-usuarios-page .main-content,
body.egresos-page .main-content{
  padding-left:var(--erp-layout-page-pad) !important;
  padding-right:var(--erp-layout-page-pad) !important;
}

body.notas-page .notas-grid,
body.registro-usuarios-page .usuarios-grid,
body.egresos-page .egresos-grid,
body.marketing-page .marketing-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:var(--erp-layout-gap);
  align-items:start;
}

/* Central Social Bridge: centrado limpio */
body.social-central-page .social-bridge-layout{
  width:100% !important;
  max-width:1120px !important;
  margin-left:auto !important;
  margin-right:auto !important;
  display:grid !important;
  grid-template-columns:1fr !important;
  gap:var(--erp-layout-gap) !important;
}

body.social-central-page .social-bridge-card{
  width:100% !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

/* Backups */
body.backups-page .bk-stats,
body.backups-page .stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:var(--erp-layout-gap);
}

/* Temas */
body.temas-page .container-fluid,
.temas-page.admin-page-wrap .container-fluid{
  max-width:var(--erp-layout-max-lg) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.temas-page .themes-grid,
body.temas-page .theme-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(260px, 1fr));
  gap:var(--erp-layout-gap);
}

body.temas-page .temas-editor-main{
  align-items:start !important;
}

/* Bloque 2 — Ventas y comprobantes */
body.ventas-profesional-page .main-content > .container,
body.erp-registro-ventas-estable .main-content > .container,
body.venta-detalle-page .main-content > .container,
body.factura-page .main-content,
body.cuentas-cobrar-page .main-content > .container,
body.ventas-reportes-page .ventas-report-wrap,
body.cierre-caja-page .receipt,
body.caja-pro-page .main-content > .container-fluid{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.ventas-profesional-page .ventas-layout,
body.ventas-profesional-page .ventas-grid,
body.caja-pro-page .caja-grid,
body.ventas-reportes-page .ventas-report-grid{
  display:grid;
  gap:var(--erp-layout-gap);
  align-items:start;
}

body.ventas-reportes-page .ventas-report-filter,
body.ventas-reportes-page .ventas-report-metrics{
  gap:var(--erp-layout-gap) !important;
}

/* Comprobantes / factura para pantalla */
body.factura-page .main-content,
body.cierre-caja-page .receipt{
  max-width:980px !important;
}

body.factura-page .layout,
body.cierre-caja-page .receipt{
  overflow-wrap:anywhere;
}

/* Bloque 3 — Clientes, diagnostico y taller */
body.home-page .main-content,
body.clientes-page .main-content,
body.registro-clientes-pro-1-0-17 .registro-wrap,
body.diagnostico-page .main-content > .container,
body.garantia-page .main-content > .container,
body.cliente-360-page .main-content > .container,
body.trazabilidad-page .trazabilidad-wrap{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  max-width:var(--erp-layout-max-lg) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.home-page .dashboard-grid,
body.home-page .row,
body.clientes-page .clientes-grid,
body.cliente-360-page .cliente360-grid,
body.trazabilidad-page .trazabilidad-grid{
  row-gap:var(--erp-layout-gap) !important;
}

/* Diagnostico mantiene la alineacion final del filtro */
body.diagnostico-page .diag-admin-sede-box{
  max-width:100% !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

/* Bloque 4 — Inventario */
body.inventario-page .main-content > .container,
body.inventario-submodulo-page .inv-sub-wrap{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.inventario-page .inventario-grid,
body.inventario-submodulo-page .inv-metrics,
body.inventario-submodulo-page .inv-filter-grid{
  gap:var(--erp-layout-gap) !important;
}

/* Bloque 5 — Citas, domicilios y orden del dia */
body.nueva-cita-page .container,
body.citas-programadas-page .main-content > .container,
body.domicilio-page .container,
body.domicilio-programado-page .main-content > .container,
body.orden-dia-page .main-content > .container,
body.orden-dia-add-page .orden-add-wrap{
  width:min(var(--erp-layout-max-md), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  max-width:var(--erp-layout-max-md) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.citas-programadas-page .cards-grid,
body.domicilio-programado-page .cards-grid,
body.orden-dia-page .orden-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:var(--erp-layout-gap);
}

/* Bloque 6 — Chat */
body.chat-client-page{
  min-height:100vh;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  padding:var(--erp-layout-page-pad) !important;
}

body.chat-client-page .chat-wrapper{
  width:min(520px, calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  margin:0 auto !important;
}

body.chat-admin-page .chat-admin-top,
body.chat-admin-page .chat-admin-shell{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

/* Bloque 7 — Administracion y sistema */
body.sedes-page .sedes-wrap,
body.auditoria-page .main-content > .container,
body.verificacion-sistema-page .main-content > .container,
body.verificador-automatizado-page .main-content > .container,
body.actualizaciones-page .container-fluid{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  max-width:var(--erp-layout-max-lg) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.sedes-page .sedes-grid,
body.verificador-automatizado-page .selftest-grid,
body.actualizaciones-page .updates-grid{
  gap:var(--erp-layout-gap) !important;
}

/* Bloque 8 — Reportes */
body.reportes-generales-page .main-content > .container,
body.reportes-generales-page .container,
body.balance-page .container-form{
  width:min(var(--erp-layout-max-lg), calc(100vw - 2 * var(--erp-layout-page-pad))) !important;
  max-width:var(--erp-layout-max-lg) !important;
  margin-left:auto !important;
  margin-right:auto !important;
}

body.reportes-generales-page .row{
  row-gap:var(--erp-layout-gap) !important;
}

body.reportes-generales-page .chart-card{
  display:flex;
  flex-direction:column;
}

/* Botoneras y acciones */
body .actions,
body .button-row,
body .btn-row,
body .form-actions,
body .social-actions,
body .inv-sub-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

body .actions.justify-end,
body .form-actions.justify-end{
  justify-content:flex-end;
}

/* Responsive general */
@media(max-width:1100px){
  body .main-content > .container,
  body .main-content > .container-fluid,
  body .container-form,
  body .container-main,
  body .page-container,
  body .content-wrap,
  body .admin-page-wrap{
    width:calc(100vw - 2 * var(--erp-layout-page-pad)) !important;
  }

  body .row{
    row-gap:var(--erp-layout-gap) !important;
  }
}

@media(max-width:768px){
  :root{
    --erp-layout-page-pad:12px;
  }

  body .main-content{
    padding-left:var(--erp-layout-page-pad) !important;
    padding-right:var(--erp-layout-page-pad) !important;
  }

  body .container-form,
  body .container-main,
  body .page-container,
  body .content-wrap,
  body .admin-page-wrap,
  body .ventas-report-wrap,
  body .inv-sub-wrap,
  body .sedes-wrap,
  body .trazabilidad-wrap,
  body .mm-wrap,
  body .social-central-wrap,
  body .orden-add-wrap{
    width:calc(100vw - 2 * var(--erp-layout-page-pad)) !important;
  }

  body .btn,
  body button[type="submit"]{
    min-height:42px;
  }

  body .actions,
  body .button-row,
  body .btn-row,
  body .form-actions,
  body .social-actions,
  body .inv-sub-actions{
    align-items:stretch;
  }
}
