@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

:root {
  --bg:#E9EDF4; --surf:#EDF1F7; --navy:#143A5C; --navy2:#5b6b82; --muted:#8A96AB; --muted2:#a2adbf; --teal:#0E7C86;
  --raised:8px 8px 16px rgba(163,177,198,0.45),-8px -8px 16px rgba(255,255,255,0.95);
  --raised-sm:4px 4px 8px rgba(163,177,198,0.45),-4px -4px 8px rgba(255,255,255,0.95);
  --inset:inset 4px 4px 8px rgba(163,177,198,0.5),inset -4px -4px 8px rgba(255,255,255,0.9);
  --danger:#D9534F; --ok-bg:#E3F5EA; --ok-text:#1E6B32; --free-text:#22A45D;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--navy);
}

button, input, select, textarea { font-family: inherit; }

.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 12px 16px 40px; }

/* Màn hình lớn (PC, ≥1300px): lớp nền hiệu ứng lấp lánh (sparkle) phía sau nội dung. */
.bg-effects { display: none; position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
@media (min-width: 1300px) {
  .bg-effects { display: block; }
}
.bg-star {
  position: absolute; border-radius: 50%; will-change: opacity, transform;
  animation: bg-twinkle ease-in-out infinite;
}
@keyframes bg-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: var(--op, 0.5); transform: scale(1); }
}

