/* ============================================================
   Împrumut 247 — mobile.css
   Tối ưu di động — nạp CUỐI CÙNG để override. Fix các lỗi mobile.
   ============================================================ */

/* ---- 1. Chống tràn ngang toàn cục ---- */
html, body { overflow-x: hidden; max-width: 100%; }
* { min-width: 0; }                 /* cho phép flex/grid item co lại, không đẩy tràn */
img, svg, video { max-width: 100%; height: auto; }
/* từ dài (URL, email) không phá layout */
p, li, td, a, .field__hint, .offer-card__apr, .footer__disclaimer p { overflow-wrap: break-word; word-wrap: break-word; }

/* ---- 2. Input ≥ 16px trên mobile: chống iOS tự zoom khi focus ---- */
@media (max-width: 768px) {
  .field input,
  .field select,
  .modal__form .field input,
  .modal__form .field select,
  .calc-field input[type="number"] {
    font-size: 16px !important;
  }
}

/* ============================================================
   TABLET & MOBILE ≤ 768px
   ============================================================ */
@media (max-width: 768px) {
  /* Container padding gọn hơn để không phí không gian */
  .container { padding: 0 16px; }

  /* Section spacing: thoáng hơn để các phần không dính vào nhau */
  .section { padding: 64px 0; }
  .section__subtitle { margin-bottom: 32px; }
  .info-card { padding: 24px 20px; }

  /* Stats band: số flagship to & tự tin hơn */
  .stat-item strong { font-size: 2rem; }
  .stats-band { padding: 36px 0; }
  .stats-band__grid { gap: 26px 10px; }
  /* Hàng 2 (item 3-4) có hairline phân cách với hàng 1 */
  .stats-band__grid .stat-item:nth-child(n+3) {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 20px;
  }

  /* Trustbar + partners: cuộn ngang 1 hàng thay vì wrap lộn xộn */
  .trustbar__inner { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .trustbar__inner::-webkit-scrollbar { display: none; }
  .trustbar__inner > span { white-space: nowrap; flex-shrink: 0; }
  .partner-chip { flex-shrink: 0; white-space: nowrap; }

  /* Hero: chữ vừa phải, không quá to gây tràn */
  .hero { padding: 36px 0 52px; }
  .hero h1 { font-size: clamp(1.6rem, 6.5vw, 2.1rem); letter-spacing: -0.5px; }
  .hero__subtitle { font-size: 1rem; }
  .hero__rating { flex-wrap: wrap; font-size: .84rem; }

  /* Header: hiện lại nút "Aplică acum" (nhỏ) cạnh burger — tăng conversion */
  .header__inner { gap: 10px; }
  .header__cta { display: inline-flex !important; padding: 8px 14px; font-size: 0.82rem; }
  .logo { font-size: 1.15rem; }
}

/* ============================================================
   MOBILE ≤ 560px
   ============================================================ */
@media (max-width: 560px) {
  .hero h1 { font-size: clamp(1.5rem, 7vw, 1.9rem); }
  .section__title { font-size: clamp(1.4rem, 6vw, 1.85rem); }

  /* Ẩn CTA header trên màn rất hẹp để burger + logo có chỗ */
  .header__cta { display: none !important; }

  /* Badge: bo mềm + chấm căn đầu dòng nếu xuống 2 dòng */
  .hero__badge {
    font-size: 0.76rem;
    padding: 8px 15px 8px 13px;
    border-radius: 16px;
    align-items: flex-start;
    line-height: 1.35;
  }
  .hero__badge::before { margin-top: 4px; }

  /* Hero USP: 3 ô cùng 1 hàng, gọn → icon trên, số + nhãn dưới, căn giữa */
  .hero__trust {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .trust-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 7px;
    padding: 14px 6px;
    background: linear-gradient(160deg, rgba(255,255,255,0.13), rgba(255,255,255,0.05));
  }
  .trust-item__icon {
    width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px;
    flex: 0 0 auto;
    background: rgba(190, 242, 100, 0.22);
  }
  .trust-item__body { display: flex; flex-direction: column; align-items: center; }
  .trust-item strong { font-size: 1.05rem; letter-spacing: -0.3px; line-height: 1.1; white-space: nowrap; }
  .trust-item span { font-size: 0.66rem; line-height: 1.2; color: rgba(255,255,255,0.82); margin-top: 2px; }

  /* Section CTA button full-width dễ bấm */
  .section__cta .btn,
  .cta-banner__inner .btn { width: 100%; max-width: 340px; }

  /* Form card padding gọn */
  .form-card { padding: 22px 16px; }
  .form-card__badge { right: 14px; font-size: .68rem; }

  /* Table: cho phép cuộn ngang mượt, gợi ý vuốt */
  .table-wrap { -webkit-overflow-scrolling: touch; position: relative; }
  .cmp-table { font-size: 0.84rem; }
  .cmp-table th, .cmp-table td { padding: 10px 12px; }

  /* Article padding trên mobile */
  .article { padding: 26px 18px; border-radius: 16px; }
  .article-wrap .container > :first-child { margin-top: -40px; }

  /* TL;DR, verdict, cta-box gọn */
  .tldr, .verdict, .related, .author-box { padding: 18px 16px; }
  .cta-box { padding: 22px 18px; }

  /* Testimonials/benefit/step cards padding */
  .benefit, .step-card, .testimonial, .gcard { padding: 22px 18px; }

  /* Footer: 2 cột trên mobile → gọn, không lê thê */
  .footer { padding: 44px 0 24px; }
  .footer__grid--wide { grid-template-columns: 1fr 1fr; gap: 24px 18px; }
  .footer__col--brand { grid-column: 1 / -1; }
  .footer__col a { font-size: 0.92rem; }

  /* Logo footer: giống hệt logo header → cân đối */
  .logo--footer { font-size: 1.15rem; margin-bottom: 12px; gap: 8px; align-items: center; }
  .logo--footer .logo__leaf { flex: 0 0 auto; }

  /* Partner logos: cuộn ngang, giãn cách rộng, logo to */
  /* Marquee mobile: logo nhỏ hơn chút, chạy nhanh hơn */
  .partners__track { gap: 44px; animation-duration: 22s; }
  .partners__logo { height: 50px; max-width: 150px; }
  .partner-chip { font-size: 0.95rem; }

  /* Logo bảng offer trên mobile: gọn hơn chút để không phá layout bảng hẹp */
  .cmp-brand { gap: 8px; }
  .cmp-brand__logo,
  .cmp-brand__initial { width: 68px; height: 38px; padding: 5px 6px; }
  .cmp-brand__initial { font-size: 1rem; }
  .th-brand__logo { width: 64px; height: 34px; }
}

/* ============================================================
   OFFER CARD trên mobile (popup + trang /oferte/)
   1 cột: logo hàng ngang trên, nội dung dưới
   ============================================================ */
@media (max-width: 560px) {
  .offer-card { grid-template-columns: 1fr !important; }
  .offer-card__brand {
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    border-right: none;
    border-bottom: 1.5px solid var(--border);
    padding: 16px 18px;
  }
  .offer-card__logo { max-width: 130px; height: 52px; margin: 0; }
  .offer-card__rating { flex-direction: column; align-items: flex-start; text-align: left; }
  .offer-card__body { padding: 18px; gap: 14px; }
  .offer-card__usp { font-size: .82rem; padding: 7px 13px; }
  .offer-card__facts { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .offer-card__ribbon { font-size: .66rem; padding: 5px 12px 5px 11px; }

  /* CTA: note trên, nút full-width dưới */
  .offer-card__action { flex-direction: column; align-items: stretch; gap: 12px; }
  .offer-card__action .btn { width: 100%; justify-content: center; min-width: 0; }
  .offer-card__apr { text-align: center; }
}

/* ============================================================
   MODAL POPUP trên mobile — bottom sheet, cuộn mượt
   ============================================================ */
@media (max-width: 680px) {
  /* Modal căn GIỮA màn hình (không dính đáy) + cho cuộn nếu dài */
  .modal { padding: 16px 12px; align-items: center; justify-content: center; overflow-y: auto; }
  .modal__dialog,
  .modal__dialog--wide {
    max-width: 100% !important;
    width: 100%;
    max-height: 90vh;
    margin: auto;
    border-radius: 20px;
  }
  .modal__header { padding: 22px 20px 18px; }
  .modal__header h3 { font-size: 1.15rem; }
  .modal__form { padding: 20px 18px 22px; }
  .modal__summary { padding: 10px 6px; }
  .modal__summary-item strong { font-size: .95rem; }
  .modal__trust { gap: 10px 14px; font-size: .72rem; }

  /* Offers screen trong popup */
  .moffers__head { padding: 24px 18px 18px; }
  .moffers__head h3 { font-size: 1.3rem; }
  .moffers__list { padding: 18px 16px 8px; }
  .moffers__tip { font-size: .8rem; padding: 8px 14px; }

  /* Loading trong popup */
  .mloading { padding: 40px 20px 36px; }
}

/* ============================================================
   NAV MOBILE — OFF-CANVAS DRAWER (làm lại chuẩn, ≤ 900px)
   Drawer trượt từ phải, có backdrop mờ, header riêng (logo + X)
   bên trong drawer → KHÔNG phụ thuộc header sticky, không lỗi.
   ============================================================ */
@media (max-width: 900px) {
  .burger { display: flex !important; }
  body.nav-open { overflow: hidden; }
  /* Header vẫn hiện (logo + burger→X) — nút X cũng có sẵn trong drawer */
  .header { z-index: 1100; }

  /* .nav = lớp phủ toàn màn hình (backdrop mờ). Ẩn/hiện qua opacity. */
  .nav {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(13, 34, 20, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
  }
  .nav.open { opacity: 1; visibility: visible; }

  /* .nav__list = DRAWER trắng trượt từ phải, phủ full cao (header nổi trên) */
  .nav__list {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(86vw, 400px);
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 0 40px;   /* thanh close bar (nav__bar) chiếm chỗ đầu drawer */
    box-shadow: -8px 0 32px rgba(0,0,0,.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .nav.open .nav__list { transform: translateX(0); }
  .nav__group { width: 100%; }

  /* Thanh đầu drawer: nhãn "Meniu" + nút X (đóng) — sticky trên cùng */
  .nav__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 22px;
    height: 64px;
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    z-index: 3;
  }
  .nav__bar-brand {
    font-weight: 800;
    font-size: .78rem;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .nav__bar-close {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: var(--bg-alt); border-radius: 50%;
    color: var(--primary-dark); font-size: 26px; line-height: 1; cursor: pointer;
  }
  .nav__bar-close:hover { background: var(--primary-light); }

  /* Nút toggle nhóm = hàng full-width, có mũi tên */
  .nav__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 22px;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: 1px solid var(--border);
    background: none;
  }
  .nav__toggle::after {
    content: "";
    width: 9px; height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s ease;
    margin-left: 12px;
    opacity: .5;
  }
  .nav__group.open > .nav__toggle::after { transform: rotate(-135deg); }

  /* Accordion dropdown — reset HOÀN TOÀN vị trí absolute của desktop */
  .nav__dropdown,
  .nav__group.open > .nav__dropdown {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: var(--bg-alt);
    padding: 4px 0 10px;
    min-width: 0;
    width: 100%;
    max-height: none;
    opacity: 1;
    visibility: visible;
  }
  .nav__dropdown::before { display: none; }   /* mũi tên tam giác của desktop */
  .nav__group.open > .nav__dropdown { display: block; }
  .nav__dropdown a {
    padding: 12px 22px 12px 34px;
    min-height: 46px;
    display: flex;
    align-items: center;
    font-size: .95rem;
    color: var(--text);
  }
  .nav__dropdown a:hover { background: var(--primary-light); padding-left: 34px; }
  .nav__dropdown .nav__dd-head { display: block; padding: 12px 22px 4px; font-size: .7rem; }
  .nav__dropdown hr { margin: 4px 22px; }
  .nav__dropdown a.nav__more { padding-left: 22px; font-weight: 700; color: var(--primary); }

  /* Link top-level không có dropdown (Întrebări frecvente) */
  .nav > .nav__list > li:not(.nav__group) > a {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 16px 22px;
    font-weight: 700;
    color: var(--primary-dark);
    border-bottom: 1px solid var(--border);
  }

}

/* ---- 3. Touch targets: nút/icon đủ lớn (≥44px) ---- */
@media (max-width: 768px) {
  .btn { min-height: 46px; }
  .modal__close { width: 40px; height: 40px; }
  .faq__item summary { min-height: 52px; display: flex; align-items: center; padding-right: 52px; }

  /* Slider: track mảnh 8px (khớp fill gradient), thumb to hơn để dễ chạm.
     KHÔNG tăng height của input — sẽ kéo giãn track fill và lệch thumb. */
  input[type="range"] { height: 8px; }
  input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; }
  input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
}

/* ---- 4. Calculator + bảng: chống tràn trên màn hẹp ---- */
@media (max-width: 560px) {
  /* ô số của calculator nhỏ lại để slider + input vừa 1 hàng */
  .calc-field input[type="number"] { width: 92px; font-size: 15px !important; padding: 10px 8px; }
  .calc-field .row { gap: 10px; }
  .calc-panel { padding: 20px 16px; }
  .calc-grid { gap: 16px; }
  /* gợi ý vuốt bảng: viền mờ bên phải cho biết còn nội dung */
  .table-wrap { position: relative; }
}
/* Hero form: đảm bảo không tràn, bo trong container */
@media (max-width: 900px) {
  .form-card, .hero__aside, .hero__form { max-width: 100%; }
}
