/**
 * loyalty/css/style.css — PHASE 2.5 — thiết kế MỚI, không kế thừa CSS trang
 * cũ. Đồng bộ NGÔN NGỮ thiết kế với landing/ (cùng font, cùng logic seal/
 * badge, cùng bán kính bo góc) để 2 site công khai của cùng hệ thống nhìn
 * "cùng 1 nhà" — nhưng đổi bảng màu chủ đạo sang tông "quà tặng" (vàng hổ
 * phách) thay vì tông "bảo mật" (xanh mực) của Serial Check, giúp người
 * dùng phân biệt trực quan 2 luồng khác nhau.
 */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --ink: #241A2E;
  --ink-2: #2E2138;
  --gold: #E3A008;
  --gold-2: #F4C430;
  --paper: #FFFBF3;
  --ink-muted: #9C8FA8;
  --success: #0FA37F; --success-bg: #E4F6F1;
  --caution: #C9821A; --caution-bg: #FBF0DC;
  --danger: #D3453B; --danger-bg: #FBE9E7;
  --radius-lg: 22px; --radius-md: 14px;
  --shadow-card: 0 24px 60px -20px rgba(20, 8, 28, 0.55);
  --font-display: 'Be Vietnam Pro', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--paper); font-family: var(--font-display); }
