/* Khu bác sĩ và TDV. Chỉ dùng biến màu của themes.css để đi theo giao diện người dùng chọn. */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --portal-radius: 8px; }
a, button, input, select { touch-action: manipulation; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@keyframes portal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes portal-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* Tiến trình đơn */

/* Mã đơn là chuỗi dài: chữ đơn cách để dò từng ký tự */
.order-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86rem; font-weight: 700; letter-spacing: .02em; color: var(--green-ink); overflow-wrap: anywhere; }

/* Đầu trang, số liệu, công cụ dùng chung */
.portal-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.portal-head > div:first-child { min-width: min(100%, 280px); }
.portal-head h1, .portal-title { margin: 0; font-size: clamp(1.5rem, 2.8vw, 2rem); line-height: 1.2; color: var(--green-ink); text-wrap: balance; overflow-wrap: anywhere; }
.portal-title { margin-bottom: 16px; }
.portal-eyebrow { margin-bottom: 6px; font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--green-strong); }
.portal-lead { margin-top: 6px; color: var(--muted); }
.portal-lead strong { color: var(--text); }
.portal-alert { margin-top: 16px; padding: 12px 14px; border-left: 4px solid var(--danger); border-radius: 4px; background: var(--danger-bg); color: var(--danger); font-weight: 700; }

.portal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; margin: 22px 0 0; }
.portal-stats > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--portal-radius); background: var(--panel); }
.portal-stats dt { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); }
.portal-stats dt svg { width: 18px; height: 18px; color: var(--green-strong); }
.portal-stats dd { margin: 6px 0 0; font-size: 1.45rem; font-weight: 700; line-height: 1.2; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.portal-stats.compact { display: flex; flex-wrap: wrap; margin: 0; }
.portal-stats.compact > div { min-width: 150px; padding: 10px 14px; }
.portal-stats.compact dd { margin-top: 2px; font-size: 1.15rem; }

.portal-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.search-field { position: relative; flex: 1 1 280px; }
.search-field svg { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search-field input { width: 100%; min-height: 44px; padding: 0 12px 0 40px; font-size: 1rem; color: var(--text); background: var(--panel); border: 1px solid var(--control-border); border-radius: 6px; }
.search-field input::placeholder { color: var(--muted); }
.portal-select { flex: 0 1 260px; min-width: 0; }
.portal-select select { width: 100%; min-height: 44px; padding: 0 12px; font-size: 1rem; color: var(--text); background: var(--panel); border: 1px solid var(--control-border); border-radius: 6px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px 0 14px; border: 1px solid var(--green-strong); border-radius: 999px; background: var(--selected); color: var(--green-ink); font-weight: 700; font-size: .88rem; }
.filter-chip svg { width: 16px; height: 16px; }
.filter-chip:hover { background: var(--green-light); }
.portal-count { margin: 14px 0 10px; color: var(--muted); font-size: .88rem; }

.portal-filter { display: flex; flex-wrap: wrap; gap: 6px; }
/* Chấm màu trạng thái đơn theo BMS (BackColor). */
.status-dot { display: inline-block; flex: none; width: .55rem; height: .55rem; border-radius: 50%; background: var(--status-color, var(--muted)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .22); }
.portal-filter :is(a, button) { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; transition: background .18s var(--ease-out), border-color .18s var(--ease-out), color .18s var(--ease-out); }
.portal-filter :is(a, button) span { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .76rem; text-align: center; font-variant-numeric: tabular-nums; }
.portal-filter :is(a, button):hover { border-color: var(--green-strong); }
.portal-filter :is(a[aria-current="true"], button[aria-pressed="true"]) { border-color: var(--nav-selected); background: var(--nav-selected); color: var(--nav-selected-ink); }
.portal-filter :is(a[aria-current="true"], button[aria-pressed="true"]) span { background: color-mix(in srgb, var(--nav-selected-ink) 20%, transparent); color: inherit; }

.portal-empty { display: grid; justify-items: center; gap: 6px; margin-top: 14px; padding: 36px 20px; text-align: center; border: 1px dashed var(--control-border); border-radius: var(--portal-radius); color: var(--muted); }
.portal-empty > svg { width: 30px; height: 30px; margin-bottom: 4px; color: var(--green-strong); }
.portal-empty strong { color: var(--text); font-size: 1.02rem; }
.portal-empty p { max-width: 46ch; }
.portal-empty .button { margin-top: 10px; }
.portal-empty.is-compact { padding: 24px 16px; }

.portal-skeleton { display: grid; gap: 12px; margin-top: 20px; }
.portal-skeleton.is-short span { height: 56px; }
.portal-skeleton span { height: 128px; border-radius: var(--portal-radius); background: var(--surface); animation: portal-pulse 1.2s ease-in-out infinite; }

.portal-panel { padding: 20px; border: 1px solid var(--line); border-radius: var(--portal-radius); background: var(--panel); }
.portal-panel :is(h2, h3) { margin: 0 0 12px; font-size: 1.05rem; color: var(--green-ink); }


/* Chi tiết đơn */
.order-detail-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.order-detail-grid > div { display: grid; gap: 16px; min-width: 0; }

.order-info section { padding-block: 14px; border-top: 1px solid var(--line); }
.order-info section:first-child { padding-top: 0; border-top: 0; }
.order-info section:last-child { padding-bottom: 0; }
.order-info h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--green-strong); }
.order-info h3 svg { width: 16px; height: 16px; }
.order-info dl { display: grid; gap: 6px; margin: 0; }
.order-info dl > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; }
.order-info dt { font-size: .88rem; color: var(--muted); }
.order-info dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.order-info dd a { color: var(--green-strong); font-weight: 700; }

