/* Sistema de diseño — Brisas de Panguilelfún */
:root {
  --primary: #2563EB;
  --primary-oscuro: #1E3A8A;
  --success: #16A34A;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.card { border-radius: 12px; }

.navbar-logo { height: 42px; }

/* ── Menú (sidebar escritorio + offcanvas móvil) ───────── */
.sidebar {
  flex: 0 0 250px;   /* ancho fijo: no se encoge ni crece al cambiar de sección */
  width: 250px;
  min-width: 250px;
  min-height: calc(100vh - 57px);
  background: linear-gradient(180deg, var(--primary-oscuro) 0%, #1D4ED8 100%);
}
/* El contenido principal absorbe el ancho restante y las tablas anchas hacen
   scroll dentro de su contenedor, en vez de empujar y encoger el menú. */
.contenido-principal { min-width: 0; }

.sidebar-offcanvas {
  width: 82vw !important;
  max-width: 320px;
  background: linear-gradient(180deg, var(--primary-oscuro) 0%, #1D4ED8 100%);
}
.sidebar-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255, 255, 255, .12); }

.menu-nav .sidebar-titulo {
  color: rgba(255, 255, 255, .45);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .6rem .9rem .2rem;
}

.menu-nav .nav-link {
  color: rgba(255, 255, 255, .78);
  border-radius: 10px;
  padding: .7rem .9rem;
  font-size: .925rem;
  display: flex;
  align-items: center;
  transition: background .15s ease, color .15s ease;
}

.menu-nav .nav-link i {
  width: 22px;
  text-align: center;
  margin-right: .55rem;
  opacity: .9;
}

.menu-nav .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .10); }

.menu-nav .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, .18);
  font-weight: 600;
  box-shadow: inset 3px 0 0 #93C5FD;
}

/* ── Barra de navegación inferior (solo móvil) ─────────── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1030;
  display: flex;
  background: #fff;
  border-top: 1px solid #E2E8F0;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, .07);
  padding: .2rem .2rem calc(.2rem + env(safe-area-inset-bottom, 0px));
}

.bottom-nav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: .3rem 0;
  font-size: .66rem;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: 0;
}

.bottom-nav .bn-item i { font-size: 1.2rem; }
.bottom-nav .bn-item.active { color: var(--primary); font-weight: 600; }
.bottom-nav .bn-item:active { background: rgba(37, 99, 235, .07); border-radius: 10px; }

/* ── Ajustes generales de responsividad ────────────────── */
@media (max-width: 991.98px) {
  /* Deja aire bajo el contenido para la barra inferior fija */
  .contenido-principal { padding-bottom: 5.5rem !important; }
  /* Mapas más bajos en pantallas chicas */
  #mapa { height: 320px !important; }
  .navbar-logo { height: 34px; }
}

@media (max-width: 575.98px) {
  main.contenido-principal { padding-left: .8rem; padding-right: .8rem; }
  #mapa { height: 260px !important; }
  h1.h5 { font-size: 1.05rem; }
}

/* Gráficos e imágenes nunca desbordan */
canvas { max-width: 100% !important; height: auto; }
img { max-width: 100%; }

/* Modales cómodos en móvil */
@media (max-width: 575.98px) {
  .modal-dialog { margin: .5rem; }
}

/* ── Tablas que se convierten en tarjetas en móvil ─────── */
@media (max-width: 767.98px) {
  table[data-cards] { border: 0; }
  table[data-cards] thead { display: none; }
  table[data-cards] tbody,
  table[data-cards] tr,
  table[data-cards] td { display: block; width: 100%; }

  table[data-cards] tr {
    background: var(--surface);
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: .35rem .8rem;
    margin-bottom: .6rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }

  table[data-cards] td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    text-align: right;
    border: 0;
    border-bottom: 1px solid #F1F5F9;
    padding: .45rem 0;
    min-height: 2.2rem;
  }

  table[data-cards] tr td:last-child { border-bottom: 0; }

  table[data-cards] td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    margin-right: auto;
    font-size: .8rem;
  }

  /* Celdas sin etiqueta (acciones) ocupan todo el ancho */
  table[data-cards] td:not([data-label])::before,
  table[data-cards] td[data-label=""]::before { content: ""; }
  table[data-cards] td:not([data-label]) { justify-content: flex-end; }

  /* Pie de tabla como resumen destacado */
  table[data-cards] tfoot,
  table[data-cards] tfoot tr,
  table[data-cards] tfoot td { display: block; width: 100%; }
  table[data-cards] tfoot tr {
    background: #EFF6FF;
    border-color: #BFDBFE;
  }
}

/* ── Finanzas · Estado por parcela + Últimos pagos ─────── */
.tabla-estado td { padding: .55rem .5rem; vertical-align: middle; }
.tabla-estado tbody tr { transition: background .15s ease; }
.tabla-estado tbody tr:hover { background: #F1F5F9; }

.pill-parcela {
  display: inline-block; white-space: nowrap; font-weight: 600;
  background: #EFF6FF; color: #1E3A8A; border: 1px solid #BFDBFE;
  border-radius: 999px; padding: 2px 10px; font-size: .8rem;
}

.avatar-ini {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #3730A3; background: #E0E7FF;
}

.badge-estado i { margin-right: 4px; }

.btn-pagar {
  white-space: nowrap; border-radius: 999px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-pagar:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(37, 99, 235, .28); }

.pago-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .35rem; border-bottom: 1px solid #F1F5F9;
  border-radius: 10px; transition: background .15s ease;
}
.pago-item:hover { background: #F8FAFC; }
.pago-icono {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ECFDF5; color: #059669; font-size: .95rem;
}
.pago-item.efectivo .pago-icono { background: #FEF3C7; color: #B45309; }
.pago-info { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.pago-parc { font-weight: 600; font-size: .82rem; }
.pago-fecha { font-size: .72rem; color: var(--muted); }
.pago-monto { font-weight: 700; color: #16A34A; white-space: nowrap; font-size: .85rem; }
.pago-acc { display: flex; align-items: center; gap: .55rem; margin-left: .1rem; }
.pago-acc a, .pago-acc button { color: #94A3B8; transition: color .12s ease, transform .12s ease; }
.pago-acc a:hover, .pago-acc button:hover { color: #475569; transform: scale(1.12); }
.pago-acc .wa:hover { color: #25D366; }
.pago-acc .anular:hover { color: #DC2626; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.tabla-estado tbody tr, .pago-item { animation: fadeUp .25s ease both; }
