/* Estilos Principales ERP Scriptum */
html,
body {
  height: 100%;
  min-height: 100%;
}

#view-login {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  align-items: stretch;
}

#view-login > [class*="col-"] {
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html.erp-session #view-login {
  display: none !important;
}

html.erp-session #view-app.erp-app-shell {
  display: flex !important;
}

/* Cascarón: menú a la izquierda, topbar + contenido a la derecha */
#view-app.erp-app-shell {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

#view-app.erp-app-shell:not(.d-none) {
  display: flex !important;
}

#app-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  flex-shrink: 0;
  overflow: hidden;
}

#app-main-column {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

#app-topbar {
  z-index: 20;
}

#main-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#app-sidebar.minimized {
  width: 70px !important;
  min-width: 70px !important;
}

#app-sidebar.minimized .sidebar-text,
#app-sidebar.minimized .submenu-arrow {
  display: none !important;
}

#app-sidebar.minimized #sidebar-build-info {
  display: block !important;
  padding: 0.25rem 0;
}

#app-sidebar.minimized #sidebar-build-info .badge,
#app-sidebar.minimized #sidebar-build-info .font-monospace {
  display: none !important;
}

#app-sidebar.minimized #sidebar-build-info::after {
  content: '⬤';
  font-size: 0.45rem;
  color: rgba(13, 202, 240, 0.85);
}

.sidebar-footer-meta {
  line-height: 1.25;
}

.transition-all {
  transition: width 0.2s ease-in-out, min-width 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1090;
}

.erp-mysql-error-card {
  border-left: 4px solid #dc3545;
}

#app-sidebar.minimized .d-flex.align-items-center {
  justify-content: center !important;
}

#app-sidebar.minimized #sidebar-app-logo {
  margin: 0 auto;
}

#page-title {
  max-width: min(52vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#user-display-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erp-search {
  width: 220px;
  max-width: 100%;
}

.erp-pagesize {
  width: 72px;
}

.erp-th-sort {
  cursor: pointer;
  white-space: nowrap;
}

.erp-table-wrap {
  min-height: 120px;
}

/* Tablas con selects en fila: no recortar el desplegable (scroll horizontal en #main-content) */
.erp-table-inline-selects {
  overflow: visible;
}

.erp-table-inline-selects > table {
  min-width: 640px;
}

.erp-data-table {
  min-width: 640px;
}

.erp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1040;
}

#main-content {
  min-width: 0;
}

.erp-content-loading {
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  max-width: min(960px, calc(100vw - 1.5rem));
}

@media (max-width: 991.98px) {
  #app-sidebar {
    position: fixed;
    z-index: 1050;
    height: 100vh;
    left: 0;
    top: 0;
  }

  #app-main-column {
    width: 100%;
  }

  #app-sidebar.minimized {
    transform: translateX(-100%);
    width: 260px !important;
    min-width: 260px !important;
  }

  #app-sidebar:not(.minimized) {
    width: 260px !important;
    min-width: 260px !important;
  }

  #app-sidebar:not(.minimized) ~ .erp-sidebar-backdrop,
  body.erp-nav-open .erp-sidebar-backdrop {
    display: block;
  }

  #main-content {
    padding: 1rem !important;
  }

  #page-title {
    font-size: 1rem;
    max-width: 42vw;
  }

  .erp-btn-label {
    display: none;
  }

  .erp-grid-actions .btn {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .erp-search {
    width: 100%;
    min-width: 140px;
  }

  .erp-grid-tools {
    width: 100%;
  }

  .erp-data-table {
    min-width: 520px;
  }

  #view-login .col-lg-5 {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }
}

.lookup-cat-nav {
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.lookup-cat-active {
  border-color: #0d6efd !important;
  background: #e7f1ff !important;
}

.lookup-studio .card {
  min-height: 0;
}

.lookup-studio .lookup-sim-hit {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lookup-studio .lookup-sim-hit:hover {
  border-color: #0d6efd !important;
  box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.25);
}

.lookup-studio .lookup-sim-title {
  font-size: 0.8rem;
  line-height: 1.25;
}

.lookup-studio .lookup-studio-preview {
  min-height: 0;
  font-size: 0.8125rem;
}

.erp-search-select {
  position: relative;
}

.erp-search-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.erp-search-select-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 1080;
  max-height: 16rem;
  overflow: auto;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  margin-top: 2px;
  box-shadow: 0 0.5rem 1rem rgba(15, 23, 42, 0.12);
}

