/* ============================================================
   shop.css — Giao diện phía khách (frontend).
   Hiện đại, sạch, responsive. Màu lấy từ CSS variables (settings).
   ============================================================ */

:root {
    /* Fallback nếu header chưa nạp settings */
    --primary:   #1f6feb;
    --secondary: #0d1117;
    --button:    #238636;

    --bg:        #f7f8fa;
    --surface:   #ffffff;
    --text:      #1a1f2b;
    --muted:     #6b7280;
    --border:    #e7eaf0;
    --radius:    14px;
    --radius-sm: 10px;
    --shadow:    0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
    --shadow-hover: 0 8px 28px rgba(16,24,40,.14);
    --maxw:      1140px;
    --trans:     .18s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--trans); }
a:hover { color: color-mix(in srgb, var(--primary) 80%, #000); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------------- Header ---------------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
    backdrop-filter: saturate(180%) blur(6px);
}
.site-header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-weight: 700; }
.brand:hover { color: var(--text); }
.brand img { max-height: 38px; border-radius: 8px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-name { font-size: 17px; }

.cart-link {
    display: flex; align-items: center; gap: 7px;
    color: var(--text); font-weight: 600; font-size: 14px;
    padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--border);
    transition: border-color var(--trans), background var(--trans);
    position: relative;
}
.cart-link:hover { color: var(--text); border-color: var(--primary); background: var(--bg); }
.cart-badge {
    background: var(--button); color: #fff;
    border-radius: 999px; font-size: 12px; font-weight: 700;
    min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-grid; place-items: center;
}

.site-main { min-height: 60vh; padding-bottom: 48px; }

/* ---------------- Hero ---------------- */

.hero {
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--secondary)));
    background-size: cover; background-position: center;
    color: #fff;
    margin-bottom: 28px;
}
.hero-inner { padding: 64px 20px; text-align: center; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); margin: 0 0 10px; font-weight: 800; letter-spacing: -.02em; }
.hero p { font-size: clamp(15px, 2.4vw, 19px); margin: 0; opacity: .95; }

/* ---------------- Category filter ---------------- */

.cat-filter { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 26px; }
.chip {
    padding: 8px 16px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 14px; font-weight: 600;
    transition: all var(--trans);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------------- Product grid ---------------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 22px;
}
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex; flex-direction: column;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform var(--trans), box-shadow var(--trans), border-color var(--trans);
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    color: var(--text);
}
.product-thumb {
    position: relative;
    aspect-ratio: 1 / 1;           /* tỉ lệ ảnh đồng đều */
    background: var(--bg);
    overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.product-card:hover .product-thumb img { transform: scale(1.05); }
.no-img {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    color: var(--muted); font-size: 14px; background: var(--bg);
}
.no-img.big { aspect-ratio: 1/1; border-radius: var(--radius); }
.no-img.sm { width: 100%; height: 100%; font-size: 12px; }

.oos-badge {
    position: absolute; top: 12px; left: 12px;
    background: rgba(20,24,33,.82); color: #fff;
    font-size: 12px; font-weight: 700;
    padding: 5px 11px; border-radius: 999px;
    letter-spacing: .02em;
}
.product-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-name { font-size: 15.5px; margin: 0; font-weight: 600; line-height: 1.4; }
.product-price { font-size: 15px; font-weight: 700; color: var(--text); }
.btn-view {
    margin-top: auto;
    background: transparent; color: var(--primary);
    border: 1px solid var(--border);
    font-weight: 600;
}
.product-card:hover .btn-view { border-color: var(--primary); }

.empty-note { color: var(--muted); padding: 40px 0; text-align: center; font-size: 16px; }

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

.btn {
    display: inline-block;
    padding: 11px 20px; border-radius: 10px;
    font-size: 14.5px; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; text-align: center;
    transition: filter var(--trans), background var(--trans), border-color var(--trans), transform var(--trans);
}
.btn:hover { text-decoration: none; }
.btn-buy { background: var(--button); color: #fff; }
.btn-buy:hover { filter: brightness(1.08); color: #fff; transform: translateY(-1px); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ---------------- Product detail ---------------- */

.back-link { color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--primary); }

.product-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
    margin-top: 8px;
}
.detail-media {
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface);
    aspect-ratio: 1/1;
}
.detail-media img { width: 100%; height: 100%; object-fit: cover; }

