/*
 * Khung trang thanh toán dùng chung: giỏ 1 BIB (/cart), mua theo nhóm (/group) và thanh toán nhóm
 * (/group/checkout), cho cả view cũ (site_views/payment/*) lẫn view DS (site_views_ds/payment/*).
 *
 * Ngôn ngữ thiết kế đồng bộ với trang kết quả đơn (payment/cart_result.php, class .cr-*): cùng tên
 * và giá trị token DS, thẻ trắng viền mảnh + shadow-md, hộp chính có viền trên vàng, nút chính xanh đặc.
 * Font kế thừa layout. Token khai báo trên .co; class co-* chỉ dùng bên trong .co. Tên co-* không trùng
 * class nào của Bootstrap/DS. File chỉ nạp trên 3 trang thanh toán.
 *
 * Class gp-* do /ds/assets/group-purchase.js sinh ra (dòng BIB), giữ nguyên tên.
 */

.co {
    --blue-50: #EAF2F9; --blue-400: #4A83BA; --blue-500: #1F5D8C; --blue-600: #184E78;
    --ink-900: #0E1B26; --ink-700: #2B3A45; --ink-500: #5C6E7A; --ink-400: #7D8E99; --ink-200: #CAD5DC; --ink-100: #E3EAEF; --ink-50: #F2F5F7;
    --success-500: #1E9E5A; --danger-500: #E23B3B; --danger-50: #FCE9E9;
    --warning-50: #FEF4DF; --warning-ink: #8A5A00;
    --amber-300: #FFCD1C;
    --shadow-md: 0 2px 6px rgba(15,47,73,.08);
    --shadow-focus: 0 0 0 3px rgba(74,131,186,.32);
    color: var(--ink-700); font-size: 15px; line-height: 1.5;
    padding-bottom: 56px;
}
.co *, .co *::before, .co *::after { box-sizing: border-box; }
.co :where(button) { font: inherit; cursor: pointer; }
.co a { color: var(--blue-600); }
.co a:hover { color: var(--blue-500); }

