/* ============================================================
   CrediSensor — Estilos globales
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=DM+Sans:ital,wght@0,400;0,500;1,400&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:   #0d1f4e;
  --blue:   #1a3fa0;
  --sky:    #2563eb;
  --cyan:   #06b6d4;
  --green:  #10b981;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --bg:     #f0f4ff;
  --card:   #ffffff;
  --border: #dde3f0;
  --text:   #0d1f4e;
  --muted:  #6b7a99;
  --light:  #e8edf8;
}

body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
.sora { font-family: 'Sora', sans-serif; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---- NAVBAR ---- */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.nav-logo { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 20px; color: var(--navy); display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo img { width: 36px; height: 36px; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { font-size: 14px; color: var(--muted); font-weight: 500; }
.nav-links a:hover { color: var(--navy); text-decoration: none; }
.btn-nav { background: var(--navy); color: #fff !important; padding: 8px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; font-family: 'Sora', sans-serif; }
.btn-nav:hover { opacity: .9; text-decoration: none !important; }

/* ---- BOTONES ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 24px; border-radius: 8px; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 600; text-decoration: none; transition: all .2s; }
.btn-primary   { background: var(--cyan);  color: var(--navy); }
.btn-secondary { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); }
.btn-dark      { background: var(--navy); color: #fff; }
.btn-danger    { background: #fee2e2; color: var(--red); }
.btn-outline   { background: #fff; color: var(--sky); border: 1px solid var(--border); }
.btn:hover     { opacity: .88; transform: translateY(-1px); }
.btn-sm        { padding: 6px 14px; font-size: 13px; }
.btn-full      { width: 100%; justify-content: center; }

/* ---- HERO ---- */
.hero { background: var(--navy); color: #fff; padding: 80px 32px 60px; text-align: center; position: relative; overflow: hidden; }
.hero-tag { display: inline-flex; align-items: center; gap: 6px; background: rgba(6,182,212,.15); border: 1px solid rgba(6,182,212,.3); color: var(--cyan); padding: 5px 16px; border-radius: 20px; font-size: 13px; font-weight: 500; margin-bottom: 22px; }
.hero h1 { font-family: 'Sora', sans-serif; font-size: 40px; font-weight: 700; line-height: 1.15; margin-bottom: 18px; max-width: 640px; margin-left: auto; margin-right: auto; }
.hero h1 span { color: var(--cyan); }
.hero p { color: rgba(255,255,255,.72); font-size: 17px; max-width: 500px; margin: 0 auto 32px; }
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- STATS ---- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; max-width: 720px; margin: 0 auto; padding: 40px 32px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; text-align: center; }
.stat-num { font-family: 'Sora', sans-serif; font-size: 32px; font-weight: 700; color: var(--sky); }
.stat-lbl { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---- SECCIONES GENERALES ---- */
.section { padding: 60px 32px; }
.section-header { text-align: center; margin-bottom: 40px; }
.section-title { font-family: 'Sora', sans-serif; font-size: 28px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.section-sub { color: var(--muted); font-size: 15px; }

/* ---- FEATURES ---- */
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; max-width: 960px; margin: 0 auto; }
.feat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.feat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 14px; }
.feat-card h3 { font-family: 'Sora', sans-serif; font-size: 16px; font-weight: 600; color: var(--navy); margin-bottom: 8px; }
.feat-card p { font-size: 14px; color: var(--muted); line-height: 1.6; }

/* ---- HOW IT WORKS ---- */
.how-section { background: var(--navy); }
.how-section .section-title { color: #fff; }
.how-section .section-sub { color: rgba(255,255,255,.6); }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 20px; max-width: 680px; margin: 0 auto; }
.step-box { text-align: center; padding: 24px 16px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; }
.step-num { font-family: 'Sora', sans-serif; font-size: 32px; font-weight: 700; color: var(--cyan); }
.step-label { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 10px; }

/* ---- TESTIMONIOS ---- */
.testimonios-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 20px; max-width: 960px; margin: 0 auto; }
.testi-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.testi-estrellas { margin-bottom: 10px; font-size: 16px; }
.testi-comentario { font-size: 14px; color: #374151; line-height: 1.65; margin-bottom: 14px; font-style: italic; }
.testi-nombre { font-family: 'Sora', sans-serif; font-size: 14px; font-weight: 600; color: var(--navy); }
.testi-ciudad { font-size: 12px; color: var(--muted); }

/* ---- FOOTER ---- */
footer { background: var(--navy); color: rgba(255,255,255,.6); padding: 28px 32px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer-links { display: flex; gap: 24px; }
.footer-links a { color: rgba(255,255,255,.5); font-size: 13px; }
.footer-links a:hover { color: #fff; text-decoration: none; }

/* ---- FORMS ---- */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 36px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--navy); margin-bottom: 6px; }
.form-control { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: 'DM Sans', sans-serif; color: var(--text); background: #fff; outline: none; transition: border .2s; }
.form-control:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.toggle-group { display: flex; gap: 10px; }
.toggle-opt { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; font-family: 'DM Sans', sans-serif; color: var(--muted); text-align: center; transition: all .2s; }
.toggle-opt.active { border-color: var(--sky); background: #eff6ff; color: var(--sky); font-weight: 600; }
.form-error { color: var(--red); font-size: 13px; margin-top: 4px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ---- DASHBOARD LAYOUT ---- */
.dash-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 0px); }
.sidebar { background: var(--navy); min-height: 100vh; position: sticky; top: 0; }
.sb-brand { padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-brand span { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; color: #fff; }
.sb-section-label { padding: 20px 20px 8px; font-size: 10px; font-weight: 600; color: rgba(255,255,255,.3); letter-spacing: 1.2px; text-transform: uppercase; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: rgba(255,255,255,.6); text-decoration: none; transition: all .2s; }
.sb-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sb-item.active { background: rgba(37,99,235,.4); color: #fff; }
.sb-item-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.dash-main { background: var(--bg); padding: 28px; overflow-y: auto; }
.dash-header { margin-bottom: 24px; }
.dash-header h1 { font-family: 'Sora', sans-serif; font-size: 22px; font-weight: 700; color: var(--navy); }
.dash-header p { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ---- ENTIDAD CARD ---- */
.lender-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; display: flex; align-items: center; gap: 18px; margin-bottom: 14px; transition: all .2s; }
.lender-card:hover { border-color: var(--sky); box-shadow: 0 4px 16px rgba(37,99,235,.1); }
.lender-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.lender-info { flex: 1; min-width: 0; }
.lender-name { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 15px; color: var(--navy); }
.lender-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.prob-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.prob-bar { height: 5px; background: var(--light); border-radius: 3px; flex: 1; overflow: hidden; }
.prob-fill { height: 100%; border-radius: 3px; background: var(--green); }
.prob-pct { font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; }

/* ---- TABLA ADMIN ---- */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-card th { padding: 11px 16px; text-align: left; background: var(--light); color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.table-card td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table-card tr:hover td { background: #fafbff; }
.admin-actions { display: flex; gap: 6px; }
.btn-edit { padding: 5px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; color: var(--sky); font-family: inherit; }
.btn-del  { padding: 5px 12px; border: 1px solid #fecaca; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; color: var(--red); font-family: inherit; }

/* ---- ADMIN SIDEBAR ---- */
.admin-sidebar { background: #0a1628; }
.admin-top-bar { background: #0a1628; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-top-bar span { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 15px; color: #fff; }

/* ---- MODAL ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500; display: none; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: 'Sora', sans-serif; font-size: 18px; font-weight: 700; color: var(--navy); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--muted); line-height: 1; }

/* ---- LOADING ---- */
.loading-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; background: var(--bg); }
.radar-anim { width: 110px; height: 110px; border-radius: 50%; border: 2px solid var(--cyan); display: flex; align-items: center; justify-content: center; position: relative; animation: radarpulse 2s ease-out infinite; }
@keyframes radarpulse { 0%,100%{box-shadow:0 0 0 0 rgba(6,182,212,.5)} 50%{box-shadow:0 0 0 24px rgba(6,182,212,0)} }
.radar-inner { width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(6,182,212,.35); display: flex; align-items: center; justify-content: center; }
.radar-core { width: 30px; height: 30px; border-radius: 50%; background: var(--cyan); opacity: .25; }
.radar-dot { position: absolute; width: 14px; height: 14px; background: var(--cyan); border-radius: 50%; }
.loading-steps { margin-top: 32px; width: 100%; max-width: 400px; }
.lstep { display: flex; align-items: center; gap: 14px; padding: 12px 0; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--border); opacity: .4; transition: all .5s; }
.lstep.done   { color: var(--green); opacity: 1; }
.lstep.active { color: var(--sky);   opacity: 1; font-weight: 500; }
.lstep-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--light); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.lstep.done   .lstep-icon { background: #d1fae5; }
.lstep.active .lstep-icon { background: #dbeafe; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ---- INFO BOX ---- */
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 16px 18px; }
.info-box p { font-size: 14px; color: #1e3a8a; line-height: 1.6; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 16px 18px; }
.warn-box p { font-size: 14px; color: #78350f; line-height: 1.6; }

/* ---- DOC CARD ---- */
.doc-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 22px; display: flex; gap: 18px; }
.doc-icon { width: 52px; height: 52px; border-radius: 12px; background: #eff6ff; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.doc-info h4 { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.doc-info p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.doc-ley { display: inline-block; font-size: 11px; background: #ede9fe; color: #5b21b6; padding: 2px 8px; border-radius: 10px; margin-top: 6px; font-weight: 500; }

/* ---- LEGAL PAGE ---- */
.legal-container { max-width: 760px; margin: 0 auto; padding: 40px 32px; }
.legal-section { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin-bottom: 16px; }
.legal-section h3 { font-family: 'Sora', sans-serif; font-size: 16px; font-weight: 600; color: var(--navy); margin-bottom: 10px; }
.legal-section p, .legal-section li { font-size: 14px; color: #374151; line-height: 1.75; }
.legal-section ul { padding-left: 20px; margin-top: 8px; }

/* ---- SCORE ---- */
.score-hero { background: var(--navy); border-radius: 16px; padding: 32px; color: #fff; text-align: center; }
.score-value { font-family: 'Sora', sans-serif; font-size: 64px; font-weight: 700; color: var(--cyan); }

/* ---- CONTACT ---- */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 20px; }
.contact-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.contact-item-icon { font-size: 28px; margin-bottom: 10px; }
.contact-item label { font-size: 12px; color: var(--muted); font-weight: 500; display: block; margin-bottom: 4px; }
.contact-item p { font-size: 15px; color: var(--navy); font-weight: 500; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .dash-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 28px; }
  .navbar { padding: 0 16px; }
  .section { padding: 40px 16px; }
  .lender-card { flex-wrap: wrap; }
}

/* ============================================================
   MOBILE NAVIGATION — Bottom nav + topbar
   ============================================================ */

/* Topbar solo visible en móvil */
.mobile-topbar {
  display: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 150;
}

/* Bottom nav bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  justify-content: space-around;
  align-items: center;
}

.mbn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  text-decoration: none;
  color: var(--muted);
  border-radius: 10px;
  transition: all .15s;
  flex: 1;
}

.mbn-item.active {
  color: var(--sky);
}

.mbn-item.active .mbn-icon {
  background: #eff6ff;
  border-radius: 10px;
  padding: 4px 8px;
}

.mbn-icon {
  font-size: 20px;
  line-height: 1;
}

.mbn-label {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================================
   RESPONSIVE — Mobile fixes
   ============================================================ */
@media (max-width: 768px) {

  /* Layout */
  .dash-layout {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }

  /* Ocultar sidebar desktop */
  .sidebar {
    display: none !important;
  }

  /* Mostrar topbar y bottom nav */
  .mobile-topbar {
    display: flex;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  /* Dar espacio al bottom nav */
  .dash-main {
    padding: 16px 14px 90px;
  }

  /* Tarjetas de entidades en móvil */
  .lender-card {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
  }

  .lender-card > a.btn {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .lender-thumb {
    width: 44px;
    height: 44px;
  }

  .lender-name {
    font-size: 14px;
  }

  /* Stats */
  .stats-row {
    grid-template-columns: 1fr 1fr;
    padding: 20px 16px;
    gap: 12px;
  }

  /* Hero */
  .hero {
    padding: 48px 20px 40px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero-btns {
    flex-direction: column;
    align-items: center;
  }

  /* Navbar pública */
  .navbar {
    padding: 0 16px;
  }

  .nav-links {
    gap: 12px;
  }

  .nav-links a:not(.btn-nav) {
    display: none;
  }

  /* Section */
  .section {
    padding: 36px 16px;
  }

  /* Forms */
  .form-card {
    padding: 20px 16px;
  }

  /* Tablas admin en móvil */
  .table-card {
    overflow-x: auto;
  }

  /* Admin sidebar — también ocultar en móvil */
  .admin-sidebar {
    display: none !important;
  }

  /* Grid admin forms */
  .dash-main div[style*="grid-template-columns:1fr 1fr"],
  .dash-main div[style*="grid-template-columns: 1fr 1fr"] {
    display: block !important;
  }

  /* Loading page */
  .loading-steps {
    padding: 0 8px;
  }

  /* Doc cards */
  .doc-card {
    flex-direction: column;
  }

  /* Testimonios */
  .testimonios-grid {
    grid-template-columns: 1fr;
  }

  /* Features */
  .features-grid {
    grid-template-columns: 1fr;
  }

  /* Steps */
  .steps-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Legal */
  .legal-container {
    padding: 24px 16px;
  }

  /* Score hero */
  .score-value {
    font-size: 48px;
  }

  /* Footer */
  footer {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
    gap: 12px;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
  .mbn-label {
    font-size: 9px;
  }
  .hero h1 {
    font-size: 22px;
  }
}