/* Avatar chữ cái và nhãn trạng thái */
.avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--selected); color: var(--green-ink); font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; padding: .2rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--green-light); color: var(--green-ink); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.pill.is-danger { background: var(--danger-bg); color: var(--danger); }

/* Trang tài khoản bác sĩ */
.portal-orders { margin-top: 28px; }
.portal-orders-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.portal-orders-head h2 { margin: 0; font-size: 1.2rem; color: var(--green-ink); }

/* Đặt hàng */
.checkout-channel { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 10px 12px; border-radius: 6px; background: var(--green-light); font-size: .9rem; }
.checkout-channel svg { width: 18px; height: 18px; flex: none; color: var(--green-strong); }

/* Khu TDV */
.tdv-shell { min-height: 100dvh; background: var(--page-bg); }
.tdv-bar { position: sticky; top: 0; z-index: 20; background: var(--nav-bg); color: var(--nav-ink); box-shadow: 0 1px 0 rgb(0 0 0 / .06); }
.tdv-bar-inner { display: flex; align-items: center; gap: 10px 24px; min-height: 64px; }
.tdv-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.tdv-brand > span:last-child { display: grid; }
.tdv-brand small { font-size: .74rem; font-weight: 600; opacity: .85; }
.tdv-brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--portal-radius); background: var(--nav-selected); color: var(--nav-selected-ink); }
.tdv-brand-mark svg { width: 20px; height: 20px; }
.tdv-tabs { display: flex; gap: 4px; margin-right: auto; }
.tdv-tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 6px; font-size: .92rem; font-weight: 700; transition: background .18s var(--ease-out), color .18s var(--ease-out); }
.tdv-tabs svg { width: 18px; height: 18px; }
.tdv-tabs a:hover { background: color-mix(in srgb, var(--nav-selected) 16%, transparent); }
.tdv-tabs a.active { background: var(--nav-selected); color: var(--nav-selected-ink); }
.tdv-user { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.tdv-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; font-weight: 700; }
.tdv-link svg { width: 16px; height: 16px; }
.tdv-link:hover span { text-decoration: underline; text-underline-offset: 3px; }
.tdv-me { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
.tdv-me-name { display: grid; line-height: 1.2; }
.tdv-me-name small { font-size: .72rem; opacity: .8; }
.tdv-signout { min-height: 44px; padding: 0 14px; border: 1px solid color-mix(in srgb, currentColor 45%, transparent); border-radius: 6px; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.tdv-signout:hover { background: color-mix(in srgb, var(--nav-selected) 16%, transparent); }
.tdv-main { padding-block: 28px 56px; }
.tdv-main > .breadcrumb { margin-bottom: 14px; }


/* Bảng ở khu TDV: cả hàng bấm được để mở hộp thoại xem nhanh */
.portal-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--portal-radius); background: var(--panel); }
.portal-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.portal-table th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-align: start; text-transform: uppercase; white-space: nowrap; }
.portal-table td { padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.portal-table tbody tr:last-child td { border-bottom: 0; }
.portal-table .is-number { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.portal-table td.is-number strong { color: var(--green-ink); }
.portal-table tr.is-clickable { cursor: pointer; transition: background-color .15s ease; }
.portal-table tr.is-clickable:hover, .portal-table tr.is-clickable:focus-within, .portal-table tr.is-open { background: var(--green-light); }
.portal-table .order-status, .portal-table .order-code { white-space: nowrap; }
.cell-sub { display: block; margin-top: 2px; font-size: .82rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-muted { color: var(--muted); }
.cell-clamp { display: -webkit-box; max-width: 30ch; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-link { color: var(--green-strong); font-weight: 700; white-space: nowrap; }
.cell-ship { display: flex; align-items: center; gap: 5px; margin-top: 6px; white-space: nowrap; }
.cell-ship svg { width: 15px; height: 15px; flex: none; }
.cell-action { width: 1%; text-align: end; white-space: nowrap; }
.portal-table .button.small { min-height: 38px; padding: 0 14px; font-size: .86rem; }

/* Hộp thoại xem nhanh */
html:has(.portal-dialog[open]) { overflow: hidden; }
.portal-dialog { width: min(94vw, 980px); max-width: none; max-height: min(90dvh, 920px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--page-bg); box-shadow: 0 24px 64px rgb(0 0 0 / .24); }
.portal-dialog[open] { display: flex; flex-direction: column; animation: dialog-in .2s var(--ease-out) both; }
.portal-dialog[open]:not(:modal) { position: fixed; inset: 0; z-index: 40; }
.portal-dialog::backdrop { background: rgb(7 17 12 / .5); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.portal-dialog-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.portal-dialog-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.portal-dialog-head .avatar { width: 42px; height: 42px; font-size: .88rem; }
.portal-dialog-title { flex: 1; min-width: 0; }
.portal-dialog-title h2 { margin: 0; font-size: 1.2rem; line-height: 1.3; color: var(--green-ink); overflow-wrap: anywhere; }
.portal-dialog-title h2:focus { outline: none; }
.portal-dialog-title h2.order-code { font-size: 1.08rem; }
.portal-dialog-title p { margin-top: 2px; font-size: .86rem; color: var(--muted); }
.portal-dialog-body { flex: 1 1 auto; min-height: 0; padding: 18px 20px 22px; overflow-y: auto; overscroll-behavior: contain; }
.portal-dialog-body .portal-empty { margin-top: 0; }
.dialog-back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin: -6px 0 10px -10px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--green-strong); font: inherit; font-weight: 700; cursor: pointer; }
.dialog-back svg { width: 16px; height: 16px; transform: rotate(180deg); }
.dialog-back:hover { background: var(--green-light); }

.quick-order-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--muted); font-size: .9rem; }
.quick-order-summary strong { margin-left: auto; font-size: 1.35rem; line-height: 1.2; color: var(--green-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.quick-order-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.quick-order-actions:not(:has(button, a)) { display: none; }

.doctor-facts { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 0 0 14px; }
.doctor-facts dt { font-size: .76rem; color: var(--muted); }
.doctor-facts dd { margin: 3px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.doctor-facts a { color: var(--green-strong); }
.portal-dialog .portal-stats.compact > div { flex: 1 1 160px; }
.doctor-filter { display: block; max-width: 300px; margin: 16px 0 12px; }
.portal-dialog .portal-table-wrap + .pager { margin-top: 12px; }

/* Đăng nhập */
.account-card input:not([type="checkbox"]) { font-size: 1rem; }
.account-card { animation: portal-in .3s var(--ease-out) both; }
.password-field { position: relative; }
.password-field input { width: 100%; padding-right: 50px; }
/* Edge tự thêm nút xem mật khẩu riêng: ẩn đi để chỉ còn nút con mắt của trang */
.password-field input::-ms-reveal, .password-field input::-ms-clear { display: none; }
.password-toggle { position: absolute; top: 0; right: 0; bottom: 0; display: grid; place-items: center; width: 48px; padding: 0; border: 0; border-radius: 0 4px 4px 0; background: none; color: var(--muted); cursor: pointer; transition: color .15s ease; }
.password-toggle:hover, .password-toggle[aria-pressed="true"] { color: var(--green-ink); }
.password-toggle:focus-visible { outline-offset: -5px; }
.password-toggle svg { width: 20px; height: 20px; }
.form-field input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.field-error { margin: 0; color: var(--danger); font-size: .86rem; font-weight: 700; line-height: 1.4; }
.field-error:empty { display: none; }
.password-rules { display: grid; gap: 4px; margin: 4px 0 0; padding: 0; list-style: none; font-size: .86rem; color: var(--muted); }
.password-rules li { display: flex; align-items: center; gap: 8px; transition: color .15s ease; }
.rule-mark { display: grid; place-items: center; flex: none; width: 18px; height: 18px; border: 1.5px solid var(--control-border); border-radius: 50%; transition: background-color .15s ease, border-color .15s ease; }
.rule-mark svg { width: 12px; height: 12px; opacity: 0; stroke-width: 3; transition: opacity .15s ease; }
.password-rules li.is-met { color: var(--green-ink); }
.password-rules li.is-met .rule-mark { border-color: var(--button-bg); background: var(--button-bg); color: var(--button-ink); }
.password-rules li.is-met .rule-mark svg { opacity: 1; }

@media (max-width: 760px) {
    .order-detail-grid { grid-template-columns: minmax(0, 1fr); }
    .order-info dl > div { grid-template-columns: 96px minmax(0, 1fr); }
    .portal-stats.compact { width: 100%; }
    .portal-stats.compact > div { flex: 1 1 0; min-width: 0; }

    .portal-stats:not(.compact) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .portal-stats:not(.compact) > div:nth-child(3) { grid-column: 1 / -1; }
    .portal-stats:not(.compact) dd { font-size: 1.25rem; }

    .tdv-bar-inner { min-height: 56px; gap: 8px; }
    .tdv-brand, .tdv-signout { white-space: nowrap; }
    .tdv-brand small, .tdv-me, .tdv-link span { display: none; }
    .tdv-user { margin-left: auto; gap: 6px; }
    .tdv-tabs { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; gap: 6px; margin: 0; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgb(0 0 0 / .06); }
    .tdv-tabs a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 0 8px; font-size: .75rem; color: var(--muted); }
    .tdv-tabs a:hover { background: var(--green-light); }
    .tdv-tabs a.active { background: var(--selected); color: var(--green-ink); }
    .tdv-tabs svg { width: 22px; height: 22px; }
    .tdv-main { padding-block: 20px calc(96px + env(safe-area-inset-bottom)); }

    /* Bảng thành thẻ: mỗi hàng là một thẻ hai cột, nhãn cột nằm trên giá trị */
    .portal-table-wrap { overflow: visible; border: 0; background: none; }
    .portal-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .portal-table, .portal-table tbody { display: block; }
    .portal-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 14px; margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--portal-radius); background: var(--panel); }
    .portal-table td, .portal-table td.is-number { display: block; padding: 0; border: 0; text-align: start; }
    .portal-table td:first-child, .portal-table td.cell-wide { grid-column: 1 / -1; }
    .portal-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
    .portal-table td:first-child[data-label]::before { display: none; }
    .portal-table .cell-action { width: auto; }
    .portal-table .cell-action .button { width: 100%; min-height: 44px; }
    .cell-clamp { max-width: none; }
    .portal-table .order-code { white-space: normal; overflow-wrap: anywhere; }

    .portal-dialog { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
    .portal-dialog-head { padding: 10px 10px 10px 14px; }
    .portal-dialog-body { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
    .quick-order-summary strong { margin-left: 0; width: 100%; }
}