/* ---------- Header ---------- */
.head {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  padding: 26px 26px; border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(16,96,107,0.90), rgba(20,139,150,0.90)),
    url('../assets/hospital-bg.jpg') center 65% / cover no-repeat;
  box-shadow: var(--raised);
  margin-bottom: 16px;
}
.head-logo {
  position: relative;
  width: 56px; height: 56px; flex: 0 0 56px; border-radius: 15px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,0.25), inset 2px 2px 5px rgba(0,0,0,0.08);
}
.head-logo img { width: 46px; height: 46px; object-fit: contain; }
.head-text { position: relative; flex: 1; min-width: 0; }
.head-title { font-size: 24px; font-weight: 800; color: #fff; line-height: 1.25; text-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.head-sub { font-size: 16px; font-weight: 700; color: rgba(255,255,255,0.92); line-height: 1.3; text-shadow: 0 2px 8px rgba(0,0,0,0.35); }

.lang-toggle {
  position: relative; flex: 0 0 auto; display: flex; gap: 4px; padding: 4px; border-radius: 11px;
  background: rgba(255,255,255,0.16); box-shadow: inset 1px 1px 3px rgba(0,0,0,0.15);
}
.lang-btn {
  padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.03em; cursor: pointer;
  color: rgba(255,255,255,0.85); border: none; background: transparent; transition: background .15s ease, color .15s ease;
}
.lang-btn.active { color: #10606B; background: #fff; }

/* ---------- Wizard layout ---------- */
.wizard-wrap { max-width: 720px; margin: 0 auto; }

.steps { display: flex; align-items: flex-start; margin-bottom: 18px; padding: 4px 6px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: 0 0 auto; width: 96px; text-align: center; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--muted); background: var(--surf); box-shadow: var(--raised-sm);
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.step-label { font-size: 10.5px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.step.active .step-num { color: #fff; background: linear-gradient(135deg,#10606B,#148B96); box-shadow: 0 4px 10px rgba(14,124,134,0.4); }
.step.active .step-label { color: var(--teal); }
.step.done .step-num { color: var(--teal); background: var(--surf); box-shadow: var(--inset); }
.step.done .step-num::after { content: '✓'; }
.step.done .step-num span { display: none; }
.step-line { flex: 1 1 auto; height: 2px; background: rgba(163,177,198,0.4); margin: 15px -8px 0; border-radius: 2px; }

.wizard-panel { margin-bottom: 16px; }
.wizard-panel.anim-in-right { animation: wizard-in-right .32s cubic-bezier(.25,.8,.4,1); }
.wizard-panel.anim-in-left { animation: wizard-in-left .32s cubic-bezier(.25,.8,.4,1); }
@keyframes wizard-in-right { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: translateX(0); } }
@keyframes wizard-in-left { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: translateX(0); } }

.wizard-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.wizard-nav-right { display: flex; gap: 10px; flex: 1; justify-content: flex-end; }
.wizard-nav .btn-reset { width: auto; flex: 0 0 auto; padding: 11px 16px; }
.wizard-nav .btn-back { flex: 0 0 auto; }
.wizard-nav .btn-submit { flex: 0 1 220px; }

.btn-back {
  border: none; cursor: pointer; font-weight: 600; padding: 11px 18px; border-radius: 12px; font-size: 0.94em;
  color: var(--navy2); background: var(--surf); box-shadow: var(--raised-sm);
}

/* ---------- Cards & fields ---------- */
.card { padding: 20px 24px; border-radius: 18px; background: var(--surf); box-shadow: var(--raised); }
.card-title { font-size: 14px; font-weight: 700; color: var(--teal); margin-bottom: 16px; }

.field-label { font-size: 12px; font-weight: 600; color: var(--navy2); display: block; margin-bottom: 6px; }
.field-label .req { color: var(--danger); }
.field-err { font-size: 11px; font-weight: 600; color: var(--danger); margin-top: 5px; display: block; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field input, .field select, .dob-grid select {
  border: none; outline: none; box-shadow: var(--inset);
  border-radius: 11px; padding: 11px 13px; font-weight: 500; color: var(--navy); font-size: 0.94em; max-width: 100%; width: 100%;
}
.field input { background: var(--bg); }
.field select, .dob-grid select {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235b6b82'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 10px 6px;
  padding-right: 32px;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer;
}
.field input.err, .field select.err, .dob-grid select.err { box-shadow: inset 0 0 0 2px var(--danger), var(--inset); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.grid-2 .field, .grid-2.even .field { margin-bottom: 0; }

.gender-toggle { display: flex; gap: 7px; padding: 4px; border-radius: 11px; background: var(--bg); box-shadow: var(--inset); }
.gender-btn {
  flex: 1; text-align: center; padding: 8px; border-radius: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--muted); border: none; background: transparent;
}
.gender-btn.active { color: var(--teal); background: var(--surf); box-shadow: var(--raised-sm); }

/* Ngày | Tháng | Năm - tháng rộng bằng năm trước đây, năm thu lại bằng tháng trước đây */
.dob-grid { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; }

/* ---------- Ngày khám: lịch chọn ngày tuỳ chỉnh (dd/MM/yyyy, chặn CN, cảnh báo T7) ---------- */
.date-picker { position: relative; }
.date-input-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  border: none; outline: none; box-shadow: var(--inset); background: var(--bg); border-radius: 11px;
  padding: 11px 13px; font-weight: 500; color: var(--navy); font-size: 0.94em; cursor: pointer; text-align: left;
}
.date-input-btn .placeholder { color: var(--muted); font-weight: 500; }
.date-input-btn .date-icon { font-size: 14px; opacity: .75; flex: 0 0 auto; }
.date-input-btn.err { box-shadow: inset 0 0 0 2px var(--danger), var(--inset); }

.date-dropdown {
  position: absolute; z-index: 25; top: calc(100% + 8px); left: 0; width: 280px; max-width: calc(100vw - 32px);
  padding: 14px; border-radius: 16px; background: var(--surf); box-shadow: var(--raised);
}
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.date-nav-btn {
  border: none; cursor: pointer; width: 30px; height: 30px; border-radius: 9px; font-size: 16px;
  color: var(--navy2); background: var(--bg); box-shadow: var(--raised-sm);
}
.date-nav-btn:disabled { opacity: .35; cursor: default; }
.date-nav-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.date-weekdays { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; margin-bottom: 4px; }
.date-weekdays span { text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); }
.date-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.date-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border: none; border-radius: 9px;
  font-size: 12px; font-weight: 600; color: var(--navy); background: transparent; cursor: pointer;
}
.date-cell:hover:not(:disabled) { background: var(--bg); box-shadow: var(--inset); }
.date-cell.saturday:not(:disabled):not(.selected) { color: #B8860B; }
.date-cell.selected { color: #fff; background: linear-gradient(135deg,#10606B,#148B96); box-shadow: 0 4px 10px rgba(14,124,134,.4); }
.date-cell:disabled { color: var(--muted2); opacity: .4; cursor: not-allowed; }

.date-note {
  margin-top: 8px; padding: 9px 11px; border-radius: 10px; background: #FFF6E0; color: #8A5A00;
  font-size: 11px; font-weight: 600; line-height: 1.5;
}

/* ---------- Khung giờ: cardview sinh động ---------- */
.slot-scroll { max-height: 380px; overflow-y: auto; padding-right: 2px; }
.slot-section + .slot-section { margin-top: 14px; }
.slot-section-title {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--navy2);
  margin-bottom: 9px;
}
.slot-section-title .count { font-weight: 600; color: var(--muted); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(82px,1fr)); gap: 8px; }
.slot-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: none; padding: 11px 6px; border-radius: 13px; cursor: pointer;
  color: var(--navy); background: var(--surf); box-shadow: var(--raised-sm);
  transition: transform .15s cubic-bezier(.34,1.5,.64,1), box-shadow .15s ease, background .15s ease, color .15s ease;
}
.slot-card:hover { transform: translateY(-2px) scale(1.04); box-shadow: var(--raised); }
.slot-card .slot-icon { font-size: 15px; line-height: 1; }
.slot-card .slot-time { font-size: 12px; font-weight: 700; }
.slot-card.active {
  color: #fff; background: linear-gradient(135deg,#10606B,#148B96);
  box-shadow: 0 6px 14px rgba(14,124,134,0.45); transform: translateY(-1px) scale(1.05);
}
.slot-card.active::after {
  content: '✓'; position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: var(--teal); font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.slot-card.just-picked, .slot-selected.just-picked { animation: slot-pop .32s ease; }
@keyframes slot-pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* Sau khi chọn: chỉ hiện 1 khung giờ đã chọn, ẩn các khung còn lại cho gọn */
.slot-selected {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg,#10606B,#148B96); box-shadow: 0 6px 14px rgba(14,124,134,0.4);
}
.slot-selected-info { display: flex; align-items: center; gap: 10px; }
.slot-selected-icon { font-size: 20px; }
.slot-selected-label { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.85); }
.slot-selected-time { font-size: 16px; font-weight: 800; }
.slot-change-btn {
  flex: 0 0 auto; border: none; cursor: pointer; font-size: 11.5px; font-weight: 700;
  padding: 8px 13px; border-radius: 10px; color: #fff; background: rgba(255,255,255,0.18);
}
.slot-change-btn:hover { background: rgba(255,255,255,0.28); }