/* ---------- Đầu trang (view cũ dùng breadcrumb Bootstrap, giống .cr) ---------- */
.co .breadcrumb { margin: 10px 0 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.co .breadcrumb-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.co .breadcrumb-item:first-child { flex: none; }
.co-head { margin: 22px 0 18px; }
.co-race { margin: 0 0 4px; color: var(--blue-400); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.co-head h1 { margin: 0; color: var(--blue-500); font-size: 28px; font-weight: 700; line-height: 1.25; }
.co-head p { margin: 6px 0 0; color: var(--ink-500); font-size: 15px; }

.co-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 992px) {
    .co-grid { grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; }
    .co-aside { position: sticky; top: 16px; }
}

/* ---------- Thẻ ---------- */
.co-panel, .co-sum { background: #fff; border: 1px solid var(--ink-100); border-radius: 6px; box-shadow: var(--shadow-md); padding: 24px; }
.co-panel + .co-panel { margin-top: 16px; }
.co-sum { border-top: 5px solid var(--amber-300); }
.co-title { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; color: var(--ink-900); font-size: 17px; font-weight: 700; line-height: 1.3; }
.co-title small { margin-left: auto; color: var(--ink-500); font-size: 13px; font-weight: 400; }
.co-tile { flex: 0 0 38px; height: 38px; border-radius: 4px; display: flex; align-items: center; justify-content: center; background: var(--blue-50); color: var(--blue-500); font-size: 16px; }

/* ---------- Form người mua ---------- */
.co-fields { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 576px) { .co-fields { grid-template-columns: 1fr 1fr; } .co-field--full { grid-column: 1 / -1; } }
.co-field { margin: 0; }
.co-field label { display: block; margin: 0 0 6px; color: var(--ink-900); font-size: 14px; font-weight: 600; }
.co-input { display: block; width: 100%; height: 44px; margin: 0; padding: 0 12px; border: 1px solid var(--ink-200); border-radius: 4px; background: #fff; color: var(--ink-900); font: inherit; font-size: 16px; line-height: normal; box-shadow: none; transition: border-color .15s, box-shadow .15s; }
.co-input::placeholder { color: var(--ink-400); opacity: 1; }
.co-input:hover { border-color: var(--blue-400); }
.co-input:focus { outline: none; border-color: var(--blue-400); box-shadow: var(--shadow-focus); }
.co-help { display: flex; gap: 6px; margin-top: 6px; color: var(--ink-500); font-size: 13px; line-height: 1.45; }

/* ---------- Cổng thanh toán ---------- */
.co-pays { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 576px) { .co-pays { grid-template-columns: 1fr 1fr; } }
.co-pay { position: relative; display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 14px; border: 1px solid var(--ink-200); border-radius: 6px; background: #fff; cursor: pointer; font-weight: 400; transition: border-color .15s, background .15s, box-shadow .15s; }
.co-pay:hover { border-color: var(--blue-400); }
.co-pay input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.co-pay__dot { flex: none; width: 20px; height: 20px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--ink-200); background: #fff; display: flex; align-items: center; justify-content: center; }
.co-pay__dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--blue-500); transform: scale(0); transition: transform .15s; }
.co-pay__logo { display: block; height: 28px; width: auto; max-width: 120px; object-fit: contain; margin-bottom: 6px; }
.co-pay__desc { display: block; color: var(--ink-500); font-size: 13px; line-height: 1.45; }
.co-pay__note { display: block; margin-top: 6px; color: var(--blue-500); font-size: 12px; }
/* Trạng thái chọn: :has() cho trình duyệt mới, .is-checked (checkout-shell.js) cho trình duyệt cũ.
   Để hai rule riêng: selector list có :has() không hỗ trợ sẽ làm hỏng cả rule. */
.co-pay.is-checked { border-color: var(--blue-500); background: var(--blue-50); box-shadow: 0 0 0 1px var(--blue-500) inset; }
.co-pay.is-checked .co-pay__dot { border-color: var(--blue-500); }
.co-pay.is-checked .co-pay__dot::after { transform: scale(1); }
.co-pay:has(input:checked) { border-color: var(--blue-500); background: var(--blue-50); box-shadow: 0 0 0 1px var(--blue-500) inset; }
.co-pay:has(input:checked) .co-pay__dot { border-color: var(--blue-500); }
.co-pay:has(input:checked) .co-pay__dot::after { transform: scale(1); }
.co-pay:focus-within { outline: 3px solid rgba(74,131,186,.32); outline-offset: 1px; }

.co-ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.co-ic--sm { width: 14px; height: 14px; }
.co-help .co-ic { margin-top: 2px; color: var(--blue-400); }
.co-assure .co-ic { color: var(--ink-500); }

/* ---------- Tóm tắt đơn ---------- */
.co-items { border-top: 1px solid var(--ink-100); }
.co-item, .co .gp-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--ink-100); }
.co .gp-row { grid-template-columns: 56px minmax(0, 1fr) auto auto; }
.co-item__img, .co .gp-row__img { display: block; width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--ink-100); border: 0; }
.co .gp-row__img { width: 56px; height: 42px; }
.co-item__name, .co .gp-row__bib { color: var(--ink-900); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.co-item__meta, .co .gp-row__meta { margin-top: 2px; color: var(--ink-500); font-size: 12px; }
.co-item__price, .co .gp-row__price { color: var(--ink-900); font-size: 14px; font-weight: 700; white-space: nowrap; }
.co .gp-row__warn { margin-top: 4px; }
.co .gp-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--warning-50); color: var(--warning-ink); font-size: 12px; font-weight: 600; }
.co .gp-remove { width: 44px; height: 44px; margin-right: -6px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink-400); font-size: 22px; line-height: 1; }
.co .gp-remove:hover { background: var(--danger-50); color: var(--danger-500); }
.co .gp-remove:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.co .gp-empty { margin-top: 12px; padding: 28px 12px; border: 1px dashed var(--ink-200); border-radius: 6px; color: var(--ink-500); font-size: 14px; text-align: center; }

