/* ==========================================================================
   PezControl — avance-reportes.css
   Estilos específicos para los módulos «Avance de Obra» y «Reportes».
   Diseño: Elementary OS HIG, Brand Orange (#F37329), Slate & Silver tokens.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Contenedores y Estructura
   -------------------------------------------------------------------------- */
.view-container-full {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
}









/* --------------------------------------------------------------------------
   2. Pestañas de Módulo (Module Tabs)
   -------------------------------------------------------------------------- */








/* --------------------------------------------------------------------------
   3. KPIs y Resumen
   -------------------------------------------------------------------------- */
.kpi-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  padding: var(--space-md) var(--space-page);
  background-color: var(--bg-app);
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-xs);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-sm);
}

.kpi-card.kpi-brand {
  border-left: 4px solid var(--color-brand);
}

.kpi-card.kpi-success {
  border-left: 4px solid var(--color-success);
}

.kpi-card.kpi-warning {
  border-left: 4px solid var(--color-warning);
}

.kpi-card.kpi-error {
  border-left: 4px solid var(--color-error);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xs);
}

.kpi-title {
  font-size: var(--font-label);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-val {
  font-size: var(--font-display);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin: var(--space-xxs) 0;
  line-height: 1.2;
}

.kpi-sub {
  font-size: var(--font-meta);
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: var(--space-xs);
}

/* --------------------------------------------------------------------------
   4. Barra de Herramientas y Filtros
   -------------------------------------------------------------------------- */
.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-page);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  min-width: 220px;
}

.search-input-wrap input {
  width: 100%;
  padding: var(--space-sm6) var(--space-md) var(--space-sm6) 28px;
  font-size: var(--font-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
}

.search-input-wrap input:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px rgba(243, 115, 41, 0.2);
}

.search-icon-pos {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.select-control {
  padding: var(--space-sm6) var(--space-md);
  font-size: var(--font-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.select-control:focus {
  border-color: var(--color-brand);
}

/* --------------------------------------------------------------------------
   5. Tablas de Ingeniería de Alta Densidad
   -------------------------------------------------------------------------- */
.table-scroll-container {
  flex: 1;
  overflow: auto;
  padding: var(--space-sm) var(--space-page) var(--space-page) var(--space-page);
}

.data-table-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-body);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table-custom thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--color-silver-200);
  color: var(--color-slate-700);
  font-size: var(--font-label);
  font-weight: var(--font-weight-bold);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

[data-theme="dark"] .data-table-custom thead th {
  background-color: var(--color-slate-800);
  color: var(--color-slate-100);
}

.data-table-custom tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.1s ease;
}

.data-table-custom tbody tr:nth-child(even) {
  background-color: var(--bg-surface-alt);
}

.data-table-custom tbody tr:hover {
  background-color: var(--bg-hover);
}

.data-table-custom td {
  padding: var(--space-sm6) var(--space-md);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table-custom td.num-cell,
.data-table-custom th.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table-custom tfoot td {
  background-color: var(--bg-surface-subtle);
  font-weight: var(--font-weight-bold);
  border-top: 2px solid var(--border-color);
  padding: var(--space-sm) var(--space-md);
}

/* --------------------------------------------------------------------------
   6. Badges y Semáforos
   -------------------------------------------------------------------------- */
.badge-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--font-meta);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  text-transform: uppercase;
}

.badge-abierto {
  background-color: var(--color-warning-bg);
  color: #854D0E;
  border: 1px solid #FDE047;
}

.badge-cerrado {
  background-color: var(--color-success-bg);
  color: var(--color-success-dark);
  border: 1px solid #86EFAC;
}

.badge-tipo-mo {
  background-color: var(--badge-mo-bg);
  color: var(--badge-mo-fg);
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-tiny);
}

.badge-tipo-mat {
  background-color: var(--badge-mat-bg);
  color: var(--badge-mat-fg);
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-tiny);
}

