/**
 * ERP Layout CSS — erp-layout.css
 * ReSysCla / Recicla Ambiente
 *
 * Complementa erp-base.css con:
 *  1.  Sidebar activo + mejoras
 *  2.  Helpers de página y contenedor
 *  3.  Toolbar de módulo
 *  4.  Tabs ERP
 *  5.  Timeline / bitácora
 *  6.  Bloques de documento
 *  7.  Grid de detalle (expediente)
 *  8.  Fieldblock (etiqueta + valor)
 *  9.  Step / flujo de aprobación
 * 10.  Responsive helpers
 *
 * Fase 2 — Adopción directa en vistas rediseñadas
 */

/* ═══════════════════════════════════════════════
   1. SIDEBAR — (Manejado en erp-sidebar.css)
   ═══════════════════════════════════════════════ */

/* Estilos de sidebar removidos para centralizar en erp-sidebar.css */

/* ═══════════════════════════════════════════════
   2. PÁGINA — CONTENEDOR PRINCIPAL
   ═══════════════════════════════════════════════ */

/* Reemplaza .crud-container para vistas ERP modernas */
.erp-page {
  animation: erpFadeIn .22s ease-out both;
  padding-left: 32px;
  padding-right: 32px;
}

@keyframes erpFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   3. TOOLBAR DE MÓDULO (sobre la tabla)
   ═══════════════════════════════════════════════ */