.erp-search-select.open .erp-search-select-menu,
.erp-search-select-menu.is-open {
  display: block;
}

.erp-search-select-option {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.erp-search-select-option:hover,
.erp-search-select-option.active,
.erp-search-select-option.keyboard-focus {
  background: #e7f1ff;
}

.erp-search-select-empty {
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  color: #6c757d;
}

.erp-dash-chart {
  position: relative;
}

.erp-gestion-layout {
  min-height: 260px;
}

.erp-cal-embed .inicio-cal-grid.is-compact {
  gap: 2px;
  font-size: 0.72rem;
}

.inicio-cal-grid.is-compact .inicio-cal-cell {
  min-height: 2rem;
  padding: 0.1rem;
}

.inicio-cal-grid.is-compact .inicio-cal-badge {
  font-size: 0.65rem;
  padding: 0 0.25rem;
}

.ind-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0;
  list-style: none;
}

.ind-nav-tabs .ind-nav-btn {
  border: 1px solid #dee2e6;
  border-left-width: 4px;
  background: #fff;
  color: #343a40;
  border-radius: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ind-nav-tabs .ind-nav-btn:hover {
  filter: brightness(0.97);
}

.ind-nav-tabs .ind-nav-btn.is-active {
  color: #fff;
}

.ind-nav-resumen { border-left-color: #0d6efd; }
.ind-nav-resumen.is-active { background: #0d6efd; border-color: #0d6efd; }
.ind-nav-modulos { border-left-color: #198754; }
.ind-nav-modulos.is-active { background: #198754; border-color: #198754; }
.ind-nav-bsc { border-left-color: #6f42c1; }
.ind-nav-bsc.is-active { background: #6f42c1; border-color: #6f42c1; }
.ind-nav-objetivos { border-left-color: #fd7e14; }
.ind-nav-objetivos.is-active { background: #fd7e14; border-color: #fd7e14; }
.ind-nav-caracterizacion { border-left-color: #20c997; }
.ind-nav-caracterizacion.is-active { background: #20c997; border-color: #20c997; }
.ind-nav-mapa { border-left-color: #6610f2; }
.ind-nav-mapa.is-active { background: #6610f2; border-color: #6610f2; }

/* Mapa de interrelaciones Indicadores */
.ind-map-hub {
  border-left: 4px solid #6610f2;
  background: #fff;
}
.ind-map-leaf {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 0.35rem 0.5rem;
  background: #f8f9fa;
  font-size: 0.8125rem;
}
.ind-map-leaf.is-ok { border-left: 3px solid #198754; }
.ind-map-leaf.is-bad { border-left: 3px solid #dc3545; }
.ind-map-leaf.is-na { border-left: 3px solid #adb5bd; }
.ind-map-connector {
  width: 12px;
  border-left: 2px solid #ced4da;
  margin-left: 0.75rem;
}

.erp-gestion-layout > [class*='col-'] > .erp-chart-card,
.erp-gestion-layout > [class*='col-'] > .card {
  flex: 1 1 auto;
  width: 100%;
  min-height: 100%;
}

.erp-chart-card.erp-chart-fill {
  display: flex;
  flex-direction: column;
}

.erp-chart-card.erp-chart-fill .card-body {
  min-height: 0;
}

.erp-chart-card.erp-chart-fill .erp-dash-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* MasterDataGrid statsLayout:split — gráfico compacto al lado de KPI (sin estirar) */
.erp-stats-extra {
  max-width: 100%;
}
.erp-stats-extra > .erp-chart-card {
  max-width: 100%;
}
.erp-stats-extra .erp-dash-chart {
  max-height: 168px;
}

.erp-gestion-kpi-grid {
  align-content: stretch;
  min-height: 100%;
}

.erp-gestion-kpi-grid > [class*='col-'] {
  min-height: calc(50% - 0.25rem);
}

.erp-gestion-kpi.erp-stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
  min-height: 100%;
  padding: 0.85rem !important;
}

.erp-gestion-kpi .erp-stat-visual {
  flex: 1 1 auto;
  align-items: center;
}

.erp-gestion-glossary {
  line-height: 1.35;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.5rem;
}

.sgc-map-card {
  min-width: 11rem;
  max-width: 16rem;
  height: auto;
  padding: 0.75rem !important;
}

.erp-note-list {
  line-height: 1.35;
}

.erp-prereq-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.8125rem;
  line-height: 1.25;
  color: #212529;
  background: #fff;
  border: 1px solid #dee2e6;
  border-left-width: 4px;
  border-radius: 0.375rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.06);
}

button.erp-prereq-chip {
  appearance: none;
  cursor: pointer;
}

button.erp-prereq-chip:hover {
  background: #f8fafc;
}

.erp-prereq-ok {
  border-left-color: var(--bs-success);
}

.erp-prereq-miss {
  border-left-color: var(--bs-warning);
}

.erp-prereq-na {
  border-left-color: var(--bs-secondary);
}

.erp-prereq-chip .fa-solid {
  font-size: 0.7rem;
}

button.erp-stat-card {
  appearance: none;
}

.erp-stat-clickable {
  cursor: pointer;
}

.erp-stat-clickable:hover {
  background: #f8fafc;
}

.erp-stat-active {
  background: #eef5ff;
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.35);
}

.erp-clause-block textarea {
  font-size: 0.95rem;
  line-height: 1.45;
}

.erp-stat-clickable:focus {
  outline: 2px solid rgba(13, 110, 253, 0.45);
  outline-offset: 2px;
}

.erp-stat-visual {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.erp-stat-donut svg {
  flex-shrink: 0;
}

.erp-stat-chart {
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
}

.erp-stat-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.erp-stat-chart canvas {
  width: 100% !important;
  height: 56px !important;
}

@media (max-width: 575.98px) {
  #user-display-name {
    display: none;
  }

  .erp-stat-row .fs-4 {
    font-size: 1.25rem !important;
  }
}

/* Inicio — calendario de pendientes con fecha */
.inicio-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}
.inicio-cal-head {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #6c757d;
  padding: 0.15rem 0;
}
.inicio-cal-cell {
  position: relative;
  min-height: 2.5rem;
  border: 1px solid #e9ecef;
  border-radius: 0.35rem;
  background: #fff;
  padding: 0.2rem 0.25rem;
  text-align: left;
  line-height: 1.1;
}
.inicio-cal-cell.is-empty {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}
.inicio-cal-cell.has-items {
  border-color: #0d6efd;
  background: #f0f6ff;
}
.inicio-cal-cell.is-late {
  border-color: #dc3545;
  background: #fff5f5;
}
.inicio-cal-cell.is-late.has-items {
  border-color: #dc3545;
}
.inicio-cal-cell.is-in-range {
  background: #e8f4ff;
  border-color: #6ea8fe;
}
.inicio-cal-cell.is-today {
  box-shadow: inset 0 0 0 1px #0d6efd;
}
.inicio-cal-cell.is-active {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}
.inicio-cal-cell.is-active .inicio-cal-badge {
  background: #fff;
  color: #0d6efd;
}
.inicio-cal-num {
  font-size: 0.8rem;
  font-weight: 600;
}
.inicio-cal-badge {
  position: absolute;
  right: 0.2rem;
  bottom: 0.15rem;
  font-size: 0.65rem;
  font-weight: 700;
  background: #0d6efd;
  color: #fff;
  border-radius: 0.75rem;
  min-width: 1.1rem;
  text-align: center;
  padding: 0 0.25rem;
}
.inicio-cal-badge.is-late-badge {
  background: #dc3545;
}
.inicio-cal-cell.is-active.is-late {
  background: #dc3545;
  border-color: #dc3545;
}

/* Ficha: barra sticky + affordance de fila */
.erp-ficha-bar.sticky-top {
  z-index: 15;
  top: 0;
  margin-left: -0.25rem;
  margin-right: -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.erp-ficha-trail {
  max-width: min(48vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.erp-ficha-section {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.erp-row-openable {
  cursor: pointer;
}
.erp-row-openable:hover {
  background-color: #f8f9fa;
}
.erp-grid-empty {
  padding: 1.75rem 1rem;
}
.erp-grid-empty .erp-grid-empty-icon {
  font-size: 1.75rem;
  opacity: 0.45;
}
.hover-bg-dark:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}
