/* Kiểu chung — mobile-first, tiếng Việt, bản TEST CTV combo du lịch.
   v5: áp design tokens + phong cách trình bày của MyRN portal (HRNKRN).
   Chỉ đổi tầng trình bày: không đổi id/class mà JS đang dùng. */
:root {
  /* Tokens MyRN (portal.html tham chiếu) */
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f1f5f9; --panel: #fff;
  --accent: #00919a; --accent-dark: #00696e; --accent-soft: #e9f8f8;
  --warn: #dc2626; --ok: #16a34a;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px -8px rgba(15, 23, 42, .08);
  /* Bí danh cũ (v4) -> tokens mới, để mọi quy tắc cũ tự đổi màu theo */
  --xanh: var(--accent); --xanh-dam: var(--accent-dark); --nen: var(--bg); --the: var(--panel);
  --chu: var(--ink); --chu-mo: var(--muted); --canh-bao: #b45309; --chan: var(--warn);
  --vien: var(--line); --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif; font-size: 14px;
  background: radial-gradient(1200px 600px at 80% -10%, #dff6f6 0%, transparent 60%), var(--bg);
  color: var(--ink); line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Topbar kiểu MyRN: gradient teal, sticky --- */
header.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(120deg, #003f43, #00b1b7); color: #fff;
  padding: 12px 20px; box-shadow: 0 4px 18px -6px rgba(10, 28, 51, .45);
  position: sticky; top: 0; z-index: 30;
}
header.topbar h1 { font-size: 15px; margin: 0; font-weight: 700; display: flex; align-items: center; gap: 10px; }
header.topbar h1 .logo {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; font-weight: 800; font-size: 16px;
}
header.topbar .who { margin-left: auto; font-size: 12.5px; color: #bfe9ea; display: flex; gap: 10px; align-items: center; }
header.topbar .who .whoname { color: #fff; font-weight: 600; }
.rolechip {
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35);
  padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap;
}
.menubtn {
  min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 8px; margin: 0; background: rgba(255, 255, 255, .1); color: #fff;
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1;
}
.menubtn:hover { background: rgba(255, 255, 255, .2); }
.menuwrap { position: relative; display: inline-flex; }

/* --- Menu thả xuống kiểu MyRN --- */
.navmenu {
  position: fixed; right: 12px; top: 60px; width: min(260px, calc(100vw - 24px));
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px -12px rgba(10, 28, 51, .35); z-index: 90; text-align: left; font-size: 14px;
  overflow: hidden; max-height: calc(100vh - 80px); overflow-y: auto;
}
.navmenu .navinfo { padding: 12px 14px; border-bottom: 1px solid #eef2f7; display: flex; flex-direction: column; gap: 6px; }
.navmenu .whoname { color: var(--ink); font-weight: 600; font-size: 13px; }
.navmenu .rolechip { background: var(--accent-soft); color: var(--accent); border: 1px solid #bde8ea; align-self: flex-start; }
#navMenu .navitem {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
  padding: 10px 14px; border: 0; border-bottom: 1px solid #eef2f7; border-radius: 0;
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px;
  text-align: left; cursor: pointer; margin: 0;
}
#navMenu .navitem:last-child { border-bottom: 0; }
#navMenu .navitem:hover { background: #f8fafc; }
#navMenu .navitem.active { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1.15rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: .9rem; }
.warn-text { color: var(--canh-bao); font-weight: 600; }

/* --- Card kiểu MyRN: trắng, viền --line, bo 14px, bóng nhẹ; h2 có vạch teal --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 10px 0; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: linear-gradient(180deg, #2bb3ba, #00b1b7); flex: 0 0 4px; }
.card dl { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; margin: 0; font-size: .95rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }

/* --- Nút kiểu MyRN --- */
.btn, button {
  display: inline-block; border: 1px solid #cbd5e1; background: #fff; color: var(--ink);
  border-radius: 9px; padding: 9px 14px; font-size: .95rem; font-weight: 500; cursor: pointer; margin: 4px 4px 4px 0;
}
.btn:hover, button:hover { background: #f8fafc; border-color: #94a3b8; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
/* Nút chính: nền accent, min-height 44px */
.btn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; min-height: 44px; padding: 10px 16px; box-shadow: 0 2px 8px -2px rgba(0, 145, 154, .5); }
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: #cbd5e1; box-shadow: none; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-danger { background: #fff; color: var(--warn); border-color: var(--warn); box-shadow: none; }
.btn-danger:hover { background: #fef2f2; border-color: var(--warn); }
.btn-small { padding: 5px 9px; font-size: .85rem; min-height: 0; box-shadow: none; }

/* --- Ô nhập kiểu MyRN --- */
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px;
  font-size: 1rem; margin: 4px 0 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 145, 154, .14); }
label { font-weight: 600; font-size: .92rem; display: block; }
form.inline label { display: inline-block; margin-right: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Hàng tabs ngang cũ đã thay bằng menu thả xuống (giữ DOM + cơ chế data-tab
   để JS menu dùng lại; không hiển thị ở mọi bề rộng). */
.tabs { display: none; }
.tab-panel[hidden] { display: none; }

/* Chat */
.chat-log { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.msg.ctv { align-self: flex-end; background: var(--accent-soft); }
.msg.system { align-self: center; background: #fef3c7; font-size: .9rem; }
.msg .who { font-size: .8rem; color: var(--muted); display: block; margin-bottom: 4px; }

/* Thẻ vé / khách sạn */
.price { font-weight: 700; color: var(--accent-dark); font-size: 1.05rem; }
.price-unknown { color: var(--canh-bao); font-weight: 600; }
.extra-fee { color: var(--canh-bao); font-weight: 700; }
.rule-box { border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: .92rem; }
.rule-block { background: #fee2e2; border: 1px solid #fca5a5; }
.rule-warn { background: #fef3c7; border: 1px solid #fcd34d; }
.rule-info { background: #dbeafe; border: 1px solid #93c5fd; }
.rule-missing { background: #f3e8ff; border: 1px solid #d8b4fe; }
.rule-ok { background: #dcfce7; border: 1px solid #86efac; }

/* Bảng kiểu MyRN */
.mini-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 8px 0; background: #fff; }
.mini-table th, .mini-table td { border-bottom: 1px solid #eef2f7; padding: 9px 10px; text-align: left; }
.mini-table thead th, .mini-table th { background: #f8fafc; color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.mini-table tbody tr:hover td { background: #f8fafc; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }

/* Tag/trạng thái dạng pill kiểu MyRN */
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef2f7; color: #475569; white-space: nowrap; }
.tag.ok { background: #dcfce7; color: #15803d; }
.tag.warn { background: #fef3c7; color: #b45309; }
.tag.err { background: #fee2e2; color: #b91c1c; }
.tag.info { background: #d9f2f3; color: var(--accent); }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { min-width: 260px; max-width: 300px; flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.kanban-col h3 { font-size: .95rem; }
.kanban-col.cancel-col { background: #fef2f2; }
.order-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; font-size: .9rem; cursor: pointer; box-shadow: var(--shadow); }
.order-card.selected { outline: 3px solid var(--accent); }
.order-card .code { font-weight: 700; }
.order-card .money { display: flex; justify-content: space-between; }

/* Lưới giá */
.price-grid { overflow-x: auto; }
.price-grid table { border-collapse: collapse; min-width: 480px; }
.price-grid td, .price-grid th { border: 1px solid var(--line); padding: 6px; }
.price-grid input { margin: 0; padding: 6px; width: 110px; }

/* QR */
.qr-box svg { max-width: 260px; width: 100%; height: auto; display: block; margin: 8px auto; }
.qr-payload { word-break: break-all; font-size: .8rem; color: var(--muted); }
.qr-fallback { border: 2px dashed var(--canh-bao); padding: 12px; border-radius: 8px; }

/* Thông báo */
.error-box { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px; margin: 10px 0; }
#toast-box { position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .92rem; }

/* --- Trang đăng nhập kiểu logincard MyRN --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 18px; margin: 0 auto; }
.logincard { width: 100%; max-width: 400px; background: #fff; border: 0; padding: 0; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px -16px rgba(10, 28, 51, .4); margin: 0; }
.logincard .lhead { background: linear-gradient(135deg, #003f43, #00b1b7); padding: 30px; color: #fff; }
.logincard .lhead .logo {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; font-weight: 800; font-size: 22px; margin-bottom: 12px;
}
.logincard .lhead h1 { font-size: 20px; margin: 0 0 4px; font-weight: 800; }
.logincard .lhead .sub { color: #a9dedf; font-size: 13px; margin: 0; }
.logincard form { padding: 26px 28px 30px; }
.logincard .card-body { padding: 26px 28px 30px; }
.logincard h2 { font-size: 15px; margin: 0 0 12px; }
.logincard .msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.logincard .msg.err { color: var(--warn); }
.logincard .msg.ok { color: var(--ok); }

footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px; }

/* ================= v5.1 — Trang chat tư vấn kiểu AI chatbot ================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Khung chat 1 cột toàn chiều cao khả dụng */
.chat-shell {
  position: relative; display: flex; flex-direction: column;
  height: calc(100dvh - 190px); min-height: 460px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; margin: 10px 0;
}
.chat-shell .card { margin: 0 0 10px; }
.chat-shell #request-card { flex: 0 0 auto; overflow-y: auto; }

/* Stepper 4 chặng */
.stepper {
  list-style: none; display: flex; gap: 4px; margin: 0 0 10px; padding: 0;
  flex: 0 0 auto;
}
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); text-align: center; position: relative; }
.stepper li::before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper .step-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted); position: relative; z-index: 1;
}
.stepper li.done { color: var(--accent); font-weight: 600; }
.stepper li.done .step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.done::before { background: var(--accent); }
.stepper li.current { color: var(--accent); font-weight: 700; }
.stepper li.current .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 145, 154, .14); }

/* Thanh tóm tắt yêu cầu 1 dòng (form thu gọn) */
.req-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); border: 1px solid #bde8ea; border-radius: 12px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 10px; flex: 0 0 auto;
}
.req-summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dòng tin cuộn */
.chat-shell .chat-log { flex: 1 1 auto; min-height: 120px; overflow-y: auto; margin: 0; padding: 4px 2px; }
.msg-row { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.msg-row.ctv { justify-content: flex-end; }
.msg-row.system { justify-content: center; }
.msg-avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(120deg, #003f43, #00b1b7); color: #fff; font-weight: 800; font-size: 13px;
  margin-top: 2px;
}
.msg-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-row.ai .msg-col { max-width: 88%; }
.msg-row.ctv .msg-col { max-width: 82%; align-items: flex-end; }
.msg-row.system .msg-col { max-width: 92%; align-items: center; }
.chat-log .msg { max-width: 100%; }
.msg.ai { border-radius: 16px; border-bottom-left-radius: 4px; background: #fff; }
.msg.ctv { background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 16px; border-bottom-right-radius: 4px; }
.msg.ctv .who { color: rgba(255, 255, 255, .75); }
.msg.system { background: transparent; border: none; color: var(--muted); font-size: .85rem; text-align: center; padding: 2px 8px; box-shadow: none; }
.msg-time { font-size: 11px; color: var(--muted); padding: 0 4px; }
.msg-row.ctv .msg-time { text-align: right; }

/* Typing indicator: 3 chấm nhảy */
.typing-bubble { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px !important; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: typing-bounce 1.1s infinite; }
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Chips gợi ý / trả lời nhanh */
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 2px 36px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; min-height: 40px; padding: 8px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--accent); color: var(--accent);
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; margin: 0;
}
.chip:hover { background: var(--accent-soft); }
#empty-chips { padding-left: 36px; }

/* Thẻ vé / khách sạn trong dòng chat */
.chat-log #flight-section, .chat-log #hotel-section { max-width: 88%; align-self: flex-start; width: 100%; }
.chat-log #flight-section h2, .chat-log #hotel-section h2 { font-size: 1rem; margin: 12px 0 4px; }
.chat-log .flight-card, .chat-log .hotel-card { margin: 0 0 10px; }
.chat-log .flight-card.selected, .chat-log .hotel-card.selected { border: 2px solid var(--accent); }
.picked-pill { margin-left: 8px; vertical-align: middle; }
.skeleton-card { min-height: 120px; background: #eef2f7 !important; animation: skeleton-pulse 1.2s ease-in-out infinite; }
.skeleton-line { height: 12px; border-radius: 6px; background: #e2e8f0; margin: 10px 0; }
.skeleton-line.w50 { width: 50%; } .skeleton-line.w70 { width: 70%; } .skeleton-line.w90 { width: 90%; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* Đáy chat: thanh tóm tắt combo + composer dính đáy */
.chat-bottom { position: relative; flex: 0 0 auto; padding-top: 8px; }
.combo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); border: 1px solid #bde8ea; border-radius: 12px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 8px;
}
.combo-bar span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.combo-bar .btn { margin: 0; flex: 0 0 auto; min-height: 40px; padding: 8px 14px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-bottom: env(safe-area-inset-bottom); }
.composer textarea {
  flex: 1; min-height: 44px; max-height: 140px; resize: none; margin: 0;
  border-radius: 999px; padding: 10px 16px; line-height: 1.4;
}
.send-btn {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; margin: 0;
  background: var(--accent); border-color: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; padding: 0;
}
.send-btn:hover:not(:disabled) { background: var(--accent-dark); }
.send-btn:disabled { opacity: .45; }
.scroll-bottom-btn {
  position: absolute; right: 12px; top: -46px; z-index: 5; margin: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow); font-size: 12.5px; font-weight: 600; padding: 8px 12px; min-height: 0;
}