.erp-toolbar {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.erp-toolbar-left  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.erp-toolbar-right { display: flex; align-items: center; gap: 8px;  flex-wrap: wrap; }

.erp-search-input {
  border: 1px solid var(--erp-gray-200, #e5e7eb);
  border-radius: 6px;
  padding: 7px 12px 7px 32px;
  font-size: 1rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E") no-repeat 10px center;
  color: var(--erp-gray-700, #374151);
  min-width: 200px;
  transition: border-color .15s, box-shadow .15s;
}
.erp-search-input:focus {
  outline: none;
  border-color: var(--erp-primary-light, #2e5d99);
  box-shadow: 0 0 0 3px rgba(46,93,153,.12);
}

/* ═══════════════════════════════════════════════
   4. TABS ERP
   ═══════════════════════════════════════════════ */

.erp-tabs {
  display: flex;
  border-bottom: 2px solid var(--erp-gray-200, #e5e7eb);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}

.erp-tab-item {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--erp-gray-500, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.erp-tab-item:hover {
  color: var(--erp-primary, #1e3a5f);
  text-decoration: none;
}

.erp-tab-item.active {
  color: var(--erp-primary, #1e3a5f);
  border-bottom-color: var(--erp-primary, #1e3a5f);
}

.erp-tab-pane { display: none; }
.erp-tab-pane.active { display: block; }

/* ═══════════════════════════════════════════════
   5. TIMELINE / BITÁCORA
   ═══════════════════════════════════════════════ */

.erp-timeline {
  position: relative;
  padding: 0;
  margin: 0;
  list-style: none;
}

.erp-timeline::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--erp-gray-200, #e5e7eb);
}

.erp-timeline-item {
  display: flex;
  gap: 16px;
  padding: 0 0 20px 0;
  position: relative;
}

.erp-timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--erp-primary-pale, #e8f0fb);
  border: 2px solid var(--erp-primary-light, #2e5d99);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--erp-primary, #1e3a5f);
  flex-shrink: 0;
  z-index: 1;
}

.erp-timeline-dot.success { background: var(--erp-success-pale, #dcfce7); border-color: var(--erp-success, #16a34a); color: var(--erp-success, #16a34a); }
.erp-timeline-dot.warning { background: var(--erp-warning-pale, #fef3c7); border-color: var(--erp-warning, #d97706); color: var(--erp-warning, #d97706); }
.erp-timeline-dot.danger  { background: var(--erp-danger-pale, #fee2e2);  border-color: var(--erp-danger, #dc2626); color: var(--erp-danger, #dc2626); }

.erp-timeline-content { flex: 1; padding-top: 4px; }
.erp-timeline-title   { font-size: 1rem; font-weight: 600; color: var(--erp-gray-700, #374151); margin: 0 0 2px; }
.erp-timeline-date    { font-size: 0.85rem; color: var(--erp-gray-500, #6b7280); }
.erp-timeline-body    { font-size: 0.925rem;  color: var(--erp-gray-500, #6b7280); margin-top: 4px; }

/* ═══════════════════════════════════════════════
   6. BLOQUE DE DOCUMENTO
   ═══════════════════════════════════════════════ */

.erp-doc-list { display: flex; flex-direction: column; gap: 8px; }

.erp-doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--erp-gray-50, #f9fafb);
  border: 1px solid var(--erp-gray-200, #e5e7eb);
  border-radius: 8px;
  transition: background .15s, border-color .15s;
}

.erp-doc-row:hover { background: var(--erp-primary-pale, #e8f0fb); border-color: var(--erp-primary-light, #2e5d99); }

.erp-doc-icon {
  width: 36px;
  height: 36px;
  background: #fff;
  border: 1px solid var(--erp-gray-200, #e5e7eb);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--erp-primary, #1e3a5f);
  flex-shrink: 0;
}

.erp-doc-info { flex: 1; min-width: 0; }
.erp-doc-name { font-size: 1rem; font-weight: 600; color: var(--erp-gray-700, #374151); margin: 0 0 2px; }
.erp-doc-meta { font-size: 0.85rem; color: var(--erp-gray-500, #6b7280); }

.erp-doc-actions { display: flex; gap: 6px; }

.erp-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.925rem;
  font-weight: 500;
  border: 1px solid var(--erp-gray-200, #e5e7eb);
  background: #fff;
  color: var(--erp-primary, #1e3a5f);
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.erp-doc-btn:hover { background: var(--erp-primary-pale, #e8f0fb); border-color: var(--erp-primary-light, #2e5d99); text-decoration: none; color: var(--erp-primary, #1e3a5f); }

.erp-doc-missing {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--erp-gray-50, #f9fafb);
  border: 1px dashed var(--erp-gray-300, #d1d5db);
  border-radius: 8px;
  color: var(--erp-gray-500, #6b7280);
  font-size: 0.925rem;
}

/* ═══════════════════════════════════════════════
   7. GRID DE DETALLE (EXPEDIENTE)
   ═══════════════════════════════════════════════ */

@media (max-width: 992px) {
  .erp-detail-grid { grid-template-columns: 1fr; }
}

.erp-detail-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

@media (max-width: 1200px) {
  .erp-detail-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .erp-detail-grid-3 { grid-template-columns: 1fr; }
}

.erp-detail-grid .erp-fieldblock:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════════
   8. FIELDBLOCK — etiqueta + valor
   ═══════════════════════════════════════════════ */

.erp-fieldblock {
  padding: 14px 20px;
  border-bottom: 1px solid var(--erp-gray-100, #f3f4f6);
  border-right: 1px solid var(--erp-gray-100, #f3f4f6);
}

.erp-fieldblock:nth-child(even) { border-right: none; }
.erp-fieldblock:last-child { border-bottom: none; }

.erp-field-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--erp-gray-500, #6b7280);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 4px;
}

.erp-field-value {
  font-size: 1rem;
  color: var(--erp-gray-700, #374151);
  font-weight: 500;
  margin: 0;
  word-break: break-word;
}

.erp-field-value.large {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--erp-gray-900, #111827);
}

.erp-field-value.muted {
  color: var(--erp-gray-500, #6b7280);
  font-style: italic;
}

/* ═══════════════════════════════════════════════
   9. STEP / FLUJO (aprobaciones)
   ═══════════════════════════════════════════════ */

.erp-flow {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: wrap;
}

.erp-flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 100px;
  position: relative;
}

.erp-flow-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--erp-gray-400, #94a3b8);
}

.erp-flow-step.done:not(:last-child)::after {
  background: var(--erp-success, #16a34a);
}

.erp-flow-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--erp-gray-300, #d1d5db);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--erp-gray-500, #6b7280);
  font-weight: 700;
  margin-bottom: 6px;
  z-index: 1;
  transition: all .2s;
}

.erp-flow-step.done .erp-flow-dot   { background: var(--erp-success, #16a34a); border-color: var(--erp-success, #16a34a); color: #fff; }
.erp-flow-step.active .erp-flow-dot { background: var(--erp-gray-700, #374151); border-color: var(--erp-gray-700, #374151); color: #fff; }
.erp-flow-step.rejected .erp-flow-dot{ background: var(--erp-danger, #dc2626); border-color: var(--erp-danger, #dc2626); color: #fff; }

.erp-flow-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--erp-gray-500, #6b7280);
  text-align: center;
  line-height: 1.3;
}
.erp-flow-step.done .erp-flow-label   { color: var(--erp-success, #16a34a); }
.erp-flow-step.active .erp-flow-label { color: var(--erp-gray-700, #374151); }
.erp-flow-step.rejected .erp-flow-label { color: var(--erp-danger, #dc2626); }

/* ═══════════════════════════════════════════════
  10. SECTION CARD (variante con borde izquierdo)
   ═══════════════════════════════════════════════ */

.erp-section-card {
  background: #fff;
  border: 1px solid var(--erp-gray-200, #e5e7eb);
  border-left: 4px solid var(--erp-primary, #1e3a5f);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.erp-section-card.success { border-left-color: var(--erp-success, #16a34a); }
.erp-section-card.warning { border-left-color: var(--erp-warning, #d97706); }
.erp-section-card.danger  { border-left-color: var(--erp-danger, #dc2626);  }
.erp-section-card.info    { border-left-color: var(--erp-info, #0891b2);    }

/* ═══════════════════════════════════════════════
  11. IMPORTE HERO (número grande en cabecera)
   ═══════════════════════════════════════════════ */

.erp-amount-hero {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--erp-gray-900, #111827);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.erp-amount-currency {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--erp-gray-500, #6b7280);
  margin-right: 4px;
}

/* ═══════════════════════════════════════════════
  12. HELPERS RÁPIDOS
   ═══════════════════════════════════════════════ */

.erp-flex         { display: flex; }
.erp-flex-center  { display: flex; align-items: center; }
.erp-flex-between { display: flex; align-items: center; justify-content: space-between; }
.erp-gap-8        { gap: 8px; }
.erp-gap-12       { gap: 12px; }
.erp-gap-16       { gap: 16px; }
.erp-mb-0         { margin-bottom: 0 !important; }
.erp-mb-16        { margin-bottom: 16px !important; }
.erp-mb-24        { margin-bottom: 24px !important; }
.erp-mt-16        { margin-top: 16px !important; }
.erp-fw-600       { font-weight: 600; }
.erp-fw-700       { font-weight: 700; }
.erp-fw-800       { font-weight: 800; }
.erp-text-sm      { font-size: 0.925rem; }
.erp-text-xs      { font-size: 0.875rem; }
.erp-nowrap       { white-space: nowrap; }
.erp-truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════════════
  13. RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 768px) {
  .erp-module-header { flex-direction: column; align-items: flex-start; }
  .erp-module-actions { width: 100%; }
  .erp-toolbar { flex-direction: column; align-items: stretch; }
  .erp-toolbar-left, .erp-toolbar-right { width: 100%; }
  .erp-amount-hero { font-size: 1.75rem; }
  .erp-flow { flex-direction: column; gap: 16px; }
  .erp-flow-step { flex-direction: row; gap: 12px; min-width: 0; width: 100%; }
  .erp-flow-step::after { display: none; }
}

/* ═══════════════════════════════════════════════
  14. MEJORAS DE FILTROS EN GRIDVIEW
   ═══════════════════════════════════════════════ */
.erp-table .filters td {
  padding: 8px 6px !important;
  background: #fff !important;
  vertical-align: middle !important;
  border-bottom: 2px solid var(--erp-gray-200) !important;
}

.erp-table .filters input.form-control,
.erp-table .filters select.form-control {
  height: 38px !important;
  padding: 4px 10px !important;
  font-size: 0.95rem !important;
  border: 1px solid var(--erp-gray-300) !important;
  border-radius: 6px !important;
  background-color: var(--erp-gray-50) !important;
  color: var(--erp-gray-700) !important;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
  width: 100% !important;
}

.erp-table .filters input.form-control:focus,
.erp-table .filters select.form-control:focus {
  border-color: var(--erp-primary) !important;
  background-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1) !important;
  outline: none !important;
}

/* Ajuste específico para evitar que inputs oculten el texto en columnas pequeñas */
.erp-table .filters input.form-control::placeholder {
  font-size: 0.75rem !important;
  color: var(--erp-gray-400) !important;
}
