/* =====================================================================
   calculadora-negocio.css
   Mejoras sobre la calculadora de Potencial de Mercado — DatosConsulting
   P1: wizard, validación, tooltips, formato
   P2: KPI cards semáforo, gráfico, tabla comparativa
   P3: responsive mobile, sticky export
   P4: skeleton loader, spinner, animación conteo
   ===================================================================== */

/* — .input reemplaza el @apply que no funciona con CDN Tailwind */
.input {
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  width: 100%;
  font-size: 0.9rem;
  color: #1f2937;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

/* =====================================================================
   P1 — WIZARD: BARRA DE PROGRESO
   ===================================================================== */
.wizard-progress-container {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.wizard-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.wizard-step {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  color: #9ca3af;
  font-weight: 500;
  transition: color 0.2s;
}
.wizard-step.activo    { color: #b91c1c; font-weight: 700; }
.wizard-step.completado { color: #059669; font-weight: 600; }
.wizard-step.completado::before { content: '✓ '; }

.wizard-progress-bar {
  height: 5px;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}
.wizard-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #b91c1c, #ef4444);
  border-radius: 9999px;
  transition: width 0.45s ease;
}

/* P1 — visibilidad de pasos */
.paso-formulario        { display: none; }
.paso-formulario.active { display: block; }

/* P1 — navegación wizard */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  gap: 0.5rem;
}

.btn-wizard {
  padding: 0.55rem 1.4rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-wizard:hover           { opacity: 0.88; transform: translateY(-1px); }
.btn-wizard:active          { transform: translateY(0); }
.btn-wizard:disabled        { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-anterior  { background: #6b7280; color: #fff; }
.btn-siguiente { background: #b91c1c; color: #fff; }
.btn-calcular  { background: #1d4ed8; color: #fff; }

/* P1 — errores de campo en tiempo real */
.campo-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.mensaje-error {
  color: #dc2626;
  font-size: 0.78rem;
  margin-top: 0.2rem;
  min-height: 1rem;
  display: block;
}
.mensaje-error.hidden { display: none; }

/* P1 — tooltips ℹ️ */
.label-con-tooltip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 0.65rem;
  font-style: normal;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}
.tooltip-icon:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 1px;
}
.tooltip-icon .tooltip-texto {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 7px);
  background: #1f2937;
  color: #f9fafb;
  font-size: 0.73rem;
  font-weight: 400;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  width: 240px;
  z-index: 999;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: normal;
  text-align: left;
}
.tooltip-icon .tooltip-texto::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
}
.tooltip-icon:hover .tooltip-texto,
.tooltip-icon:focus .tooltip-texto { display: block; }

/* =====================================================================
   P2 — KPI CARDS CON SEMÁFORO
   ===================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 0.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border-left: 4px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}
.kpi-verde    { border-left-color: #10b981; background: #f0fdf4; }
.kpi-amarillo { border-left-color: #f59e0b; background: #fffbeb; }
.kpi-rojo     { border-left-color: #ef4444; background: #fef2f2; }

.kpi-icono  { font-size: 1.4rem; }
.kpi-titulo {
  font-size: 0.72rem;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-valor {
  font-size: 1.45rem;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-label { font-size: 0.67rem; color: #9ca3af; }

/* P2 — tabla comparativa empresa vs competencia */
.tabla-titulo {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin: 1.5rem 0 0.6rem;
}
.tabla-responsive { overflow-x: auto; }
.tabla-comparativa {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
.tabla-comparativa th {
  background: #b91c1c;
  color: #fff;
  padding: 0.55rem 1rem;
  text-align: left;
  font-weight: 600;
}
.tabla-comparativa td {
  padding: 0.45rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
}
.tabla-comparativa tr:hover td { background: #f9fafb; }
.empresa-col { font-weight: 600; color: #1d4ed8; }

/* P2 — detalle por escenario */
.detalle-escenario {
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  display: inline-block;
  font-size: 0.93rem;
}
.escenario-conservador { background: #fef2f2; color: #b91c1c; }
.escenario-realista    { background: #eff6ff; color: #1d4ed8; }
.escenario-optimista   { background: #f0fdf4; color: #065f46; }

.detalle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 0.2rem 1rem;
  margin-bottom: 0.25rem;
}
.detalle-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.28rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.83rem;
}
.detalle-metrica { color: #374151; }
.detalle-valor   { font-weight: 600; color: #111827; white-space: nowrap; margin-left: 0.5rem; }

/* =====================================================================
   P4 — SKELETON LOADER
   ===================================================================== */
.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.skeleton-block {
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 5px;
  height: 18px;
}
.skeleton-block.tall  { height: 160px; }
.skeleton-block.short { width: 50%; }
.skeleton-block.med   { width: 72%; }

@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* P4 — spinner en botón Calcular */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   P3 — STICKY FOOTER EXPORT (solo en mobile)
   ===================================================================== */
.sticky-export-mobile { display: none; }

/* =====================================================================
   UTILIDAD
   ===================================================================== */
.hidden { display: none !important; }

/* =====================================================================
   P3 — RESPONSIVE < 480px
   ===================================================================== */
@media (max-width: 480px) {
  .wizard-step  { font-size: 0.7rem; }
  .btn-wizard   { padding: 0.48rem 0.85rem; font-size: 0.82rem; }
  .kpi-grid     { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .kpi-valor    { font-size: 1.15rem; }
  .detalle-grid { grid-template-columns: 1fr; }

  /* P3 — sticky export footer visible tras calcular */
  .sticky-export-mobile {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 300;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 0.55rem 1rem;
    gap: 0.5rem;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }
  .sticky-export-mobile.visible { transform: translateY(0); }
  .sticky-export-mobile button {
    flex: 1;
    padding: 0.55rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.83rem;
  }
  .btn-pdf   { background: #10b981; color: #fff; }
  .btn-excel { background: #f59e0b; color: #fff; }
}