/* Gallery thumbnails */
.thumb-strip { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.thumb-btn {
    width: 68px; height: 68px; padding: 0;
    border: 2px solid var(--border); border-radius: 10px;
    overflow: hidden; cursor: pointer; background: var(--surface);
    transition: border-color var(--trans);
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }
.thumb-btn:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.thumb-btn.active { border-color: var(--primary); }

.detail-title { font-size: clamp(22px, 3vw, 30px); margin: 0 0 12px; font-weight: 800; letter-spacing: -.02em; }
.detail-price { font-size: 26px; font-weight: 800; color: var(--primary); margin-bottom: 14px; min-height: 30px; }
.detail-short { color: #374151; font-size: 15.5px; margin: 0 0 22px; }

/* Description section */
.description-section {
    margin-top: 44px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px;
}
.description-section h2 { margin: 0 0 14px; font-size: 20px; font-weight: 700; }
.description-body { color: #374151; line-height: 1.75; }

.field-label { display: block; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }

.variation-list { margin-bottom: 22px; }
.variation-opt {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: border-color var(--trans), background var(--trans);
}
.variation-opt:hover { border-color: var(--primary); }
.variation-opt input { accent-color: var(--primary); width: 18px; height: 18px; }
.variation-opt:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.variation-opt.disabled { opacity: .55; cursor: not-allowed; background: var(--bg); }
.vopt-name { font-weight: 600; flex: 1; }
.vopt-price { font-weight: 700; }

.buy-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.qty-wrap { display: block; }
.qty-input {
    width: 90px; padding: 11px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 15px; text-align: center;
}
.qty-input:focus { outline: none; border-color: var(--primary); }
.btn-buy { padding: 13px 30px; font-size: 15px; }

.oos-text { color: #b42318; font-weight: 600; }

/* ---------------- Cart ---------------- */

.page-title { font-size: 26px; font-weight: 800; margin: 8px 0 20px; }

.cart-page { padding-top: 24px; }
.cart-empty { text-align: center; padding: 50px 0; color: var(--muted); }
.cart-empty p { font-size: 17px; margin-bottom: 18px; }

.cart-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cart-row {
    display: grid;
    grid-template-columns: 2.4fr .8fr 1fr .8fr .7fr;
    align-items: center; gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.cart-row:last-child { border-bottom: none; }
.cart-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
.cart-head .c-act { text-align: right; }

.c-prod { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cart-thumb { width: 60px; height: 60px; flex: 0 0 60px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.muted { color: var(--muted); font-size: 13.5px; }

.c-qty { display: flex; align-items: center; gap: 10px; }
.qty-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface);
    font-size: 18px; line-height: 1; cursor: pointer; color: var(--text);
    transition: border-color var(--trans), background var(--trans);
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-num { min-width: 22px; text-align: center; font-weight: 700; }
.c-total { font-weight: 700; }
.c-act { text-align: right; }

.inline { display: inline; }
.link-remove { background: none; border: none; color: #b42318; cursor: pointer; font-size: 13.5px; font-weight: 600; padding: 0; }
.link-remove:hover { text-decoration: underline; }

.cart-foot {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 24px; margin-top: 22px; flex-wrap: wrap;
}
.cart-summary {
    margin-left: auto; min-width: 280px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
}
.grand { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.grand b { font-size: 22px; }
.btn-checkout { width: 100%; }
.continue { text-align: center; font-size: 14px; color: var(--muted); }
.continue:hover { color: var(--primary); }

/* ---------------- Checkout ---------------- */

.checkout-page { padding-top: 24px; }
.checkout-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    align-items: start;
}
.card-pane {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.card-pane h2 { margin: 0 0 18px; font-size: 18px; font-weight: 700; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.input {
    width: 100%; padding: 11px 13px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 15px; font-family: inherit; color: var(--text); background: #fff;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea.input { resize: vertical; line-height: 1.5; }
.input.has-error { border-color: #d92d20; }
.err-msg { display: block; color: #b42318; font-size: 13px; margin-top: 5px; }

.btn-place { width: 100%; margin-top: 4px; padding: 13px; font-size: 15px; }
.pay-note { color: var(--muted); font-size: 13px; margin: 14px 0 0; text-align: center; }

.checkout-summary-col .card-pane { position: sticky; top: 84px; }
.sum-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.sum-row.unavailable { opacity: .6; }
.sum-name { display: flex; flex-direction: column; gap: 2px; }
.sum-name .muted { font-size: 13px; }
.sum-line { font-weight: 600; white-space: nowrap; }
.sum-total {
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; font-size: 16px;
}
.sum-total b { font-size: 22px; }

/* Coupon */
.coupon-box { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; margin-bottom: 12px; }
.coupon-form { display: flex; gap: 8px; }
.coupon-form .input { flex: 1; }
.coupon-applied { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #e9f7ef; border: 1px solid #b7e3c8; color: #14663b; padding: 9px 12px; border-radius: 8px; font-size: 14px; }

.sum-line-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 15px; }
.sum-line-row.discount { color: #14663b; font-weight: 600; }
.free-ship { color: #14663b; font-weight: 700; letter-spacing: .03em; }

/* ---------------- Thank you ---------------- */

.thankyou {
    max-width: 560px; margin: 40px auto; text-align: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 44px 32px;
}
.ty-check {
    width: 64px; height: 64px; margin: 0 auto 18px;
    border-radius: 50%; background: color-mix(in srgb, var(--button) 16%, transparent);
    color: var(--button); font-size: 34px; font-weight: 800;
    display: grid; place-items: center;
}
.thankyou h1 { font-size: 26px; margin: 0 0 8px; font-weight: 800; }
.ty-sub { color: var(--muted); margin: 0 0 24px; font-size: 16px; }
.ty-code-box {
    display: inline-flex; flex-direction: column; gap: 6px;
    background: var(--bg); border: 1px dashed var(--border);
    border-radius: 12px; padding: 18px 32px; margin-bottom: 22px;
}
.ty-code-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.ty-code { font-size: 28px; font-weight: 800; letter-spacing: .08em; color: var(--primary); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.ty-mail { color: #374151; margin: 0 0 26px; }

@media (max-width: 760px) {
    .checkout-grid { grid-template-columns: 1fr; }
    .checkout-summary-col .card-pane { position: static; }
    .checkout-summary-col { order: -1; }
}

/* ---------------- Flash ---------------- */

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: #e9f7ef; color: #14663b; border-color: #b7e3c8; }
.flash-error   { background: #fdecec; color: #9b1c1c; border-color: #f5c2c2; }
.flash-info    { background: #eaf1fd; color: #1d4ed8; border-color: #c2d6f5; }

/* ---------------- Footer ---------------- */

.site-footer { background: var(--secondary); color: #c7ccd6; margin-top: 40px; }
.site-footer-inner { display: flex; justify-content: space-between; gap: 24px; padding: 36px 20px 20px; flex-wrap: wrap; }
.footer-brand { font-weight: 700; color: #fff; font-size: 16px; margin-bottom: 8px; }
.footer-line { font-size: 14px; line-height: 1.7; }
.footer-copy { border-top: 1px solid rgba(255,255,255,.1); padding: 16px 20px; font-size: 13px; color: #8b93a3; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: #c7ccd6; font-size: 14px; }
.footer-links a:hover { color: #fff; }

/* Trang tĩnh */
.static-page { padding-top: 24px; }
.static-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; line-height: 1.75; color: #374151; }
.static-content h1, .static-content h2, .static-content h3 { color: var(--text); }
.static-content img { max-width: 100%; border-radius: 8px; }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
    .product-detail { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 680px) {
    .cart-head { display: none; }
    .cart-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "prod prod"
            "price qty"
            "total act";
        row-gap: 10px;
    }
    .c-prod { grid-area: prod; }
    .c-price { grid-area: price; }
    .c-qty { grid-area: qty; justify-content: flex-end; }
    .c-total { grid-area: total; }
    .c-act { grid-area: act; }
    .cart-summary { width: 100%; margin-left: 0; }
}
@media (max-width: 460px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
    .hero-inner { padding: 44px 20px; }
}
