/* ============================================================
   styles-extra.css
   Estilos adicionales para las nuevas secciones:
   - Toggle de moneda (topbar)
   - Toggle de sociedad (topbar)
   - Aging bars (Facturas de Venta)
   - Bloques de Indicadores Globales
   - Banner de alerta del Cashflow
   - Ajustes responsive
   ============================================================ */

/* ── TOGGLES (FX + SOCIEDAD) ─────────────────── */
.fx-toggle, .soc-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--navy-3);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.fx-label {
  font-size: 11px;
  color: var(--text-3);
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}
.fx-btn {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  transition: all .12s;
}
.fx-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.fx-btn.active {
  background: var(--blue);
  color: #fff;
}
.fx-rate {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-3);
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

/* En pantallas pequeñas, ocultar texto de los toggles */
@media (max-width: 1300px) {
  .fx-rate { display: none; }
  .fx-label { display: none; }
}
@media (max-width: 1100px) {
  .soc-toggle { display: none; }
}

/* ── AGING BARS ──────────────────────────────── */
.aging-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px;
  padding: 2px 0;
  width: 100%;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
.aging-row {
  display: grid !important;
  /* Columnas compactas que caben incluso en viewport angosto: 80+1fr+100+60 = ~250+1fr */
  grid-template-columns: 80px 1fr 100px 60px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  min-height: 20px;
  width: 100%;
  visibility: visible !important;
  opacity: 1 !important;
}
.aging-label {
  font-weight: 600;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aging-bar-bg {
  height: 14px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  min-width: 0;
}
.aging-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .4s ease;
  min-width: 2px;
  max-width: 100%;
}
.aging-amt {
  font-family: var(--mono);
  font-weight: 700;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aging-cnt {
  font-size: 11px;
  color: var(--text-3);
  text-align: right;
  white-space: nowrap;
}

/* ── TABLA ESPACIOSA (Detalle de Facturas) ───── */
/* Sobrescribe el padding default de td/th sólo en tablas marcadas con esta clase.
   Las tablas existentes (sin la clase) mantienen su padding original. */
.tbl-spacious table td {
  padding: 14px 14px !important;
  font-size: 13px;
  line-height: 1.4;
}
.tbl-spacious table th {
  padding: 12px 14px !important;
  font-size: 11px;
}
.tbl-spacious table td:first-child { padding-left: 20px !important; }
.tbl-spacious table td:last-child  { padding-right: 20px !important; }
.tbl-spacious table tbody tr {
  border-bottom: 1px solid var(--border);
}

/* ── SKELETON LOADING PULSE ──────────────────── */
.skeleton-pulse {
  display: inline-block;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  opacity: 0.6;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.85; }
}

/* ── BLOQUES DE TÍTULO EN INDICADORES ────────── */
.kpi-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 20px;
  margin-bottom: -8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.kpi-block-title:first-child { margin-top: 0; }

/* ── BANNER DE ALERTA ────────────────────────── */
.alert-banner {
  background: var(--red-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid var(--red);
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-banner strong { color: var(--red); margin-right: 4px; }

/* ── INPUTS Y SELECTS ────────────────────────── */
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--blue) !important;
}

/* ── TABLA DEL CASHFLOW (sticky first column) ── */
.tbl-wrap table th:first-child,
.tbl-wrap table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}
.tbl-wrap thead tr th:first-child {
  z-index: 4;
}

/* ── HOVER TARJETAS KPI ──────────────────────── */
.kpi-card {
  transition: transform .15s ease, border-color .15s ease;
}
.kpi-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

/* ── CHIPS NEW BADGE ─────────────────────────── */
.chip-open[style*="font-size:9px"] {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: white;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── FIX FLEX SHRINK del .main ────────────────── */
/* Sin esto, las cards se comprimen para caber en la altura del viewport
   en vez de overflowear y permitir scroll. Esto fuerza a que cada card
   mantenga su altura natural y el .main scrollee cuando excede. */
.main > * {
  flex-shrink: 0 !important;
}

/* ── RESPONSIVE ──────────────────────────────── */
/* NOTA: el stacking vertical del aging fue removido porque rompía
   la legibilidad cuando el sidebar (220px) reducía el viewport efectivo
   debajo de 900px. Las columnas compactas 80+1fr+100+60 caben perfecto
   incluso en viewport de 600px. */
@media(max-width:600px) {
  .aging-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .aging-bar-bg { order: 3; }
  .aging-amt   { order: 2; text-align: left; }
  .aging-cnt   { order: 4; text-align: left; }
}