.badge-tipo-eq {
  background-color: var(--badge-eq-bg);
  color: var(--badge-eq-fg);
  font-weight: var(--font-weight-bold);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-tiny);
}

.badge-tag-danger {
  background-color: var(--color-red-50);
  color: var(--color-red-700);
  border: 1px solid #FCA5A5;
}

.badge-tag-success {
  background-color: var(--color-green-50);
  color: var(--color-green-900);
  border: 1px solid #86EFAC;
}

.badge-tag-neutral {
  background-color: var(--color-silver-200);
  color: var(--color-slate-500);
  border: 1px solid var(--border-color);
}

/* --------------------------------------------------------------------------
   7. Barras de Progreso Lineal
   -------------------------------------------------------------------------- */
.progress-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm6);
  min-width: 110px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background-color: var(--border-color);
  border-radius: var(--radius-round);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--color-brand);
  border-radius: var(--radius-round);
  transition: width 0.25s ease;
}

.progress-fill.complete {
  background-color: var(--color-success);
}

.progress-fill.danger {
  background-color: var(--color-error);
}

.progress-pct-text {
  font-size: var(--font-label);
  font-variant-numeric: tabular-nums;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  min-width: 38px;
  text-align: right;
}

/* --------------------------------------------------------------------------
   8. Drawer Lateral (Editor de Parte Diario)
   -------------------------------------------------------------------------- */
.avance-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: var(--z-avance-drawer);
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.15s ease-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.avance-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.avance-drawer-panel {
  width: 100%;
  max-width: 780px;
  height: 100%;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.avance-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
}

.avance-drawer-header h3 {
  margin: 0;
  font-size: var(--font-title);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.avance-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.avance-drawer-section {
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.avance-drawer-section-title {
  font-size: var(--font-subt);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.avance-drawer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  gap: var(--space-md);
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   9. Gráficas y Layout de Reportes
   -------------------------------------------------------------------------- */
.report-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: var(--space-page);
}

.charts-grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-page);
}

.chart-card-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  box-shadow: var(--shadow-xs);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.chart-card-header h4 {
  margin: 0;
  font-size: var(--font-title);
  color: var(--text-primary);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 320px;
}

.curva-s-canvas-wrap {
  position: relative;
  width: 100%;
  height: 380px;
}

/* --------------------------------------------------------------------------
   10. Estado Vacío Explicativo
   -------------------------------------------------------------------------- */
.empty-state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}



.empty-state-box h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: var(--font-title);
  color: var(--text-primary);
}

.empty-state-box p {
  margin: 0 0 var(--space-lg) 0;
  font-size: var(--font-body);
  max-width: 480px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   11. Estilos para Impresión (@media print)
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  /* Ocultar elementos no imprimibles */
  .sidebar,
  .topbar,
  .module-tabs,
  .toolbar-row,
  .view-header-actions,
  .btn,
  .avance-drawer-backdrop,
  #toast-container,
  .no-print {
    display: none !important;
  }

  .view-container-full,
  .table-scroll-container,
  .report-content-scroll {
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
  }

  .view-header-row {
    border-bottom: 2px solid #000000 !important;
    padding: 10px 0 !important;
  }

  .kpi-summary-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    padding: 10px 0 !important;
    background: transparent !important;
  }

  .kpi-card {
    border: 1px solid #CCCCCC !important;
    box-shadow: none !important;
    padding: 8px !important;
    break-inside: avoid;
  }

  .data-table-custom {
    border: 1px solid #999999 !important;
    width: 100% !important;
    font-size: 9pt !important;
    page-break-inside: auto;
  }

  .data-table-custom tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .data-table-custom thead th {
    background-color: #EEEEEE !important;
    color: #000000 !important;
    border-bottom: 2px solid #000000 !important;
  }

  .data-table-custom td {
    border-bottom: 1px solid #DDDDDD !important;
    color: #000000 !important;
  }

  .chart-card-box {
    border: 1px solid #CCCCCC !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }
}
