/**
 * Bán Hàng Nhanh — mobile-first: CSS mặc định = mobile,
 * @media (min-width) chỉ để mở rộng cho tablet/desktop.
 * KHÔNG khai báo font-family — kế thừa Inter Tight từ theme.
 *
 * Ngôn ngữ thiết kế v2 — "light glass tech": nền sáng có ánh gradient nhẹ,
 * bề mặt kính mờ (backdrop blur), màu nhấn emerald→cyan, bóng đổ mềm nhiều lớp.
 * Toàn bộ token màu/bo góc khai báo 1 chỗ trong .bhn — admin.css dùng lại qua var().
 *
 * Breakpoint chuẩn hóa theo thang Tailwind CSS, dùng nhất quán với admin.css:
 *   sm  (min-width: 640px)  — tablet dọc / điện thoại lớn
 *   md  (min-width: 768px)  — tablet ngang
 *   lg  (min-width: 1024px) — desktop
 *   xl  (min-width: 1280px) — màn hình rộng
 */

/* Full-width trong trang plugin, chỉ ghi đè container Flatsome ở đây */
body.bhn-page .container {
    max-width: 100% !important;
}

/* Trang shop là SPA toàn màn hình — ẩn header/footer/top-bar của theme (Flatsome). */
body.bhn-page #header,
body.bhn-page #top-bar,
body.bhn-page .header-wrapper,
body.bhn-page .footer-wrapper,
body.bhn-page #footer,
body.bhn-page .page-title {
    display: none !important;
}

/* #content (page-wrapper của Flatsome) mới là nơi có padding-top ~30px thực sự, không phải #main. */
body.bhn-page #content,
body.bhn-page #main {
    padding-top: 0;
    background: transparent;
}

/* Nền toàn trang: sáng, điểm 2 quầng gradient emerald/cyan rất nhạt ở góc — chất "tech"
   mà không ảnh hưởng độ đọc. Đè bg trắng của theme bằng !important. */
body.bhn-page {
    background-color: #f5f8f7 !important;
    background-image:
        radial-gradient(1100px 520px at 88% -120px, rgba(16, 185, 129, 0.1), transparent 60%),
        radial-gradient(900px 520px at -8% 35%, rgba(8, 145, 178, 0.07), transparent 55%) !important;
    background-attachment: fixed !important;
}

.bhn,
.bhn * {
    min-width: 0;
    overflow-wrap: break-word;
}

body.bhn-no-scroll {
    overflow: hidden;
}

.bhn {
    /* Token thiết kế dùng chung (admin.css cũng đọc các biến này) */
    --bhn-accent: #10b981;
    --bhn-accent-dark: #059669;
    --bhn-accent-deep: #047857;
    --bhn-accent-soft: #ecfdf5;
    --bhn-cyan: #0891b2;
    --bhn-grad: linear-gradient(135deg, #10b981, #0d9488 55%, #0891b2);
    --bhn-ink: #0f172a;
    --bhn-muted: #64748b;
    --bhn-line: rgba(15, 23, 42, 0.08);
    --bhn-glass: rgba(255, 255, 255, 0.72);
    --bhn-glass-solid: rgba(255, 255, 255, 0.88);
    --bhn-radius: 16px;
    --bhn-radius-sm: 10px;
    --bhn-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.07);
    --bhn-glow: 0 4px 16px rgba(16, 185, 129, 0.32);
    --bhn-ring: 0 0 0 3px rgba(16, 185, 129, 0.22);
    position: relative;
    padding: 6px 6px;
    min-height: 60vh;
    color: var(--bhn-ink);
}

.bhn *,
.bhn *::before,
.bhn *::after {
    box-sizing: border-box;
}

/*
 * Reset triệt để mọi <button> trong SPA. Flatsome tự áp padding/border/font-size riêng
 * cho thẻ button (ví dụ 0 18.624px) — với các nút icon bo tròn kích thước cố định (40x40...),
 * padding đó ăn hết chỗ khiến icon bên trong bị bóp gần như biến mất.
 * :where() giữ độ ưu tiên bằng 0 nên không phá padding/màu riêng mà từng class .bhn-btn,
 * .bhn-icon-btn... khai báo bên dưới — chỉ đơn thuần trung hòa CSS mặc định của theme trước đó.
 */
