/* ==========================================================================
   BAMFLOW — trial.css (2026-09-27, #32 #34)
   Form "Dùng thử ứng dụng mẫu" (hộp thoại #trialModal) + nút mở nó ở header, ngăn kéo menu
   và thẻ lĩnh vực trang Dự án; trang kích hoạt activate.html.
   Hộp thoại dùng lại nguyên lớp của form tư vấn (.modal-*, .form, .field, .form__status):
   tệp này chỉ thêm phần riêng — ô đồng ý, dòng lỗi đỏ, màn "kiểm tra hộp thư", nút dùng thử.
   Nạp SAU theme-fluent-glass.css (và du-an.css trên trang Dự án).
   Mục 6 (mobile-014): điện thoại / máy tính bảng cho cả hai hộp thoại, header, ngăn kéo menu và trang kích hoạt.
   ========================================================================== */

/* ---------- 1. Nút "Dùng thử" trên thanh header ---------- */
.header__actions .header__trial {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; flex: 0 0 auto;
  border: 1px solid #bfdbfe; border-radius: 999px; background: #ffffff; color: #1d4ed8;
  font-size: var(--text-sm); font-weight: 600; line-height: 1; white-space: nowrap; box-shadow: none;
}
.header__actions .header__trial:hover { background: #eef4ff; border-color: #93c5fd; color: #133c9f; }
.header__actions .header__trial:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.header__trial svg { width: 14px; height: 14px; flex: none; }
/* trên hero xanh đậm, header chưa dính: viền trắng mảnh như nút ngôn ngữ */
.has-hero-dark .header:not(.is-stuck) .header__actions .header__trial {
  background: transparent; color: #ffffff; border-color: rgba(255, 255, 255, 0.55);
}
.has-hero-dark .header:not(.is-stuck) .header__actions .header__trial:hover { background: rgba(255, 255, 255, 0.12); border-color: #ffffff; }
.has-hero-dark .header:not(.is-stuck) .header__actions .header__trial:focus-visible { outline-color: #ffffff; }
/* ≤1140px: style.css ẩn mọi .btn trong .header__actions (nút tư vấn chuyển vào ngăn kéo).
   Nút dùng thử vẫn ở trên thanh, gọn như nút menu (36px, bo 8px). */
@media (max-width: 1140px) {
  .header__actions > .btn.header__trial { display: inline-flex; height: 36px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
}
/* Điện thoại: khoảng cách logo ↔ cụm nút và giữa các nút gọn lại để nút dùng thử vừa thanh ở 380–414px */
@media (max-width: 480px) {
  .header .header__inner { gap: 12px; }
  .header .header__actions { gap: 8px; }
  .header__actions > .btn.header__trial { padding: 0 10px; }
}
/* Điện thoại hẹp (<380px): logo + nút ngôn ngữ + nút menu đã chiếm gần hết thanh → nút dùng thử chỉ ở ngăn kéo */
@media (max-width: 379px) {
  .header__actions > .btn.header__trial { display: none; }
}
html:not(.js) .header__actions > .btn.header__trial { display: none; }

/* ---------- 2. Nút "Dùng thử app mẫu" trong ngăn kéo menu (≤1140px) ---------- */
.header .nav .nav__cta.nav__cta--trial,
.has-hero-dark .header:not(.is-stuck) .nav .nav__cta.nav__cta--trial {
  margin-top: 10px; background: #ffffff; color: #1d4ed8; border: 1px solid #bfdbfe; box-shadow: none;
}
.header .nav .nav__cta.nav__cta--trial:hover { background: #eef4ff; border-color: #93c5fd; }
@media (min-width: 1141px) {
  .header .nav .nav__cta.nav__cta--trial { display: none; }
}

/* ---------- 3. Nút dùng thử trên thẻ lĩnh vực (du-an.html) ---------- */
.dcard__trial { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; }
.dcard__try {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 8px 14px;
  appearance: none; cursor: pointer;
  border: 1px solid #bfdbfe; border-radius: 999px; background: #ffffff; color: #1d4ed8;
  font: 600 0.88rem/1.2 var(--font-body); text-align: left;
  transition: background 200ms ease, border-color 200ms ease, transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.dcard__try svg { width: 12px; height: 12px; flex: none; }
.dcard__try:hover { background: #eef4ff; border-color: #93c5fd; transform: translateY(-1px); }
.dcard__try:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }
@media (pointer: coarse) { .dcard__try { min-height: 44px; } }
/* lưới nhiều thẻ: đẩy hàng nút xuống đáy để các thẻ cùng hàng thẳng nút */
.dg__grid:not(.is-solo) .dcard__body { display: flex; flex-direction: column; flex: 1 1 auto; }
.dg__grid:not(.is-solo) .dcard__trial { margin-top: auto; }
.dg__grid.is-solo .dcard__trial { padding-top: 20px; }
.dg__grid.is-solo .dcard__trial + .dcard__cta { margin-top: 14px; }

/* ---------- 4. Hộp thoại dùng thử ---------- */
#trialModal .modal-header { padding-right: 48px; }
/* .modal-form đặt display:flex → thuộc tính hidden (màn cảm ơn thay form) cần luật riêng */
#trialModal .modal-form[hidden] { display: none; }
#trialModal .modal-container { max-width: 560px; }
#trialModal .field select.custom-select:invalid { color: #64748b; }
#trialModal .field select.custom-select option { color: #0b1633; }
#trialModal .field select.custom-select option:disabled { color: #94a3b8; }

/* ô đồng ý */
.trial-consent { display: grid; gap: 4px; }
.trial-consent__label {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 0.84rem; line-height: 1.5; color: #334155;
}
.trial-consent__label input[type="checkbox"] {
  flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: #1d4ed8; cursor: pointer;
}
.trial-consent.has-error .trial-consent__label input[type="checkbox"] { outline: 2px solid #dc2626; outline-offset: 1px; }
.trial-consent .field__error { display: none; }
.trial-consent.has-error .field__error { display: block; }

/* dòng báo lỗi / chọn cách gửi khác: nền đỏ nhạt thay cho nền xanh lá "đã ghi nhận" */
#trialStatus.trial-status--error[data-visible="true"] {
  display: grid; gap: 10px; align-items: start; text-align: left;
  padding: 12px 14px; border-radius: 12px;
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 0.9rem; line-height: 1.5;
}
#trialStatus .form__status-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#trialStatus .form__status-btn { padding: 9px 14px; font-size: 0.9rem; min-height: 40px; }

/* màn "kiểm tra hộp thư" sau khi gửi thành công */
.trial-done { display: grid; gap: 14px; padding: 4px 0 24px; overflow-y: auto; min-height: 0; }
.trial-done[hidden] { display: none; }
.trial-done:focus { outline: none; }
.trial-done__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%; background: #dcfce7; color: #15803d;
}
.trial-done__icon svg { width: 24px; height: 24px; }
.trial-done__title { margin: 0; font-size: 1.2rem; line-height: 1.35; color: #0b1633; }
.trial-done__lead { margin: 0; font-size: 0.95rem; line-height: 1.55; color: #334155; overflow-wrap: anywhere; }
.trial-done__lead b { color: #0b1633; }
.trial-done__steps { margin: 0; padding-left: 20px; list-style: disc; display: grid; gap: 6px; font-size: 0.9rem; line-height: 1.5; color: #475569; }
.trial-done__actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.trial-done__actions .btn { padding: 10px 18px; font-size: 0.92rem; border-radius: 10px; }
#trialModal .trial-done__actions .btn--ghost { background: #ffffff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---------- 5. Trang kích hoạt (activate.html) ---------- */
.act-page { min-height: 100vh; display: flex; flex-direction: column; background: #f4f7fc; }
.act-page .act-top { padding: 18px 0; }
.act-page .act-top .container { display: flex; align-items: center; justify-content: space-between; }
.act-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: clamp(24px, 8vh, 96px) 16px 48px; }
.act-card {
  width: 100%; max-width: 520px; display: grid; gap: 16px;
  padding: 28px 28px 26px; border-radius: 20px;
  background: #ffffff; border: 1px solid #e2e8f0; box-shadow: 0 30px 60px -40px rgba(29, 78, 216, 0.45);
}
.act-card__title { margin: 0; font-size: 1.35rem; line-height: 1.35; color: #0b1633; }
.act-card__title:focus { outline: none; }
.act-card__status { margin: 0; font-size: 0.95rem; line-height: 1.6; color: #334155; }
.act-card[data-state="error"] .act-card__status { color: #991b1b; }
.act-card[data-state="ok"] .act-card__status { color: #166534; }
.act-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid #dbeafe; border-top-color: #1d4ed8; animation: act-spin 800ms linear infinite;
}
.act-spinner[hidden] { display: none; }
@keyframes act-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .act-spinner { animation-duration: 2400ms; } }
.act-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.act-actions[hidden] { display: none; }
.act-actions .btn { padding: 10px 18px; font-size: 0.92rem; border-radius: 10px; }
.act-actions .btn[hidden] { display: none; }
.act-actions .btn--ghost { background: #ffffff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.act-manual { display: grid; gap: 8px; }
.act-manual[hidden] { display: none; }
.act-manual label { font-size: 0.85rem; font-weight: 600; color: #334155; }
.act-manual__row { display: flex; gap: 8px; }
.act-manual input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px;
  font: inherit; font-size: 0.92rem; color: #0b1633; background: #ffffff;
}
.act-manual input:focus { outline: 2px solid #1d4ed8; outline-offset: 1px; border-color: #1d4ed8; }
.act-manual input[aria-invalid="true"] { border-color: #dc2626; }
.act-manual .btn { padding: 10px 16px; font-size: 0.92rem; border-radius: 10px; white-space: nowrap; }
.act-manual__error { margin: 0; font-size: 0.82rem; color: #b91c1c; }
.act-manual__error[hidden] { display: none; }
.act-note { margin: 0; font-size: 0.8rem; line-height: 1.5; color: #64748b; }
@media (max-width: 480px) {
  .act-card { padding: 22px 18px 20px; }
  .act-manual__row { flex-direction: column; }
}

/* ---------- 6. Soát điện thoại / máy tính bảng (mobile-014, 2026-09-27) ----------
   Đo bằng Edge không giao diện, giả lập điện thoại 360/390/414 · 768 · ngang 844×390 · máy tính 1440/1920
   (bamflow-vn/demo-apps/mobile-014/site/). Chỉ sửa cỡ chữ ô nhập, vùng chạm, chỗ xuống dòng và phần cuộn;
   màu và bố cục giữ nguyên. */

/* 6a. Ô nhập ≥ 16px trên điện thoại và máy cảm ứng: iPhone/iPad (Safari) tự phóng to cả trang khi chạm vào ô
   có chữ < 16px và giữ nguyên mức phóng → hộp thoại lệch khỏi màn hình. Form dùng thử, form tư vấn, ô dán link kích hoạt. */
@media (max-width: 767px), (pointer: coarse) {
  .modal-container .field input,
  .modal-container .field select,
  .modal-container .field textarea,
  .act-manual input { font-size: 16px; }
  /* chữ 16px: bớt lề trong của ô chọn để tên app / nội dung còn vừa ô đóng */
  .modal-container .field select.custom-select { padding-left: 12px; padding-right: 36px; background-position: right 10px center; }
}

/* 6b. Vùng chạm ≥ 44px trên màn hình cảm ứng */
@media (pointer: coarse) {
  /* thanh header giữ dáng 36px; vùng bấm nới thêm 5px trên/dưới (lớp ::after trong suốt) */
  .header .lang-toggle, .header__actions .header__trial, .header .nav-toggle { position: relative; }
  .header .lang-toggle::after, .header__actions .header__trial::after, .header .nav-toggle::after {
    content: ""; position: absolute; inset: -5px 0;
  }
  /* logo về trang chủ: cao 26px → vùng bấm 44px, bố cục không đổi */
  .header .logo { padding-block: 9px; margin-block: -9px; }
  /* bộ lọc lĩnh vực trang Dự án */
  .dchips .dchip { min-height: 44px; }
  /* dòng báo lỗi (gửi yêu cầu cho BAMFLOW), màn "kiểm tra hộp thư", form tư vấn (email/Zalo), trang kích hoạt */
  #trialStatus .form__status-btn,
  .form__status--choose .form__status-btn,
  .trial-done__actions .btn,
  .act-actions .btn,
  .act-manual .btn,
  .act-manual input { min-height: 44px; }
}

/* 6c. Ngăn kéo menu (≤1140px): mục cao ≥ 44px trên màn hình cảm ứng; ngăn kéo cao hơn màn hình (điện thoại xoay
   ngang, 390px) thì cuộn trong ngăn — trước đây nút "Dùng thử app mẫu" nằm lọt dưới mép màn hình, không với tới. */
@media (max-width: 1140px) {
  .header .nav {
    max-height: calc(100vh - var(--header-h, 72px) - 24px);
    max-height: calc(100dvh - var(--header-h, 72px) - 24px);
    overflow-y: auto; overscroll-behavior: contain;
  }
}
@media (max-width: 1140px) and (pointer: coarse) {
  /* "NocoBase Partner" mang display:block ở theme (vòng 102c/108, bộ chọn dài) → lặp lại đủ các bộ chọn đó */
  .header .nav .nav__link,
  .header .nav .nav__link.nav__link--partner,
  .header .nav .nav__link.nav__link--partner:hover,
  .header .nav .nav__link.nav__link--partner.is-active,
  .has-hero-dark .header:not(.is-stuck) .nav .nav__link.nav__link--partner,
  .has-hero-dark .header:not(.is-stuck) .nav .nav__link.nav__link--partner:hover,
  .has-hero-dark .header:not(.is-stuck) .nav .nav__link.nav__link--partner.is-active { min-height: 44px; display: flex; align-items: center; }
}

/* 6d. Màn hình thấp (điện thoại xoay ngang ≤ 520px): cả hộp thoại cuộn một khối thay vì chỉ phần form
   (phần form còn ~110px giữa tiêu đề và nút Gửi); nút Gửi vẫn dính ở đáy khung. */
@media (max-height: 520px) {
  .modal-overlay .modal-container { overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 72px; }
  .modal-overlay .modal-form { overflow: visible; min-height: auto; flex: none; }
  .modal-overlay .modal-form .form__note { position: static; }
  .modal-overlay .modal-form > .btn[type="submit"] { bottom: 0; }
}

/* 6e. Số điện thoại không bị bẻ đôi: link Zalo trong đoạn văn (FAQ, liên hệ, chân trang).
   Ví dụ số trong dòng lỗi của form dùng thử được bọc <span class="nowrap"> trong HTML. */
a[href^="https://zalo.me/"]:not(.btn) { white-space: nowrap; }

/* 6f. Trang kích hoạt trên điện thoại: dòng báo lỗi nằm ngay dưới ô dán link (trước nút Kích hoạt) */
@media (max-width: 480px) {
  .act-manual__row { display: contents; }
  .act-manual input { order: 1; }
  .act-manual__error { order: 2; }
  .act-manual .btn { order: 3; }
}