.slot-empty { font-size: 12px; color: var(--muted); padding: 10px 2px; }
.slot-loading { font-size: 12px; color: var(--muted); padding: 10px 2px; display: flex; align-items: center; gap: 8px; }

/* ---------- Bước 3: xác nhận ---------- */
.summary-box { border-radius: 13px; background: var(--bg); box-shadow: var(--inset); padding: 4px 14px; margin-bottom: 14px; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; font-size: 11.5px; border-bottom: 1px solid rgba(163,177,198,0.18); }
.summary-row:last-child { border-bottom: none; }
.summary-row .lbl { color: var(--muted); font-weight: 500; }
.summary-row .val { font-weight: 600; color: var(--navy); text-align: right; max-width: 58%; }

.captcha-row { display: flex; gap: 9px; align-items: center; }
.captcha-img-wrap {
  flex: 1; padding: 6px 11px; border-radius: 11px; background: var(--bg); box-shadow: var(--inset);
  display: flex; align-items: center; justify-content: center; min-height: 40px;
}
.captcha-img-wrap img { height: 34px; }
.btn-refresh {
  flex: 0 0 auto; width: 40px; height: 40px; border: none; cursor: pointer; font-size: 15px;
  border-radius: 11px; color: var(--navy2); background: var(--surf); box-shadow: var(--raised-sm);
}

.agree-row { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; margin-bottom: 4px; }
.agree-box {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 6px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
  color: var(--teal); margin-top: 1px; box-shadow: var(--inset);
}
.agree-box.err { box-shadow: inset 0 0 0 2px var(--danger), var(--inset); }
.agree-text { font-size: 11.5px; font-weight: 500; color: var(--navy2); line-height: 1.5; }