:where(.bhn) button {
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    line-height: normal;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* Số (giá, số lượng) canh cột đều nhau — chi tiết nhỏ nhưng nhìn "kỹ thuật" hơn hẳn. */
.bhn {
    font-variant-numeric: tabular-nums;
}

/* Người dùng bật giảm chuyển động: tắt toàn bộ animation/transition trong SPA. */
@media (prefers-reduced-motion: reduce) {
    .bhn *,
    .bhn *::before,
    .bhn *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- Buttons ---------- */

.bhn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px; /* vùng chạm mobile */
    padding: 8px 16px;
    border: 1px solid transparent;
    /* !important cho mọi border-radius trên nút: Flatsome áp bo góc nút qua CSS inline
       của Customizer (kèm !important, nạp sau cùng) — không khóa là bị đè như vụ height. */
    border-radius: 999px !important;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: filter 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.bhn-btn--primary {
    background: var(--bhn-grad);
    color: #fff;
    box-shadow: var(--bhn-glow);
}

.bhn-btn--primary:hover {
    filter: brightness(1.06);
    color: #fff;
}

.bhn-btn--primary:active {
    transform: scale(0.98);
}

.bhn-btn--ghost {
    background: var(--bhn-glass);
    color: var(--bhn-ink);
    border-color: var(--bhn-line);
}

.bhn-btn--ghost:hover {
    background: var(--bhn-accent-soft);
    color: var(--bhn-accent-deep);
}

.bhn-btn--danger {
    background: rgba(255, 255, 255, 0.8);
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.45);
}

/* Hành động phụ, cố ý làm mờ nhạt (nút "Hủy đơn"): vẫn bấm được nhưng không mời gọi,
   nhỏ hơn hẳn nút chính để mắt khách không bị hút vào. */
.bhn-btn--quiet {
    background: none;
    color: var(--bhn-muted);
    border-color: var(--bhn-line);
    min-height: 28px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 400;
}

.bhn-btn--quiet:hover {
    background: rgba(15, 23, 42, 0.04);
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.35);
}

.bhn-btn--block {
    width: 100%;
}

.bhn-btn--sm {
    min-height: 30px;
    padding: 4px 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.bhn-btn:disabled {
    opacity: 0.55;
    cursor: default;
    filter: none;
}

/* ---------- Login: thẻ kính nổi giữa trang ---------- */

.bhn-login {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.bhn-login__form {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 26px 22px;
    background: var(--bhn-glass-solid);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    box-shadow: var(--bhn-shadow);
}

.bhn-login__form h2 {
    margin: 0 0 4px;
    text-align: center;
    font-size: 20px;
    letter-spacing: -0.01em;
}

.bhn label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
}

.bhn input[type="tel"],
.bhn input[type="password"],
.bhn input[type="number"],
.bhn input[type="search"],
.bhn textarea {
    min-height: 40px;
    /* Flatsome tự thêm margin-bottom ~15px cho input/textarea — nếu không triệt tiêu,
       ô nằm trong flex (topbar) sẽ bị lệch tâm so với các icon bên cạnh. */
    margin: 0 !important;
    padding: 8px 12px;
    border: 1px solid var(--bhn-line);
    border-radius: var(--bhn-radius-sm);
    background: rgba(255, 255, 255, 0.85);
    font-size: 15px; /* >=15px: iOS Safari không tự zoom khi focus */
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.bhn textarea {
    resize: vertical;
    min-height: 60px;
}

.bhn input:focus,
.bhn textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--bhn-accent);
    box-shadow: var(--bhn-ring);
}

/* ---------- Account panel: từng khối (địa chỉ / đổi mật khẩu) cách nhau rõ ràng ---------- */

.bhn-account-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px 0;
}

