/* Legal pages — Privacy & Terms 2026-04-21 */

/* P3.0 (2026-05-24): iOS-only hide. Apple Guideline 2.3.10 cấm references
   Google Play trong app binary. Ẩn "Google Play Billing" trong legal pages
   khi load qua iOS app. Android + web vẫn hiện. */
html.is-platform-ios [data-ios-hide],
html.is-platform-ios [data-ios-hide="true"] { display: none !important; }

:root {
  --legal-bg: #f6f7fb;
  --legal-surface: #fff;
  --legal-text: #1f2940;
  --legal-muted: #5b657c;
  --legal-line: #e7eaf2;
  --legal-primary: #4f6ef7;
  --legal-primary-strong: #3d5ae5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--legal-bg);
  color: var(--legal-text);
  font-family: 'Nunito', 'Avenir Next', Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

html[lang="my"] body {
  font-family: 'Noto Sans Myanmar', 'Nunito', Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.7;
}

/* 2026-04-24: đồng bộ header với module/profile/hoithoai — back plain 22px
   flex-center, title UPPERCASE 20/600, container relative để back absolute. */
.legal-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: var(--legal-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.legal-back {
  position: absolute;
  left: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 4px;
  background: transparent;
  border: 0;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  transition: opacity 0.15s, transform 0.1s;
}
.legal-back:hover, .legal-back:focus-visible { opacity: 0.8; background: transparent; outline: none; }
.legal-back:active { transform: scale(0.92); }

/* 2026-05-04: Standalone lang switcher CSS — copy từ styles.css vì legal pages
   KHÔNG load styles.css. Trước khi có rule này, menu hiện inline horizontal đè title. */
.lang-wrap { position: relative; display: inline-flex; }

.legal-topbar .lang-wrap .lang-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.legal-topbar .lang-wrap .lang-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}
.legal-topbar .lang-wrap .lang-btn .lang-flag { font-size: 14px; line-height: 1; }
.legal-topbar .lang-wrap .lang-btn .lang-code { font-size: 11px; font-weight: 700; }
.legal-topbar .lang-wrap .lang-btn .lang-caret { font-size: 9px; opacity: 0.8; }
.legal-topbar .lang-wrap .lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

/* Dropdown menu — vertical column thay vì horizontal default */
.legal-topbar .lang-wrap .lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: max-content;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(47, 55, 82, 0.22);
  padding: 4px;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.legal-topbar .lang-wrap .lang-menu[hidden] { display: none; }

.legal-topbar .lang-wrap .lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: #2d3a5b;
  font-size: 13.5px;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  min-height: 40px;
}
.legal-topbar .lang-wrap .lang-option:hover { background: #fef2ec; }
.legal-topbar .lang-wrap .lang-option.is-active { background: #ffe8da; color: #d95a2a; font-weight: 700; }
.legal-topbar .lang-wrap .lang-option .lang-flag { font-size: 16px; line-height: 1; }
.legal-topbar .lang-wrap .lang-option-label { flex: 1; }

/* 2026-05-03: Lang switcher slot — mount qua lang-switcher.js. Position absolute right
   để giữ title center. Reuse styles .lang-btn/.lang-menu từ styles.css. */
.lang-switcher-slot {
  position: absolute;
  right: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
}
/* Override màu cho legal context (header tím, lang-btn cần trắng nổi bật) */
.legal-topbar .lang-switcher-slot .lang-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 999px;
}
.legal-topbar .lang-switcher-slot .lang-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}
.legal-topbar .lang-switcher-slot .lang-btn .lang-flag { font-size: 14px; }
.legal-topbar .lang-switcher-slot .lang-btn .lang-code { font-size: 11px; font-weight: 700; }
.legal-topbar .lang-switcher-slot .lang-btn .lang-caret { font-size: 9px; opacity: 0.8; }

/* Title cần thêm padding-right để không bị lang-switcher đè */
.legal-title { padding-right: 80px; }

@media (max-width: 380px) {
  .lang-switcher-slot { right: 8px; }
  .legal-topbar .lang-switcher-slot .lang-btn { padding: 4px 7px; }
  .legal-topbar .lang-switcher-slot .lang-btn .lang-code,
  .legal-topbar .lang-switcher-slot .lang-btn .lang-caret { display: none; }
  .legal-title { padding: 0 48px; font-size: 17px; }
}

.legal-title {
  margin: 0;
  padding: 0 64px;
  width: 100%;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1px;
  text-align: center;
  text-transform: uppercase;
  overflow: visible;
  white-space: nowrap;
}

.legal-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.legal-updated {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--legal-muted);
  font-style: italic;
}

.legal-content section {
  background: var(--legal-surface);
  border: 1px solid var(--legal-line);
  border-radius: 14px;
  padding: 18px 18px 14px;
  margin-bottom: 14px;
}

.legal-content h2 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--legal-primary-strong);
  line-height: 1.3;
}

.legal-content p {
  margin: 8px 0;
  font-size: 14.5px;
  color: var(--legal-text);
}

.legal-content ul {
  margin: 8px 0;
  padding-left: 22px;
}

.legal-content li {
  margin-bottom: 6px;
  font-size: 14.5px;
  line-height: 1.55;
}

.legal-content a {
  color: var(--legal-primary);
  text-decoration: none;
  font-weight: 600;
}
.legal-content a:hover { text-decoration: underline; }

.legal-contact {
  padding: 10px 12px;
  background: #f0f3ff;
  border-radius: 8px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.legal-backlink {
  margin-top: 28px;
  text-align: center;
  font-size: 15px;
}
.legal-backlink a { color: var(--legal-primary-strong); }

/* 2026-05-03: legal table cho privacy/terms (data processors, user rights, retention) */
.legal-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 18px 0 10px;
  color: var(--legal-text-strong, #2a3144);
}

.legal-content table.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  font-size: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.legal-content table.legal-table thead th {
  background: #f3f4f7;
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  color: #2a3144;
  border-bottom: 1px solid #e5e7eb;
}
.legal-content table.legal-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid #f1f3f7;
  vertical-align: top;
  line-height: 1.5;
}
.legal-content table.legal-table tbody tr:nth-child(even) {
  background: #fafbff;
}
.legal-content table.legal-table tbody td a {
  font-weight: 500;
  font-size: 13px;
}

@media (max-width: 720px) {
  /* Tables responsive: scroll horizontal trên mobile (tránh squeeze chật) */
  .legal-content table.legal-table {
    display: block;
    overflow-x: auto;
    white-space: normal;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
  }
  .legal-content table.legal-table thead { font-size: 12.5px; }
  .legal-content table.legal-table th,
  .legal-content table.legal-table td { padding: 8px 10px; min-width: 90px; }
}

@media (max-width: 480px) {
  .legal-content { padding: 16px 12px 40px; }
  .legal-content section { padding: 14px 14px 10px; }
  .legal-content h2 { font-size: 16px; }
  .legal-content h3 { font-size: 14.5px; margin: 14px 0 8px; }
  .legal-content p, .legal-content li { font-size: 14px; }
}

/* Analytics opt-out checkbox inside privacy page */
.legal-optout {
  margin-top: 14px;
  padding: 14px;
  background: #eef3ff;
  border-radius: 10px;
  border: 1px solid #dbe3ff;
}
.legal-optout label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
}
.legal-optout input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--legal-primary);
  cursor: pointer;
}
.legal-optout-note {
  margin: 8px 0 0 28px;
  font-size: 13px;
  color: var(--legal-muted);
}