.btn-submit {
  border: none; cursor: pointer; font-weight: 700; padding: 14px; border-radius: 13px; font-size: 0.94em;
  color: #fff; background: linear-gradient(135deg,#10606B,#148B96); box-shadow: var(--raised-sm); width: 100%;
}
.btn-submit:disabled { opacity: .65; cursor: default; }
.btn-reset {
  border: none; cursor: pointer; font-weight: 600; padding: 11px; border-radius: 12px; font-size: 0.94em;
  color: var(--navy2); background: var(--surf); box-shadow: var(--raised-sm); width: 100%;
}
.err-msg { padding: 13px 15px; border-radius: 12px; background: #FBE9E7; color: var(--danger); font-size: 12px; font-weight: 600; line-height: 1.55; margin-top: 14px; }

.hotline { font-size: 11px; font-weight: 500; color: var(--muted); line-height: 1.6; padding: 10px 4px 0; text-align: center; }
.hotline b { color: var(--navy); }

/* ---------- Result screen ---------- */
.result-wrap { display: flex; justify-content: center; padding: 0 4px; }
.result-card {
  width: 100%; max-width: 620px; padding: 26px 28px; border-radius: 18px; background: var(--surf);
  box-shadow: var(--raised); display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.result-title { width: 100%; text-align: center; font-size: 17px; font-weight: 800; color: var(--navy); line-height: 1.35; letter-spacing: 0.01em; }
.result-qr { width: 280px; height: 280px; max-width: 78vw; max-height: 78vw; padding: 12px; border-radius: 14px; background: #fff; box-shadow: var(--inset); display: flex; align-items: center; justify-content: center; }
.result-qr img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.result-code { font-size: 21px; font-weight: 800; letter-spacing: 0.04em; color: var(--navy); }
.result-info { width: 100%; display: flex; flex-direction: column; gap: 9px; padding: 16px 18px; border-radius: 14px; background: var(--bg); box-shadow: var(--inset); }
.result-info .danger { font-size: 13px; font-weight: 700; color: var(--danger); line-height: 1.55; }
.result-info .green { font-size: 13px; font-weight: 700; color: var(--ok-text); line-height: 1.55; }
.btn-finish {
  align-self: flex-end; border: none; cursor: pointer; font-weight: 700; padding: 12px 26px;
  border-radius: 12px; color: var(--navy2); background: var(--surf); box-shadow: var(--raised-sm);
}

/* ---------- Loading overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,45,60,0.45); backdrop-filter: blur(1px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.loader { position: relative; width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; }
.loader-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 5px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spin 0.85s linear infinite;
}
.loader-logo {
  width: 54px; height: 54px; object-fit: contain; border-radius: 14px; background: #fff; padding: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: loader-pulse 1.3s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loader-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .wrap { padding: 0 !important; }
  .wizard-wrap { padding: 0 10px 20px; }
  .grid-2, .grid-2.even { grid-template-columns: 1fr !important; gap: 14px !important; }
  .dob-grid { grid-template-columns: 1fr 1.2fr 1fr !important; gap: 8px !important; }
  .head { padding: 16px 16px !important; border-radius: 0 0 20px 20px !important; gap: 12px !important; flex-wrap: wrap; margin-bottom: 12px; }
  .head-logo { width: 44px !important; height: 44px !important; flex: 0 0 44px !important; }
  .head-title { font-size: 19px !important; }
  .head-sub { font-size: 13.5px !important; }
  .card { padding: 16px 15px !important; border-radius: 16px !important; }
  .field input, .field select, .dob-grid select { font-size: 15px !important; padding: 13px 13px !important; }
  .field select, .dob-grid select { padding-right: 32px !important; }
  .slot-grid { grid-template-columns: repeat(auto-fill,minmax(74px,1fr)) !important; }
  .btn-submit { padding: 16px !important; font-size: 15px !important; }
  .result-qr { width: min(78vw,300px) !important; height: min(78vw,300px) !important; }
  .steps { padding: 4px 0; }
  .step { width: 76px; }
  .step-label { font-size: 9.5px; }
  .wizard-nav { flex-wrap: wrap; }
  .wizard-nav-right { width: 100%; justify-content: stretch; }
  .wizard-nav-right .btn-back, .wizard-nav-right .btn-submit { flex: 1 1 0; }
  .wizard-nav .btn-reset { order: 3; width: 100%; }
  .date-dropdown { left: 50%; transform: translateX(-50%); }
}