/* Khối tiền: cùng kiểu .cr-info của trang kết quả đơn */
.co-money { margin: 16px 0 0; padding: 4px 16px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: 6px; }
.co-money > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; font-size: 14px; }
.co-money > div + div { border-top: 1px solid var(--ink-100); }
.co-money dt { font-weight: 400; color: var(--ink-500); }
.co-money dd { margin: 0; color: var(--ink-900); font-weight: 700; text-align: right; white-space: nowrap; }
.co-money .is-disc dd { color: var(--success-500); }
.co-money .is-total dt { color: var(--ink-900); font-size: 15px; font-weight: 700; }
.co-money .is-total dd { color: var(--blue-500); font-size: 22px; line-height: 1.2; }
.co-tier { display: flex; gap: 10px; align-items: center; margin: 14px 0 0; padding: 10px 12px; border-radius: 4px; background: var(--warning-50); color: var(--warning-ink); font-size: 14px; }
.co-tiers { margin: 10px 0 0; color: var(--ink-500); font-size: 13px; }
.co-terms { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; color: var(--ink-500); font-size: 13px; font-weight: 400; line-height: 1.5; cursor: pointer; }
.co-terms input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue-500); }
.co-terms a { color: var(--blue-600); text-decoration: underline; }

/* Nút: cùng kiểu .cr-btn */
.co-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; margin-top: 16px; padding: 0 20px; border: 1px solid var(--blue-500); border-radius: 4px; background: var(--blue-500); color: #fff !important; font-size: 16px; font-weight: 600; text-decoration: none !important; transition: background .15s, border-color .15s; }
.co-btn:hover { background: var(--blue-600); border-color: var(--blue-600); }
.co-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.co-btn:disabled, .co-btn.is-disabled { opacity: .45; pointer-events: none; }
.co-btn--outline { margin-top: 10px; background: #fff; border-color: var(--ink-200); color: var(--blue-600) !important; }
.co-btn--outline:hover { background: #fff; border-color: var(--blue-400); }
.co-assure { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; color: var(--ink-500); font-size: 12px; text-align: center; }

.co-msg { margin-top: 12px; padding: 10px 12px; border-radius: 4px; background: var(--danger-50); color: var(--danger-500); font-size: 14px; }
.co-locked { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 12px; border-radius: 4px; background: var(--warning-50); color: var(--warning-ink); font-size: 14px; }
.co-locked button { height: 40px; padding: 0 14px; border: 1px solid currentColor; border-radius: 4px; background: transparent; color: inherit; font-weight: 600; }

/* Nhập BIB */
.co-add { display: flex; gap: 8px; margin: 0; }
.co-add .co-input { flex: 1; min-width: 0; font-weight: 600; }
.co-add button { flex: none; height: 44px; padding: 0 20px; border: 1px solid var(--blue-500); border-radius: 4px; background: var(--blue-500); color: #fff; font-weight: 600; }
.co-add button:hover { background: var(--blue-600); }

/* ---------- Thanh dính đáy (dưới 992px) ---------- */
.co-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020; display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--ink-100); box-shadow: 0 -2px 10px rgba(15,47,73,.10); }
.co-bar__sum { min-width: 0; }
.co-bar__sum small { display: block; color: var(--ink-500); font-size: 12px; }
.co-bar__sum b { color: var(--blue-500); font-size: 18px; white-space: nowrap; }
.co-bar .co-btn { flex: 1; width: auto; margin: 0; }
@media (max-width: 991.98px) {
    .co { padding-bottom: 96px; }
    /* Chỉ áp trên trang thanh toán (file chỉ nạp ở đây): tab bar DS nằm đúng chỗ thanh dính đáy nên ẩn đi
       cho khách tập trung thanh toán; nút đổi giao diện DS nâng lên trên thanh. */
    .bx-tabbar { display: none !important; }
    .bx-design-switch { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
}
@media (min-width: 992px) { .co-bar { display: none; } }

@media (max-width: 575.98px) {
    /* Như .cr: lề hai bên 16px trên mobile (layout cũ không có; bản DS trùng giá trị bx-container). */
    .co { padding-left: 16px; padding-right: 16px; }
    .co .breadcrumb { margin-top: 8px; font-size: 14px; }
    .co-race { display: none; }
    .co-head { margin: 16px 0 14px; }
    .co-head h1 { font-size: 22px; }
    .co-panel, .co-sum { padding: 18px 16px; }
    .co-input, .co-add button { height: 48px; }
    .co-tile { flex-basis: 34px; height: 34px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) { .co *, .co *::before, .co *::after { transition: none !important; } }