body {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; padding: 32px 18px 150px;
  background:
    radial-gradient(circle at 15% 10%, rgba(227, 160, 8, 0.18), transparent 42%),
    radial-gradient(circle at 88% 90%, rgba(15, 163, 127, 0.12), transparent 46%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
}

.bl-page { width: 100%; max-width: 460px; }
.bl-header { text-align: center; margin-bottom: 18px; }
.bl-brand-name { font-weight: 800; font-size: 1.05rem; margin: 0 0 4px; }
.bl-brand-tagline { font-size: 0.82rem; color: var(--ink-muted); margin: 0; }

/* ---------- [Bug Fix Phase 1 — mục 1.3] Logo thật ở giữa header — ẩn mặc
   định (hidden trong HTML) nếu Tenant chưa cấu hình LOGO_URL. ---------- */
.bl-brand-logo {
  display: block;
  max-width: 140px;
  max-height: 64px;
  margin: 0 auto 10px;
  object-fit: contain;
}
.bl-brand-logo[hidden] { display: none; }

.bl-badge {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  background: rgba(255,255,255,.05); border: 1.5px solid rgba(255,255,255,.14);
  transition: background .25s, border-color .25s;
}
.bl-badge::before { content: '🎁'; }
.bl-badge.is-success { background: rgba(15,163,127,.16); border-color: var(--success); }
.bl-badge.is-success::before { content: '🎉'; }
.bl-badge.is-caution { background: rgba(201,130,26,.16); border-color: var(--caution); }
.bl-badge.is-caution::before { content: '⚠️'; }
.bl-badge.is-danger { background: rgba(211,69,59,.16); border-color: var(--danger); }
.bl-badge.is-danger::before { content: '✕'; }

.bl-card { background: var(--paper); color: #241A2E; border-radius: var(--radius-lg); padding: 22px 22px 24px; box-shadow: var(--shadow-card); }

.bl-mode-toggle { display: flex; background: #F1ECE2; border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.bl-mode-toggle button {
  flex: 1; border: none; background: transparent; padding: 10px 8px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.86rem; color: #6B5F78; cursor: pointer; transition: all .2s;
}
.bl-mode-toggle button.is-active { background: var(--gold); color: #2A1B00; box-shadow: 0 4px 12px rgba(227,160,8,.35); }

.bl-field-label { display: block; font-size: 0.78rem; font-weight: 700; color: #6B5F78; margin: 10px 0 4px; }
.bl-field-label:first-child { margin-top: 0; }
input[type="tel"], input[type="text"] {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-md); border: 2px solid #E9E2D4;
  background: #fff; color: #241A2E; font-family: var(--font-display); font-size: 1rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#bl_earnSerial, #bl_lookupProof { font-family: var(--font-mono); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
input:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(227,160,8,.16); }

.bl-btn-primary {
  width: 100%; margin-top: 16px; padding: 14px; border: none; border-radius: var(--radius-md);
  background: var(--gold); color: #2A1B00; font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  cursor: pointer; transition: transform .1s, opacity .15s;
}
.bl-btn-primary:hover { opacity: .92; }
.bl-btn-primary:active { transform: scale(.98); }
.bl-btn-primary:disabled { opacity: .6; cursor: progress; }
.bl-btn-primary:focus-visible { outline: 3px solid var(--success); outline-offset: 2px; }
.bl-hint { font-size: 0.78rem; color: #8A7E95; margin-top: 8px; }

.bl-message { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-md); border: 1.5px solid transparent; animation: blFade .25s ease; }
.bl-message[hidden] { display: none; }
.bl-message.is-success { background: var(--success-bg); border-color: var(--success); color: #0B5C48; }
.bl-message.is-caution { background: var(--caution-bg); border-color: var(--caution); color: #7A4E0C; }
.bl-message.is-danger { background: var(--danger-bg); border-color: var(--danger); color: #8C2A22; }
.bl-message-title { font-weight: 800; margin-bottom: 3px; }
.bl-message-body { font-size: 0.86rem; line-height: 1.5; }
@keyframes blFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Dashboard sau khi tích điểm / tra cứu thành công ---------- */
#bl_dashboard[hidden] { display: none; }
.bl-block { margin-top: 22px; }
.bl-block h2 { font-size: 1rem; font-weight: 800; color: #fff; margin: 0 0 10px; padding-left: 2px; }

.bl-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.bl-balance-card { background: var(--paper); border-radius: var(--radius-md); padding: 14px; color: #241A2E; text-align: center; box-shadow: var(--shadow-card); }
.bl-balance-campaign { font-size: 0.74rem; color: #8A7E95; margin-bottom: 4px; }
.bl-balance-value { font-family: var(--font-mono); font-weight: 700; font-size: 1.4rem; color: var(--gold-2); }
.bl-balance-value span { font-family: var(--font-display); font-size: 0.7rem; color: #8A7E95; font-weight: 500; }

.bl-empty { color: var(--ink-muted); font-size: 0.86rem; background: rgba(255,255,255,.04); padding: 14px; border-radius: var(--radius-md); }

.bl-reward-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.bl-reward-card { background: var(--paper); border-radius: var(--radius-md); padding: 12px; color: #241A2E; box-shadow: var(--shadow-card); display: flex; flex-direction: column; }
.bl-reward-img { width: 100%; height: 84px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: #F1ECE2; }
.bl-reward-img-placeholder { display: flex; align-items: center; justify-content: center; font-size: 32px; }
.bl-reward-name { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; }
.bl-reward-cost { font-family: var(--font-mono); font-size: 0.82rem; color: var(--caution); font-weight: 700; margin-bottom: 10px; }
.bl-btn-redeem {
  margin-top: auto; border: none; border-radius: 10px; padding: 9px; font-weight: 700; font-size: 0.82rem;
  background: var(--gold); color: #2A1B00; cursor: pointer;
}
.bl-btn-redeem:disabled { background: #E9E2D4; color: #A79E90; cursor: not-allowed; }

.bl-history-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); }
.bl-history-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; color: #241A2E; border-bottom: 1px solid #F1ECE2; font-size: 0.84rem; }
.bl-history-item:last-child { border-bottom: none; }
.bl-history-points { font-family: var(--font-mono); font-weight: 700; min-width: 46px; }
.bl-history-item.is-earn .bl-history-points { color: var(--success); }
.bl-history-item.is-redeem .bl-history-points { color: var(--caution); }
.bl-history-desc { flex: 1; }
.bl-history-time { color: #A79E90; font-size: 0.76rem; }

/* ---------- Chân trang ---------- */
.bl-footer { position: fixed; left: 0; bottom: 0; width: 100%; background: var(--paper); color: #241A2E; text-align: center; padding: 10px 14px; border-top: 3px solid var(--gold); box-shadow: 0 -8px 24px rgba(0,0,0,.18); }
.bl-footer strong { color: var(--gold-2); }
.bl-footer .bl-footer-line { font-size: 0.82rem; margin: 2px 0; }
.bl-footer a { color: #B5651D; font-weight: 700; text-decoration: none; }
.bl-footer .bl-copyright { font-size: 0.72rem; color: #98A0AC; }
.bl-footer .bl-check-link { display: block; margin-top: 4px; font-size: 0.76rem; }
.bl-footer .bl-check-link[hidden] { display: none; }

@media (min-width: 640px) and (max-width: 1023px) {
  body { padding-bottom: 96px; }
  .bl-page { max-width: 480px; }
  .bl-card { padding: 28px 28px 26px; }
}

@media (min-width: 1024px) {
  body { padding-bottom: 96px; }
  .bl-page { max-width: 500px; }
  .bl-card { padding: 32px 32px 28px; }
}

@media (prefers-reduced-motion: reduce) { .bl-message { animation: none; } }

/* ---------- Modal Đổi quà (Redeem) — PHASE 4b UI Revamp ----------
   Trước đây dựng bằng inline style rời rạc trong app.js (màu xanh lá
   #0e7c4a không khớp bảng màu vàng của trang) — nay dùng token sẵn có
   (--gold/--radius-md/--danger/--success...) và tái dùng trực tiếp
   .bl-field-label/.bl-btn-primary/.bl-message/.bl-hint đã tồn tại, chỉ
   thêm CSS THẬT SỰ MỚI cho phần khung Modal + input readonly/textarea/
   nút Huỷ (trước đây chưa có). */
.bl-redeem-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 9999; align-items: center; justify-content: center; padding: 16px;
}
.bl-redeem-overlay.is-open { display: flex; }
.bl-redeem-box {
  background: var(--paper); color: #241A2E; border-radius: var(--radius-md);
  max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 24px; box-shadow: var(--shadow-card); font-family: var(--font-display);
}
.bl-redeem-box h3 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 800; }
.bl-redeem-subtitle { margin: 0 0 16px; color: var(--ink-muted); font-size: 0.86rem; }
.bl-redeem-field { margin-bottom: 12px; }
.bl-redeem-required { color: var(--danger); }
.bl-redeem-field input[readonly] { background: #F7F3EA; color: #6B5F78; }
.bl-redeem-field textarea {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-md); border: 2px solid #E9E2D4;
  background: #fff; color: #241A2E; font-family: var(--font-display); font-size: 1rem; outline: none;
  resize: vertical; transition: border-color .15s, box-shadow .15s;
}
.bl-redeem-field textarea:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(227,160,8,.16); }
.bl-redeem-actions { display: flex; gap: 8px; margin-top: 16px; }
.bl-redeem-cancel {
  flex: 1; padding: 13px; border-radius: var(--radius-md); border: 2px solid #E9E2D4;
  background: #fff; color: #241A2E; font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; cursor: pointer;
}
.bl-redeem-actions .bl-btn-primary { flex: 2; width: auto; margin-top: 0; }