.bhn-account-section h4 {
    margin: 0;
    font-size: 13px;
    color: var(--bhn-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bhn-panel__body hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid var(--bhn-line);
}

.bhn-login__error,
.bhn-form-msg.is-error {
    color: #b91c1c;
    font-size: 14px;
    margin: 0;
}

.bhn-form-msg {
    color: var(--bhn-accent-dark);
    font-size: 14px;
    margin: 0;
}

.bhn-login__hint {
    font-size: 13px;
    color: var(--bhn-muted);
    text-align: center;
    margin: 0;
}

/* ---------- Topbar: thanh kính mờ dính đỉnh ---------- */

.bhn-topbar {
    display: flex;
    gap: 8px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    padding: 10px 0;
    /* .bhn có padding-top 6px — kéo topbar lên dính sát đỉnh màn hình (kể cả khi chưa cuộn),
       không lệ thuộc padding của cha để sticky top:0 luôn đúng nghĩa "sát đỉnh". */
    margin-top: -6px;
}

.bhn-search {
    flex: 1;
    min-width: 0;
    height: 40px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid rgba(16, 185, 129, 0.35) !important;
}

.bhn-search:focus {
    background: #fff;
    border-color: var(--bhn-accent) !important;
}

.bhn-topbar__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ---------- Icon buttons: user / đơn hàng / giỏ hàng trên topbar ---------- */

/* width/height !important: Flatsome tự áp height theo em (~2.4em) lên mọi <button>,
   độ ưu tiên cao hơn cả class của mình — không khóa cứng thì nút tròn sẽ bị kéo méo thành oval. */
.bhn-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0;
    border: 1px solid var(--bhn-line);
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.75);
    color: var(--bhn-ink);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.bhn-icon-btn:hover,
.bhn-icon-btn:focus-visible {
    background: var(--bhn-accent-soft);
    color: var(--bhn-accent-dark);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.18);
}

.bhn-icon-svg {
    width: 21px;
    height: 21px;
}

.bhn-icon-btn__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px !important;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 0 2px #fff;
}

.bhn-icon-btn__badge[hidden] {
    display: none;
}

/* Đích thả kéo-thả (thay cho FAB cố định trước đây) — icon giỏ hàng trên topbar phồng lên khi kéo tới gần. */
.bhn-icon-btn--target {
    background: var(--bhn-grad);
    color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25);
}

.bhn-icon-btn--pulse {
    animation: bhn-pulse 0.35s ease;
}

@keyframes bhn-pulse {
    50% { transform: scale(1.25); }
}

/* ---------- Product grid: hàng ngang, 1 sản phẩm/hàng trên mobile ---------- */

.bhn-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 24px;
}

/* Mỗi thẻ = 1 hàng ngang: ảnh / tên+giá / SL+đơn vị / nút thêm (đủ rộng cho nút 40px tròn đều).
   Thẻ kính: nền bán trong suốt + viền sáng, nổi nhẹ khi hover. */
.bhn-card {
    position: relative;
    display: grid;
    grid-template-columns: 2fr 6fr 3fr 2fr;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 14px;
    padding: 6px;
    background: var(--bhn-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y; /* cho phép scroll dọc, kéo ngang do JS xử lý */
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.bhn-card:hover {
    box-shadow: var(--bhn-shadow);
    transform: translateY(-1px);
}

.bhn-card--in-cart {
    border-color: var(--bhn-accent);
    box-shadow: 0 0 0 1px var(--bhn-accent) inset, 0 2px 12px rgba(16, 185, 129, 0.15);
}

.bhn-card__img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    pointer-events: none;
}

.bhn-card__img--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.05);
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    font-size: 24px;
}

.bhn-card__info-col {
    min-width: 0; /* cho phép chữ tràn co lại đúng cột trong grid */
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bhn-card__name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bhn-card__price {
    font-size: 12px;
    color: var(--bhn-accent-dark);
    font-weight: 700;
    line-height: 1.3;
}

.bhn-card__price--case {
    color: var(--bhn-muted);
    font-weight: 400;
}

.bhn-card__qty-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}

/* Chọn quy cách: segmented control dạng viên thuốc */
.bhn-card__pack-toggle {
    display: flex;
    border: 1px solid var(--bhn-line);
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px;
    gap: 2px;
}

