/*
 * Cổng tự phục vụ NAG — stylesheet dùng chung.
 * Mobile-first. Font Be Vietnam Pro + system-font fallback chống FOIT mạng yếu.
 * Accent chính: #D9480F (cam BIBPIX).
 * File này load trong layout nag/layout.php.
 */

/* ===== Custom properties ===== */
:root {
  --bg: #FAF6F0;
  --card: #FFFFFF;
  --ink: #221B12;
  --ink-2: #6E6256;
  --line: #EDE5DA;
  --accent: #D9480F;
  --accent-soft: #FFF0E6;
  --accent-ink: #A23A0B;
  --ok: #2B7A3D;
  --ok-bg: #E7F3EA;
  --wait: #9A6700;
  --wait-bg: #FFF4D6;
  --na: #6B7280;
  --na-bg: #F1F0EE;
  --bad: #B42318;
  --bad-bg: #FBEAE9;
  --radius: 14px;
  --nav-h: 64px;
}

/* ===== Reset & base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/*
 * Font stack: Be Vietnam Pro từ Google Fonts (preconnect + display=swap giảm FOIT).
 * Fallback system-font stack đảm bảo layout không bị vỡ khi Google bị chặn.
 */
body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Helvetica, Arial, sans-serif;
  background: #E9E2D8;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  min-height: 100vh; /* fallback cho browser cũ */
}

/* ===== Wrapper điện thoại ===== */
.nag-phone {
  max-width: 430px;
  margin: 20px auto 40px;
  background: var(--bg);
  min-height: 780px;
  border-radius: 28px;
  box-shadow: 0 18px 60px rgba(34, 27, 18, .25);
  overflow: hidden;
  position: relative;
}

@media (max-width: 470px) {
  .nag-phone {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100dvh;
    min-height: 100vh;
  }
}

/* ===== Nội dung screen có khoảng thở bottom nav ===== */
.nag-screen {
  padding-bottom: calc(var(--nav-h) + 20px);
}

/* ===== App bar ===== */
.appbar {
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.appbar h1 {
  font-size: 20px;
  font-weight: 700;
}
.appbar .back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.brand {
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  font-size: 14px;
}

/* ===== Bottom nav cố định ===== */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 10;
}

@media (max-width: 470px) {
  .bottomnav {
    left: 0;
    transform: none;
    max-width: 100%;
  }
}

.bottomnav a {
  flex: 1;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
}
.bottomnav a .ic {
  font-size: 20px;
  line-height: 1;
}
.bottomnav a.active {
  color: var(--accent);
}

/* ===== Shared layout ===== */
.wrap {
  padding: 0 16px;
}

/* ===== Card ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ===== Badge trạng thái ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.b-ok   { color: var(--ok);   background: var(--ok-bg);   }
.b-wait { color: var(--wait); background: var(--wait-bg); }
.b-na   { color: var(--na);   background: var(--na-bg);   }
.b-bad  { color: var(--bad);  background: var(--bad-bg);  }

/* ===== Buttons ===== */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius);
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn:active {
  transform: scale(.985);
}
.btn-line {
  background: var(--card);
  color: var(--accent-ink);
  border: 1.5px solid var(--accent);
}
.btn-ghost {
  background: none;
  color: var(--ink-2);
  border: 1.5px dashed var(--line);
}

/* ===== Form fields ===== */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
/*
 * font-size: 16px trên input/textarea/select ngăn iOS Safari tự zoom khi focus.
 * Quan trọng với mạng yếu/thiết bị cũ — user NAG thường dùng điện thoại phổ thông.
 */
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
}
.field input[readonly],
.field textarea[readonly] {
  background: var(--na-bg);
  color: var(--ink-2);
}

/* ===== Misc helpers ===== */
.hint {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 5px;
}
.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.sec-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 18px 0 8px;
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14.5px;
}
.row:last-child { border-bottom: 0; }
.row .l { color: var(--ink-2); }
.row .l b { color: var(--ink); font-weight: 600; }
.total-row {
  border-top: 2px solid var(--ink);
  margin-top: 4px;
  padding-top: 11px;
  font-size: 16px;
}

/* ===== Notif / alert boxes ===== */
.pending-note {
  background: var(--wait-bg);
  color: var(--wait);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  font-weight: 500;
  margin-bottom: 12px;
}
.approved-note {
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  font-weight: 500;
  margin-bottom: 12px;
}
.reply {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 9px;
}
.reply b { color: var(--accent-ink); }

/* ===== Events summary header ===== */
.summary {
  background: linear-gradient(135deg, #221B12, #43301F);
  border-radius: var(--radius);
  padding: 18px;
  color: #FAF6F0;
  margin-bottom: 16px;
}
.summary .who { font-size: 13px; opacity: .75; margin-bottom: 12px; }
.summary .grid { display: flex; gap: 12px; }
.summary .cell {
  flex: 1;
  background: rgba(255, 255, 255, .07);
  border-radius: 11px;
  padding: 12px;
}
.summary .cell .t { font-size: 12px; opacity: .8; margin-bottom: 4px; }
.summary .cell .v { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary .cell.paid .v { color: #7ED99A; }
.summary .cell.wait .v { color: #FFD773; }

/* ===== Event card ===== */
.event-card {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  margin-bottom: 12px;
}
.event-card > .card-inner {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.event-card .top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.event-card h3 { font-size: 15.5px; font-weight: 700; line-height: 1.35; }
.event-card .date { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.event-card .bot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 9px;
  margin-top: 2px;
}
.event-card .meta { font-size: 13.5px; color: var(--ink-2); }
.event-card .amt { font-size: 16px; }

/* ===== Empty state ===== */
.empty {
  padding: 48px 24px;
  text-align: center;
}
.empty .ic { font-size: 42px; margin-bottom: 10px; }
.empty h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty p {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ===== Claim card ===== */
.claim-card .typ {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-ink);
  letter-spacing: .3px;
  margin-bottom: 4px;
}
.claim-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.claim-card .desc { font-size: 14px; color: var(--ink-2); line-height: 1.5; margin-bottom: 9px; }

/* ===== Picker 3 bậc ===== */
.tier {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.tier .tier-head {
  padding: 12px 14px;
  font-size: 14.5px;
  font-weight: 600;
  background: var(--card);
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}
.tier .tier-head .step { color: var(--accent); font-weight: 800; margin-right: 6px; }
.tier .tier-body { padding: 0 14px 14px; display: none; }
.tier.open .tier-body { display: block; }
.tier.open .tier-head { border-bottom: 1px dashed var(--line); }
.result {
  padding: 12px 10px;
  border-bottom: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 14.5px;
}
.result:last-child { border-bottom: 0; }
.result .d { font-size: 13px; color: var(--ink-2); }
.result:active { background: var(--accent-soft); }
.picked {
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14.5px;
  font-weight: 600;
  display: none;
  margin-bottom: 12px;
}

/* ===== Profile avatar ===== */
.avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Flash message (redirect message từ Controller::redirect) ===== */
.nag-flash {
  margin: 12px 16px 0;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}
.nag-flash.success { background: var(--ok-bg);   color: var(--ok);   }
.nag-flash.error   { background: var(--bad-bg);  color: var(--bad);  }
.nag-flash.warning { background: var(--wait-bg); color: var(--wait); }
