:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #eff4ff;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --radius: 12px;
    --tip-bg: #fffbeb;
    --tip-border: #f59e0b;
    --tip-title: #92400e;
    --tip-text: #78350f;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.card-head h2, .card > h2:first-child { margin-top: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.brand-logo { display: block; height: 48px; width: auto; margin-block: 6px; }
.header-note { color: var(--muted); font-size: .9rem; }

main.container { padding-top: 1.5rem; padding-bottom: 2rem; }

.site-footer { color: var(--muted); font-size: .85rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card.center { text-align: center; padding: 3rem 1.5rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.lead { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; counter-reset: step; flex-wrap: wrap; }
.steps li { counter-increment: step; color: var(--muted); font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.steps li::before { content: counter(step); width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); font-size: .8rem; }
.steps li:not(:last-child)::after { content: ""; width: 2rem; height: 1px; background: var(--border); margin-left: .25rem; }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps li.done::before { content: "✓"; background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.alert { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.preset { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; text-align: left; background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; padding: 1rem; cursor: pointer; font: inherit; color: inherit; }
.preset:hover { border-color: #94a3b8; }
.preset.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.preset-shape { height: 44px; border: 1.5px solid var(--muted); border-radius: 3px; margin-bottom: .4rem; background: #fff; }
.preset.selected .preset-shape { border-color: var(--primary); }
.preset-photo { display: block; height: 120px; width: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 4px; margin-bottom: .4rem; }
.preset.selected .preset-photo { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.preset-name { font-weight: 600; }.preset-meta { color: var(--muted); font-size: .82rem; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; margin-top: .3rem; }
.badge-warn { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; min-height: 150px; padding: 1.5rem; border: 2px dashed #cbd5e1; border-radius: var(--radius); background: #fafbfc; text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--primary); }
.dropzone span { color: var(--muted); font-size: .9rem; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.tips { margin: 0 0 1rem; padding: 1rem 1.25rem; background: var(--tip-bg); border: 1px solid var(--tip-border); border-radius: var(--radius); color: var(--tip-text); font-size: .95rem; }
.tips h3 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; font-size: 1.05rem; color: var(--tip-title); }
.tips-icon { width: 22px; height: 22px; flex: none; }
.tips ul { margin: 0; padding-left: 1.25rem; display: grid; gap: .35rem; }

.actions { display: flex; gap: .75rem; margin-top: 1.25rem; flex-wrap: wrap; }

.btn { font: inherit; font-weight: 600; padding: .65rem 1.1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: #94a3b8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.alert .link { color: inherit; }

.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 1rem; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Màn hình kết quả. minmax(0, …) ở cả 2 bố cục: nếu không, kích thước gốc của ảnh xem trước kéo rộng cột ⇒ tràn màn hình điện thoại. */
.result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; align-items: start; }
@media (max-width: 760px) { .result { grid-template-columns: minmax(0, 1fr); } }
.result .card > h3:first-child { margin-top: 0; }
.result .center { text-align: center; }

.preview-frame { width: min(300px, 80%); margin: 0 auto 1rem; overflow: hidden; border: 1px solid var(--border); background: #fff; box-shadow: 0 4px 14px rgba(15, 23, 42, .12); }
.preview-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Ảnh người dùng vừa chọn (chỉ ở bước tải lên) */
.upload-thumb { display: block; max-width: 100%; max-height: 220px; width: auto; height: auto; border-radius: 8px; box-shadow: 0 2px 8px rgba(15, 23, 42, .15); margin-bottom: .5rem; }

@media (max-width: 560px) {
    .card { padding: 1rem; }
    .steps li::after { display: none; }
}

.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; font-size: .9rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check-icon { flex: none; width: 1.35rem; height: 1.35rem; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #fff; }
.check-passed .check-icon { background: var(--success); }
.check-warning .check-icon { background: var(--warning); }
.check-failed .check-icon { background: var(--danger); }

.export-buttons { display: grid; gap: .5rem; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

#blazor-error-ui { background: #fffbeb; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---- Bán hàng: ảnh mềm / ảnh in, thanh toán VietQR ---- */
.card.narrow { max-width: 520px; margin: 0 auto; }
.header-note a { color: var(--primary); }
.offers { display: grid; gap: .75rem; }
.offer { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; display: grid; gap: .5rem; justify-items: start; }
.offer p { margin: 0; }
.offer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; width: 100%; }
.price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.paid-box { border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.paid-box p { margin: 0 0 .6rem; color: var(--success); }
.pay-box { border: 2px solid var(--primary); border-radius: 12px; padding: 1rem; text-align: center; display: grid; gap: .5rem; justify-items: center; }
.pay-title { margin: 0; font-size: 1.05rem; }
.pay-qr { width: min(260px, 100%); height: auto; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pay-details { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: .5rem 0; text-align: left; width: 100%; font-size: .95rem; }
.pay-details dt { color: var(--muted); }
.pay-details dd { margin: 0; overflow-wrap: anywhere; }
.pay-code { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: .05em; }
.pay-box p { margin: 0; }
.waiting { display: flex; gap: .6rem; align-items: center; text-align: left; background: var(--primary-soft); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }
.spinner.spinner-sm { width: 20px; height: 20px; border-width: 3px; margin: 0; flex: none; }
.order-form { display: grid; gap: .75rem; }
.order-form h4 { margin: 0; }
.field { display: grid; gap: .25rem; font-size: .9rem; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { color: var(--muted); }
.field legend { padding: 0; margin-bottom: .25rem; }
/* Chỉ ô nhập chữ / danh sách chọn — không áp vào radio, checkbox (nếu không sẽ bị kéo rộng 100% kèm viền, lệch chữ). */
.field input:not([type=radio]):not([type=checkbox]), .field select { font: inherit; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; }
.radio { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; line-height: 1.4; }
.radio input { flex: none; width: 1rem; height: 1rem; margin: .15rem 0 0; accent-color: var(--primary); }
/* Lựa chọn cách nhận ảnh: mỗi lựa chọn là một ô bấm được, thẳng hàng. */
fieldset.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
fieldset.field .radio { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
fieldset.field .radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.quote { border-top: 1px dashed var(--border); padding-top: .5rem; display: grid; gap: .2rem; font-size: .9rem; }
.quote > div { display: flex; justify-content: space-between; gap: 1rem; }
.quote-total { font-weight: 700; font-size: 1rem; }
.order-list { margin: 0 0 .5rem; padding-left: 1.1rem; font-size: .9rem; }
.status { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.status-awaitingPayment { background: #fffbeb; color: var(--warning); }
.status-paid, .status-printed, .status-readyForPickup, .status-shipping { background: var(--primary-soft); color: var(--primary); }
.status-completed { background: #f0fdf4; color: var(--success); }
.status-cancelled { background: #fef2f2; color: var(--danger); }

/* ---- Trang quản trị ---- */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.admin-tools { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.admin-tools form { margin: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 1rem 0; flex-wrap: wrap; }
.tab { font: inherit; background: none; border: none; border-bottom: 2px solid transparent; padding: .5rem .8rem; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; text-align: center; }
.admin-orders { display: grid; gap: .75rem; }
.admin-order { padding: 1rem 1.25rem; }
.admin-order header { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.admin-order header .price { margin-left: auto; font-size: 1.1rem; }
.admin-order p { margin: .4rem 0; }
.order-code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 1.15rem; letter-spacing: .05em; }
.admin-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
a.btn { text-decoration: none; display: inline-block; }

/* ---- Khung thông tin cửa hàng ---- */
.store-card { border: 1.5px solid var(--tip-border); background: var(--tip-bg); color: var(--tip-text); border-radius: 10px; padding: .85rem 1rem; display: grid; gap: .35rem; }
.store-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; color: var(--tip-title); font-size: .9rem; }
.store-icon { width: 20px; height: 20px; flex: none; }
.store-name { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.store-info { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: 0; font-size: .95rem; }
.store-info dt { color: var(--tip-title); }
.store-info dd { margin: 0; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.store-info a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ---- Hỗ trợ khách: nút liên hệ nổi, khung "Cần giúp?", câu hỏi thường gặp ---- */
.contact-float { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; }
.contact-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem .95rem; border-radius: 999px; font-weight: 600; font-size: .95rem; text-decoration: none; color: #fff; box-shadow: 0 4px 14px rgba(15, 23, 42, .22); }
.contact-btn svg { width: 1.3rem; height: 1.3rem; flex: none; }
.contact-zalo { background: #0068ff; }
.contact-zalo:hover { background: #0052cc; }
.contact-call { background: var(--success); }
.contact-call:hover { background: #166534; }
.site-footer { padding-bottom: 7.5rem; } /* chừa chỗ cho nút nổi, không che chữ cuối trang */

.support-hint { border: 1px dashed #93c5fd; background: var(--primary-soft); border-radius: 10px; padding: .75rem 1rem; margin: .75rem 0; }
.support-hint p { margin: 0 0 .5rem; }
.support-hint p:last-child { margin-bottom: 0; }
.support-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.support-actions .btn { text-decoration: none; font-size: .9rem; padding: .5rem .9rem; }
.btn-zalo { background: #0068ff; border-color: #0068ff; color: #fff; }
.btn-zalo:hover:not(:disabled) { background: #0052cc; border-color: #0052cc; }

.faq { margin-top: 1.25rem; }
.faq h2 { margin-top: 0; }
.faq details { border-top: 1px solid var(--border); padding: .7rem 0; }
.faq details:last-of-type { border-bottom: 1px solid var(--border); margin-bottom: .75rem; }
.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.faq details[open] summary { color: var(--primary); }
.faq details p, .faq details ul { margin: .5rem 0 0; color: var(--text); }
.faq details ul { padding-left: 1.2rem; }

@media (max-width: 560px) {
    .contact-float { right: 12px; bottom: 12px; }
    .contact-btn { padding: .55rem .8rem; font-size: .9rem; }
}

/* ---- Trang hỏi đáp & góp ý ---- */
.field textarea { font: inherit; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; resize: vertical; min-height: 7rem; box-sizing: border-box; }
.field .counter { justify-self: end; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.card.narrow + .card.narrow { margin-top: 1.25rem; }
.card.narrow > .lead + .order-form { margin-top: 1rem; }

/* Trạng thái máy in trên trang quản trị */
.printer-state { padding: .5rem .75rem; border-radius: 8px; }
.printer-state.ok { background: #e8f5e9; color: #1b5e20; }
.printer-state.bad { background: #fff3e0; color: #8a4b00; }

/* Ô mật khẩu có nút Hiện / Ẩn (trang đăng nhập quản trị) */
.field > label { color: var(--muted); }
.password-field { position: relative; }
.password-field input { padding-right: 2.9rem !important; box-sizing: border-box; }
.pw-toggle { position: absolute; top: 50%; right: .3rem; transform: translateY(-50%); display: grid; place-items: center; width: 2.2rem; height: 2.2rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--primary); background: rgba(29, 78, 216, .08); }
.pw-toggle .icon-hide, .pw-toggle[aria-pressed="true"] .icon-show { display: none; }
.pw-toggle[aria-pressed="true"] .icon-hide { display: block; }