.bhn-card__pack-toggle button {
    flex: 1;
    min-width: 0;
    height: 22px !important;
    min-height: 0 !important;
    border: none;
    border-radius: 999px !important;
    background: transparent;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 1px;
    line-height: 1.2;
    cursor: pointer;
    color: var(--bhn-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
    /* Ghi đè .bhn * { overflow-wrap: break-word } — nhãn "Thùng" ngắn, không cho tách đôi
     * giữa chữ (VD "Thùn"/"g") khi ô hơi hẹp; thà cắt gọn bằng ellipsis còn hơn xuống dòng xấu. */
    white-space: nowrap;
    overflow-wrap: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bhn-card__pack-toggle button.is-on {
    background: var(--bhn-grad);
    color: #fff;
}

.bhn-card__stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
}

.bhn-card__stepper button {
    width: 26px !important;
    height: 26px !important;
    flex-shrink: 0;
    border: 1px solid var(--bhn-line);
    background: rgba(255, 255, 255, 0.85);
    border-radius: 8px !important;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.bhn-card__stepper button:hover {
    background: var(--bhn-accent-soft);
    border-color: rgba(16, 185, 129, 0.4);
}

.bhn-card__stepper-val {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

.bhn-card__add-col {
    display: flex;
    justify-content: center;
}

/* Icon giỏ hàng. Flatsome ép height <button> theo em (~40px) bằng 1 rule !important nạp sau
   cùng, không thể khóa đè height nhỏ hơn được nữa — nên để width = 40px khớp theo, luôn tròn
   đều thay vì méo, thay vì cố ép height nhỏ lại. */
.bhn-card__add {
    position: relative;
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    border: none;
    background: var(--bhn-grad);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--bhn-glow);
    transition: filter 0.15s ease, transform 0.1s ease;
}

.bhn-card__add .bhn-icon-svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.bhn-card__add-plus {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    color: var(--bhn-accent-dark);
    font-size: 13px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 0 0 1.5px var(--bhn-accent);
}

.bhn-card__add:hover {
    filter: brightness(1.08);
}

.bhn-card__add:active {
    transform: scale(0.92);
}

.bhn-loading {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--bhn-muted);
    padding: 24px 0;
}

.bhn-drag-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 95;
    background: var(--bhn-grad);
    color: #fff;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 999px;
    pointer-events: none;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: var(--bhn-glow);
}

/* ---------- Panels: mobile = bottom sheet kính mờ ---------- */

.bhn-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 100;
}

.bhn-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 110;
    background: var(--bhn-glass-solid);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    max-height: 85vh;
    /* dvh theo chiều cao thực tế hiển thị — 85vh trên Safari iOS tính theo viewport lớn nhất
       (như thanh địa chỉ đang ẩn), khiến nút dưới cùng bị thanh trình duyệt che mất. */
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.22);
}

/* display:flex ở trên đè lên display:none mặc định của [hidden] — phải khai báo lại tường minh. */
.bhn-panel[hidden] {
    display: none;
}

.bhn-panel__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--bhn-line);
}

.bhn-panel__head h3 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 17px;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bhn-panel__head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.bhn-panel__close {
    width: 40px !important;
    height: 40px !important;
    border: none;
    background: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--bhn-muted);
    border-radius: 50% !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bhn-panel__close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--bhn-ink);
}

.bhn-panel__body {
    overflow-y: auto;
    padding: 8px 16px;
    flex: 1;
}

/* Panel không có __foot riêng (Tài khoản, Đơn hàng) — body là phần tử cuối, tự chừa đáy an toàn. */
.bhn-panel__body:last-child {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.bhn-panel__foot {
    /* +20px (và safe-area nếu thiết bị báo lớn hơn) — iPhone bo tròn/thanh home ở đáy màn hình
       che mất nút nếu panel dán sát cạnh dưới không có chừa khoảng trống. */
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--bhn-line);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- Cart rows: hiển thị đầy đủ, chỉ xem lại/xóa — không còn chỉnh SL/quy cách ở đây ---------- */

.bhn-cart-row {
    padding: 6px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.bhn-cart-row__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.bhn-cart-row__name {
    font-size: 15px;
    font-weight: 600;
}

.bhn-cart-row__remove {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    color: #b91c1c;
    font-size: 20px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.bhn-cart-row__remove:hover {
    background: #fee2e2;
}

.bhn-cart-row__bottom {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--bhn-muted);
}

.bhn-cart-row__unitprice {
    color: var(--bhn-muted);
}

.bhn-cart-row__linetotal {
    color: var(--bhn-ink);
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.bhn-cart-total {
    flex: 1 1 100%;
    font-size: 16px;
}

/* ---------- Đơn hàng của tôi: mỗi đơn = 1 box ngang (mã đơn / ngày mua / tổng tiền) ---------- */

.bhn-order-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--bhn-radius-sm);
    background: var(--bhn-glass);
    cursor: pointer;
    min-height: 40px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.bhn-order-row:hover {
    border-color: var(--bhn-accent);
    box-shadow: var(--bhn-shadow);
    transform: translateY(-1px);
}

.bhn-order-row__code {
    font-weight: 700;
}

.bhn-order-row__meta {
    color: var(--bhn-muted);
    font-size: 13px;
    grid-row: 2;
}

.bhn-order-row__total {
    font-weight: 700;
    color: var(--bhn-accent-dark);
    text-align: right;
}

.bhn-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    color: #374151;
    justify-self: end;
    white-space: nowrap;
}

/* Chip thanh toán phía khách (trục độc lập với trạng thái giao hàng). */
.bhn-order-row__chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    justify-self: end;
}

