/* ═══════════════════════════════════════════════════════════════════
   TEMFI PORTAL — Estilos específicos del portal de clientes
   Complementa styles.css del sitio principal (que define las
   variables CSS: --midnight, --cosmic, --violet, --white, etc.)
═══════════════════════════════════════════════════════════════════ */

/* ─── BASE ───────────────────────────────────────────────────────── */
.portal-body {
  background: var(--light-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── LOGIN ──────────────────────────────────────────────────────── */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0, 22, 114, 0.08);
  border: 1px solid var(--gray-blue);
}

.login-logo {
  display: block;
  margin-bottom: 36px;
}

.login-logo__img {
  height: 36px;
  width: auto;
}

.login-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--midnight);
  margin-bottom: 12px;
  line-height: 1.2;
}

.login-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 28px;
}

.login-help {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
}

.login-help a {
  color: var(--cosmic);
  text-decoration: none;
  font-weight: 500;
}

.login-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.login-footer a {
  color: var(--cosmic);
  text-decoration: none;
  font-weight: 500;
}

/* ─── CAMPOS DE FORMULARIO ───────────────────────────────────────── */
.portal-field {
  margin-bottom: 20px;
}

.portal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.portal-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--light-bg);
  border: 1.5px solid var(--gray-blue);
  border-radius: 10px;
  font-size: 16px;
  color: var(--midnight);
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.portal-input:focus {
  border-color: var(--cosmic);
  box-shadow: 0 0 0 3px rgba(0, 94, 255, 0.1);
}

/* Campo OTP: letra grande y centrada */
.portal-input--otp {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  font-family: var(--font-display);
  color: var(--midnight);
}

/* Mensaje de error */
.portal-error {
  font-size: 13px;
  color: #DC2626;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ─── BOTONES DEL PORTAL ─────────────────────────────────────────── */
.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.portal-btn:hover { transform: translateY(-1px); opacity: 0.9; }
.portal-btn:active { transform: translateY(0); opacity: 1; }

.portal-btn--primary {
  background: linear-gradient(135deg, var(--cosmic), var(--violet));
  color: white;
  width: 100%;
  margin-bottom: 12px;
}

.portal-btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--gray-blue);
  width: 100%;
}

.portal-btn--ghost:hover { border-color: var(--midnight); color: var(--midnight); opacity: 1; }

.portal-btn--wa {
  background: #25D366;
  color: white;
}

.portal-btn--sm {
  padding: 8px 16px;
  font-size: 13px;
  width: auto;
}

.portal-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ─── HEADER DEL DASHBOARD ───────────────────────────────────────── */
.portal-body--dashboard {
  background: var(--light-bg);
  display: block;
}

.dash-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-blue);
  padding: 0 5%;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.dash-logo { display: flex; align-items: center; text-decoration: none; }

.dash-logo__img { height: 32px; width: auto; }

.dash-header__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-saludo {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── ESTADOS: LOADING / ERROR ───────────────────────────────────── */
.dash-loading,
.dash-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
  font-size: 15px;
}

.dash-loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-blue);
  border-top-color: var(--cosmic);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── LAYOUT PRINCIPAL ───────────────────────────────────────────── */
.dash-main { padding: 40px 5% 80px; }

.dash-inner { max-width: 960px; margin: 0 auto; }

/* ─── SECCIONES ──────────────────────────────────────────────────── */
.dash-section {
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 24px;
  border: 1px solid var(--gray-blue);
}

.dash-section__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.dash-section__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--midnight);
  margin-bottom: 24px;
}

.dash-section__header .dash-section__title { margin-bottom: 0; }

.dash-section__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--cosmic);
  text-decoration: none;
}

.dash-section__desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.dash-section--soporte {
  background: linear-gradient(135deg, var(--midnight), #0A1A80);
  border-color: transparent;
  color: white;
}

.dash-section--soporte .dash-section__title { color: white; }
.dash-section--soporte .dash-section__desc  { color: rgba(255,255,255,0.65); }

.soporte-btns { display: flex; gap: 12px; flex-wrap: wrap; }

/* ─── TARJETAS DE CRÉDITO ────────────────────────────────────────── */
.credito-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}

