/* ======================================
   RESET / BASE / TIPOGRAFÍA
====================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background: #f1f5f9; /* gris muy claro tipo Bretica */
  color: #1f2937;      /* slate-800 */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
}

body {
  padding: 16px;
}

/* ======================================
   CONTENEDOR & TARJETAS
====================================== */

.wrap {
  max-width: 1080px;
  margin: 0 auto 48px;
}

.card {
  background: #ffffff;                        /* tarjeta clara */
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;                        /* un poco más separadas */
  border: 1px solid rgba(15, 23, 42, 0.08);   /* borde suave */
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08); /* sombra suave, no tan pesada */
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.header h1 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.muted {
  color: #64748b; /* slate-500/600 */
  font-size: 0.9rem;
}

.section-title {
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: #2e4a62; /* azul Bretica */
}

.section-help {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 10px;
}

/* ======================================
   BOTONES
====================================== */

.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 999px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #ff8e7a, #ff6c58); /* coral Bretica */
  color: #ffffff;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}

.btn:hover {
  filter: brightness(1.03);
  box-shadow: 0 8px 18px rgba(248, 113, 113, 0.25);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: #1f2937;
  border: 1px solid #cbd5f5; /* borde clarito */
}

.btn-outline:hover {
  background: #e5f3ff;
}

.btn-ghost {
  background: transparent;
  color: #64748b !important;
  border: none;
}

.btn-ghost:hover {
  background: #e5e7eb;
  color: #111827 !important;
}

.btn-sm {
  padding: 2px 10px !important;
  font-size: 0.8rem;
}

/* toolbar para botones de header / secciones */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ======================================
   INPUTS
====================================== */

.input {
  width: 100%;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid #e2e8f0; /* gris claro */
  background: #ffffff;
  color: #1f2937;
  font-size: 0.85rem;
}

.input:focus {
  outline: 2px solid #ff8e7a; /* coral */
  outline-offset: 0;
  border-color: #ff8e7a;
}

.input-right {
  text-align: right;
}

/* ======================================
   TABLAS
====================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.table thead {
  background: #f8fafc; /* fondo suave */
}

.table th,
.table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 8px;
  font-size: 0.86rem;
}

.table th {
  text-align: left;
  color: #64748b;
  font-weight: 500;
}

.table td.num {
  text-align: right;
}

.table-products th,
.table-products td {
  font-size: 0.8rem;
}

/* ======================================
   FLEX HELPERS
====================================== */

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
}

.summary strong {
  font-size: 1rem;
}

/* ======================================
   RESULTADOS
====================================== */

.results {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.results-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
}

.results-row strong {
  text-align: right;
}

.results-note {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #64748b;
}

/* ======================================
   COLUMNA COST CELL
====================================== */

.cost-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ======================================
   MODAL DESGLOSE DE COSTOS
====================================== */

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.25); /* navy suave */
}

.modal-content {
  position: relative;
  max-width: 560px;
  margin: 60px auto;
  z-index: 51;
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
}

/* ======================================
   SCROLL HORIZONTAL EN TABLAS
====================================== */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ancho mínimo para que la tabla de productos no se aplaste */
.pe-products-table {
  min-width: 640px;
}

/* ======================================
   RESPONSIVE
====================================== */

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Reducir texto en botones pequeños del toolbar */
  .toolbar .btn {
    font-size: 0.8rem;
    padding: 5px 10px;
  }

  .table,
  .table th,
  .table td {
    font-size: 0.78rem;
  }

  .results-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .results-row strong {
    text-align: left;
  }

  .modal-content {
    width: 94%;
    margin: 20px auto;
    padding: 14px;
  }

  /* Indicadores del dashboard en columna en móvil */
  .chart-row-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .chart-meta {
    text-align: left;
  }

  .chart-row-footer {
    flex-wrap: wrap;
  }

  /* Sección de configuración en columna */
  .row-between {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary {
    margin-top: 6px;
  }
}

/* ======================================
   PRINT (PDF)
====================================== */

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .card {
    box-shadow: none;
    border-radius: 0;
    border-color: #ddd;
  }

  .btn,
  .toolbar,
  .modal {
    display: none !important;
  }
}

/* ======================================
   BADGES
====================================== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-strong {
  background: rgba(34, 197, 94, 0.15); /* verde */
  color: #15803d;
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.2); /* gris */
  color: #475569;
}

.badge-weak {
  background: rgba(239, 68, 68, 0.15); /* rojo */
  color: #b91c1c;
}

/* ======================================
   DASHBOARD GRÁFICO
====================================== */

#dashboardGlobal {
  margin-top: 8px;
  margin-bottom: 12px;
}

#dashboardChartBody {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.chart-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.chart-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.85rem;
}

.chart-name {
  font-weight: 500;
  color: #2e4a62; /* azul Bretica */
}

.chart-meta {
  color: #64748b;
  font-size: 0.8rem;
  text-align: right;
}

.chart-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #f8fafc;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.chart-fill {
  height: 100%;
  border-radius: 999px;
  transform-origin: left;
}

/* Global: fuerte / neutro / débil */
.chart-fill.strong {
  background: linear-gradient(90deg, #a7ebd0, #6ee7b7); /* mint */
}

.chart-fill.neutral {
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
}

.chart-fill.weak {
  background: linear-gradient(90deg, #f97316, #fb923c); /* coral/naranja */
}

/* Productos: positivo / negativo */
.chart-fill.positive {
  background: linear-gradient(90deg, #a7ebd0, #6ee7b7);
}

.chart-fill.negative {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.chart-row-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.chart-gap {
  color: #64748b;
}

.chart-gap.positive {
  color: #15803d;
}

.chart-gap.negative {
  color: #b91c1c;
}