.bhn-pay-ok { background: #d1fae5; color: #065f46; }
.bhn-pay-due { background: #fee2e2; color: #991b1b; }

/* Trục giao hàng */
.bhn-status--da_dat { background: #e2e8f0; color: #334155; }
.bhn-status--da_xac_nhan { background: #fef3c7; color: #92400e; }
.bhn-status--dang_gui { background: #cffafe; color: #155e75; }
.bhn-status--da_giao { background: #d1fae5; color: #065f46; }
.bhn-status--huy { background: #fee2e2; color: #991b1b; }

/* ---------- Invoice preview ---------- */

.bhn-invoice h3 {
    text-align: center;
    margin: 0 0 10px;
}

.bhn-invoice__meta {
    font-size: 14px;
    line-height: 1.6;
}

/* Bảng dài: cuộn ngang trong khung riêng, không tràn layout */
.bhn-invoice__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    display: block;
    overflow-x: auto;
}

.bhn-invoice__table th,
.bhn-invoice__table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--bhn-line);
    text-align: left;
    white-space: nowrap;
}

.bhn-invoice__table td:first-child {
    white-space: normal;
    min-width: 120px;
}

.bhn-invoice__table .num {
    text-align: right;
}

.bhn-invoice__total {
    text-align: right;
    font-size: 16px;
    margin: 10px 0 4px;
}

.bhn-invoice__note {
    text-align: right;
    color: var(--bhn-muted);
    font-style: italic;
    font-size: 13px;
}

/* ---------- Toast: viên kính tối, nổi giữa đáy ---------- */

.bhn-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 120;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
}

.bhn-toast--error {
    background: rgba(185, 28, 28, 0.92);
}

/* ---------- Tablet/desktop: mở rộng ---------- */
/* Lưới sản phẩm tối đa 3 cột: 1 cột (mobile) → 2 (sm) → 3 (xl trở lên).
   Mốc 3 cột đặt ở 1280px chứ không phải 768px để MỌI iPad đều chỉ 2 sản phẩm/hàng:
   iPad dọc 768–834px, iPad ngang 1024–1194px — đều nằm dưới 1280px. */

@media (min-width: 640px) { /* sm: 2 cột */
    .bhn-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (min-width: 768px) { /* md: vẫn 2 cột, chỉ nới khoảng cách và lề */
    .bhn {
        padding: 12px 16px;
    }

    /* padding-top của .bhn tăng lên 12px — kéo topbar lên tương ứng để vẫn dính sát đỉnh. */
    .bhn-topbar {
        margin-top: -12px;
    }

    .bhn-grid {
        gap: 12px;
    }
}

@media (min-width: 1024px) { /* lg: khung desktop, KHÔNG tăng thêm cột */
    .bhn {
        padding: 16px 24px;
    }

    .bhn-topbar {
        margin-top: -16px;
    }

    .bhn-btn {
        min-height: 36px; /* desktop gọn hơn */
    }

    /* Panel thành hộp góc phải thay vì bottom-sheet */
    .bhn-panel {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 440px;
        border-radius: 20px;
        max-height: 80vh;
        box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
    }
}

@media (min-width: 1280px) { /* xl: desktop rộng — lúc này mới lên 3 cột (iPad đã nằm dưới mốc này) */
    .bhn {
        max-width: 1440px;
        margin: 0 auto;
    }

    .bhn-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
