/* ==========================================================
   estilo.css — Calculadora de Préstamos
   Tema claro, responsive móvil-first
   Dependencias: Bootstrap 5.3, Bootstrap Icons 1.11
========================================================== */

/* =============================================
   RESET Y BASE MÓVIL
============================================= */
*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

html {
  font-size: 16px; /* base fija para evitar zoom en inputs iOS */
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: #f0f2f5;
  min-height: 100dvh; /* dynamic viewport height para móviles */
  overflow-x: hidden;
}

/* =============================================
   LAYOUT PRINCIPAL
============================================= */
.page-wrapper {
  padding: 1rem 0 5rem; /* bottom padding para navegación móvil */
}

/* En desktop mantiene el espaciado original */
@media (min-width: 768px) {
  .page-wrapper {
    padding-top: 2.5rem;
    padding-bottom: 4rem;
  }
}

.container-mobile {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding-left: 0.875rem;
  padding-right: 0.875rem;
}

@media (min-width: 576px) {
  .container-mobile {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* =============================================
   HEADER SECTION
============================================= */
.page-header {
  text-align: center;
  margin-bottom: 1rem;
  padding-top: 0.25rem;
}

@media (min-width: 768px) {
  .page-header {
    margin-bottom: 1.5rem;
  }
}

.page-header .badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: rgba(35, 134, 54, 0.08);
  color: #238636;
  border: 1px solid rgba(35, 134, 54, 0.25);
  border-radius: 2rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.65rem;
}

.page-header h1 {
  font-size: clamp(1.35rem, 5vw, 1.75rem); /* fluido */
  font-weight: 800;
  color: #1a1d23;
  margin-bottom: 0.3rem;
  line-height: 1.2;
}

.page-header p {
  font-size: 0.85rem;
  color: #6c757d;
  margin: 0;
  padding: 0 0.5rem;
}

/* =============================================
   CARD SALDO
============================================= */
.card-saldo {
  background-color: #ffffff;
  border: 1.5px solid #238636;
  border-radius: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 12px rgba(35, 134, 54, 0.1);
  overflow: hidden;
}

.card-saldo .saldo-body {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
}

.saldo-icon-wrap {
  width: 44px;
  height: 44px;
  min-width: 44px; /* evita que se comprima */
  background-color: rgba(35, 134, 54, 0.1);
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saldo-icon-wrap i {
  font-size: 1.3rem;
  color: #238636;
}

.saldo-info {
  flex: 1;
  min-width: 0; /* evita overflow */
}

.saldo-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saldo-monto {
  font-size: clamp(1.1rem, 5vw, 2rem);
  font-weight: 800;
  color: #238636;
  line-height: 1.1;
  word-break: break-all;
}

.saldo-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #238636;
  flex-shrink: 0;
}

.dot-online {
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: #238636;
  border-radius: 50%;
  box-shadow: 0 0 6px #238636;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* =============================================
   CARD PRINCIPAL DEL FORMULARIO
============================================= */
.card-main {
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 1rem;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.card-traffic-lights {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.9rem;
}

.traffic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-traffic-lights .card-title-label {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6c757d;
}

.card-body-form {
  padding: 1rem;
}

@media (min-width: 480px) {
  .card-body-form {
    padding: 1.25rem;
  }
}

@media (min-width: 768px) {
  .card-body-form {
    padding: 1.5rem;
  }
}

/* =============================================
   ALERTAS
============================================= */
.alert {
  border-radius: 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert ul {
  padding-left: 1.1rem;
  margin: 0.35rem 0 0;
}

.alert ul li {
  margin-bottom: 0.15rem;
}

/* =============================================
   VALIDACIÓN INLINE — Campo obligatorio
============================================= */
.field-error-msg {
  display: none;
  font-size: 0.78rem;
  color: #dc3545;
  margin-top: 0.3rem;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  animation: fadeIn 0.18s ease;
}

.field-error-msg.visible {
  display: flex;
}

.form-control.is-invalid-live,
.form-select.is-invalid-live {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.18rem rgba(220, 53, 69, 0.18) !important;
}

/* =============================================
   FORM LABELS
============================================= */
.form-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #495057;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* =============================================
   INPUTS — Tamaño táctil adecuado
============================================= */
.form-control,
.form-select {
  background-color: #ffffff;
  border-color: #ced4da;
  color: #212529;
  border-radius: 0.65rem;
  padding: 0.7rem 0.9rem;
  font-size: 1rem; /* 16px mínimo para evitar zoom iOS */
  line-height: 1.4;
  min-height: 48px; /* área táctil */
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: #238636;
  box-shadow: 0 0 0 0.2rem rgba(35, 134, 54, 0.2);
  outline: none;
}

.form-control.bg-light {
  background-color: #f8f9fa !important;
  color: #6c757d;
  cursor: not-allowed;
}

.form-text {
  font-size: 0.78rem;
  color: #6c757d;
  margin-top: 0.3rem;
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
}

.form-text i {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.mb-field {
  margin-bottom: 1rem;
}

/* =============================================
   TASA — Campo visual compacto
============================================= */
.tasa-display {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: #f0faf4;
  border: 1.5px solid #c3e6cb;
  border-radius: 0.65rem;
  padding: 0.65rem 0.9rem;
  min-height: 48px;
}

.tasa-badge {
  background-color: #238636;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 0.5rem;
  padding: 0.15rem 0.6rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.tasa-desc {
  font-size: 0.8rem;
  color: #495057;
  font-weight: 500;
}

.tasa-lock {
  margin-left: auto;
  color: #6c757d;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Input real oculto (sigue enviándose en el form) */
.tasa-input-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* =============================================
   PRECÁLCULO
============================================= */
.precalculo-box {
  background: linear-gradient(135deg, #f0faf4 0%, #e9f5ee 100%);
  border: 1px solid #c3e6cb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.85rem;
  display: none;
}

.precalculo-box.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.precalculo-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.precalculo-label {
  font-size: 0.78rem;
  color: #495057;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.precalculo-monto {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1a7f37;
}

/* =============================================
   BOTÓN CALCULAR
============================================= */
.btn-calcular {
  background: linear-gradient(135deg, #238636, #2ea043);
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
  border-radius: 0.75rem;
  width: 100%;
  min-height: 52px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition:
    opacity 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(35, 134, 54, 0.35);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-calcular:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(35, 134, 54, 0.3);
}

.btn-calcular:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-calcular i {
  font-size: 1.1rem;
}

/* =============================================
   RESULTADO
============================================= */
.resultado-divider {
  height: 1px;
  background: #dee2e6;
  margin: 1.25rem 0;
}

.resultado-hero {
  background: linear-gradient(135deg, #e9f7ef 0%, #d4edda 100%);
  border: 1px solid #c3e6cb;
  border-radius: 0.875rem;
  padding: 1.25rem 1rem;
  text-align: center;
  margin-bottom: 0.85rem;
}

.resultado-hero .result-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #2d6a4f;
  margin-bottom: 0.35rem;
}

.resultado-hero .monto-principal {
  font-size: clamp(2rem, 9vw, 2.6rem);
  font-weight: 800;
  color: #1a7f37;
  line-height: 1;
}

.resultado-hero .result-sublabel {
  font-size: 0.75rem;
  color: #40916c;
  margin-top: 0.35rem;
}

.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.res-cell {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.75rem;
  padding: 0.75rem 0.875rem;
}

.res-cell .res-cell-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6c757d;
  margin-bottom: 0.2rem;
}

.res-cell .res-cell-value {
  font-size: clamp(0.95rem, 3.5vw, 1.1rem);
  font-weight: 700;
  color: #212529;
  line-height: 1.2;
}

.res-cell .res-cell-value.text-danger {
  color: #dc3545 !important;
}

/* =============================================
   SAFE AREA (iOS notch / home bar)
============================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .page-wrapper {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  }
}

/* =============================================
   BOTÓN WHATSAPP
============================================= */
.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.85rem 1.5rem;
  background-color: #25d366;
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 0.75rem;
  text-decoration: none;
  min-height: 52px;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  transition:
    background-color 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-whatsapp:hover {
  background-color: #1ebe5d;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
}

.btn-whatsapp:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp i {
  font-size: 1.2rem;
}

.form-control::placeholder {
  opacity: 0.65 !important;
  color: #6c757d;
}