.credito-card {
  border-radius: 12px;
  padding: 24px;
}

.credito-card--main {
  background: var(--light-bg);
  border: 1px solid var(--gray-blue);
}

.credito-card--proxima {
  background: linear-gradient(135deg, var(--midnight), #0A1A80);
  color: white;
}

.credito-card__row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.credito-card__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.credito-card--proxima .credito-card__label { color: rgba(255,255,255,0.5); }

.credito-card__value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--midnight);
}

/* Progreso */
.credito-progress__header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.credito-progress__track {
  background: var(--gray-blue);
  border-radius: 4px;
  height: 8px;
}

.credito-progress__fill {
  background: linear-gradient(90deg, var(--cosmic), var(--violet));
  height: 8px;
  border-radius: 4px;
  transition: width 0.8s ease;
}

/* Proxima cuota */
.credito-proxima__num   { font-size: 12px; color: rgba(255,255,255,0.5); margin: 16px 0 6px; }
.credito-proxima__monto { font-family: var(--font-display); font-size: 32px; font-weight: 800; color: white; }
.credito-proxima__fecha { font-size: 14px; color: rgba(255,255,255,0.7); margin-top: 4px; margin-bottom: 12px; }
.credito-proxima__wa    { margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.15); }

/* ─── BADGES DE ESTADO ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}

.badge--pagado   { background: #D1FAE5; color: #065F46; }
.badge--pendiente{ background: #EFF6FF; color: #1E40AF; }
.badge--vencido  { background: #FEE2E2; color: #991B1B; }

.cuota-estado--pagado   { color: #059669; font-weight: 600; font-size: 13px; }
.cuota-estado--pendiente{ color: #8BA4FF; font-weight: 600; font-size: 13px; }
.cuota-estado--vencido  { color: #EF4444; font-weight: 600; font-size: 13px; }

/* ─── TABLA DE CUOTAS ────────────────────────────────────────────── */
.tabla-wrap { overflow-x: auto; margin-bottom: 16px; }

.tabla-cuotas {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tabla-cuotas th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0 16px 12px 0;
  border-bottom: 1px solid var(--gray-blue);
  white-space: nowrap;
}

.tabla-cuotas td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid rgba(188, 201, 221, 0.4);
  color: var(--text-body);
  vertical-align: middle;
}

.tabla-cuotas tbody tr:last-child td { border-bottom: none; }

.fila-vencida td { background: #FFF5F5; }

.tabla-nota {
  font-size: 13px;
  color: var(--text-muted);
}

.tabla-nota a { color: var(--cosmic); text-decoration: none; font-weight: 500; }

/* Sin crédito */
.sin-credito {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 15px;
}

.sin-credito .portal-btn--primary { width: auto; margin: 20px auto 0; }

/* ─── CÁPSULAS EDUCATIVAS ────────────────────────────────────────── */
.capsulas-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.capsula-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--light-bg);
  border-radius: 12px;
  border: 1px solid var(--gray-blue);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s;
}

.capsula-card:hover {
  border-color: var(--cosmic);
  transform: translateX(4px);
}

.capsula-card__icon { font-size: 24px; flex-shrink: 0; }

.capsula-card__body { flex: 1; }

.capsula-card__cat {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cosmic);
  font-weight: 700;
  margin-bottom: 3px;
}

.capsula-card__titulo {
  font-size: 14px;
  font-weight: 600;
  color: var(--midnight);
  line-height: 1.4;
}

.capsula-card__arrow {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .login-card { padding: 32px 24px; }

  .dash-header { padding: 0 4%; }
  .dash-saludo  { display: none; }
  .dash-main    { padding: 24px 4% 60px; }

  .credito-grid        { grid-template-columns: 1fr; }
  .credito-card__row   { grid-template-columns: 1fr 1fr; }

  .dash-section { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .credito-card__row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .credito-card__value { font-size: 16px; }
  .credito-proxima__monto { font-size: 26px; }
}
