/*
 * Auth panel, order timeline, payment status page and PWA touches.
 * Uses the storefront theme variables (--primary-color, --primary-soft, ...) from css/colors/*.css,
 * so every colour follows the configured theme.
 */

/* ---------- PWA shell ---------- */
html { -webkit-tap-highlight-color: transparent; }
@media (display-mode: standalone) {
    body { overscroll-behavior-y: contain; }
    .pwa-hide-standalone { display: none !important; }
}
.pwa-install-bar {
    position: fixed; left: 12px; right: 12px; z-index: 1080;
    bottom: calc(76px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 12px;
    background: #fff; border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}
.pwa-install-bar[hidden] { display: none; }
.pwa-install-bar img { width: 40px; height: 40px; border-radius: 10px; }
.pwa-install-bar .pwa-install-text { flex: 1; font-size: 14px; line-height: 1.3; }
.pwa-install-bar .btn { min-height: 40px; }
.pwa-offline-badge {
    position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    z-index: 2000; background: #222; color: #fff; font-size: 13px; padding: 6px 14px; border-radius: 20px;
}
.pwa-offline-badge[hidden] { display: none; }
@media (min-width: 992px) { .pwa-install-bar { left: auto; right: 24px; bottom: 24px; max-width: 380px; } }

/* ---------- Login sheet: bottom sheet on phones ---------- */
@media (max-width: 575.98px) {
    #login-canvas.offcanvas-end {
        top: auto; right: 0; left: 0; bottom: 0; width: 100%;
        height: auto; max-height: 94vh; border-left: 0;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
        padding-bottom: env(safe-area-inset-bottom);
    }
    #login-canvas.offcanvas-end.showing,
    #login-canvas.offcanvas-end.show:not(.hiding) { transform: none; }
    #login-canvas .offcanvas-header::before {
        content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px;
        margin-left: -20px; border-radius: 2px; background: rgba(0, 0, 0, .18);
    }
    #login-canvas .offcanvas-header { position: relative; padding-top: 22px; }
}

/* ---------- Auth panel ---------- */
.auth-panel { max-width: 440px; margin: 0 auto; }
.auth-page .auth-panel { background: #fff; border-radius: 16px; padding: 22px 18px; box-shadow: 0 4px 24px rgba(0, 0, 0, .06); }
.auth-title { font-size: 1.25rem; font-weight: 700; margin: 4px 0 6px; }
.auth-sub { color: #6c757d; font-size: .92rem; margin-bottom: 16px; }
.auth-hint { color: #6c757d; font-size: .8rem; margin: -6px 0 12px; }
.auth-field { margin-bottom: 14px; }
.auth-field .form-label { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.auth-panel .form-control { min-height: 48px; font-size: 16px; /* no iOS zoom */ border-radius: 10px; }
.auth-panel .form-control[aria-invalid="true"] { border-color: #dc3545; }
.auth-field-error { color: #dc3545; font-size: .82rem; margin-top: 4px; min-height: 0; }
.auth-field-error:empty { display: none; }
.auth-btn { width: 100%; min-height: 48px; border-radius: 10px; font-weight: 600; margin-top: 4px; }
.auth-btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.auth-switch { text-align: center; margin: 14px 0 0; font-size: .92rem; }
.btn-link-plain {
    background: none; border: 0; padding: 6px 2px; min-height: 36px;
    color: var(--primary-color, #6133bd); font-weight: 600; cursor: pointer;
}
.btn-link-plain:disabled { color: #9aa0a6; cursor: default; }
.btn-link-plain:focus-visible, .auth-tab:focus-visible, .auth-pw-toggle:focus-visible {
    outline: 2px solid var(--primary-color, #6133bd); outline-offset: 2px; border-radius: 6px;
}

.auth-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 18px;
    background: var(--primary-soft, #efeafb); border-radius: 12px;
}
.auth-tabs[hidden] { display: none; }
.auth-tab {
    border: 0; background: transparent; border-radius: 9px; min-height: 42px; font-weight: 600; font-size: .92rem;
    color: #444; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.auth-tab[aria-selected="true"] { background: #fff; color: var(--primary-color, #6133bd); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

.auth-phone { display: flex; align-items: stretch; }
.auth-cc {
    display: flex; align-items: center; padding: 0 12px; background: #f4f4f6; border: 1px solid #ced4da;
    border-right: 0; border-radius: 10px 0 0 10px; font-weight: 600;
}
.auth-phone .form-control { border-radius: 0 10px 10px 0; }

.auth-otp { letter-spacing: .6em; text-align: center; font-size: 22px !important; font-weight: 700; }

.auth-pw { position: relative; }
.auth-pw .form-control { padding-right: 48px; }
.auth-pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border: 0; background: transparent; font-size: 20px; color: #6c757d;
    display: flex; align-items: center; justify-content: center;
}

.auth-consent { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; cursor: pointer; }
.auth-consent .form-check-input { margin-top: 3px; flex: 0 0 auto; width: 20px; height: 20px; }
.auth-locked {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 14px;
    background: #eaf7ee; color: #1a7f37; border-radius: 10px; font-size: .9rem;
}
.auth-choices { display: grid; gap: 8px; margin-bottom: 12px; }
.auth-choices[hidden] { display: none; }
.auth-choice {
    display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid #e3e3e8;
    border-radius: 12px; cursor: pointer; min-height: 56px;
}
.auth-choice:has(input:checked) { border-color: var(--primary-color, #6133bd); background: var(--primary-soft, #f4f0fc); }
.auth-choice span { display: flex; flex-direction: column; }
.auth-choice small { color: #6c757d; }

.auth-alert { border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 14px; }
.auth-alert-err { background: #fdecea; color: #b42318; }
.auth-alert-ok { background: #eaf7ee; color: #1a7f37; }
.auth-done { text-align: center; padding: 24px 0; }
.auth-done ion-icon { font-size: 56px; color: #1a7f37; }

.auth-page { padding: 24px 12px 96px; min-height: 60vh; background: #f7f7f9; }

/* ---------- Order updates timeline ---------- */
.order-timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.order-timeline li { position: relative; padding: 0 0 18px 26px; }
.order-timeline li::before {
    content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: #e3e3e8;
}
.order-timeline li:last-child::before { display: none; }
.order-timeline li::after {
    content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--primary-color, #6133bd); box-shadow: 0 0 0 3px var(--primary-soft, #efeafb);
}
.order-timeline .tl-title { font-weight: 600; }
.order-timeline .tl-time { color: #6c757d; font-size: .82rem; }

/* ---------- Payment status page ---------- */
.pay-status { max-width: 460px; margin: 0 auto; text-align: center; background: #fff; border-radius: 16px; padding: 28px 20px; }
.pay-status ion-icon { font-size: 64px; }
.pay-status .ok { color: #1a7f37; }
.pay-status .wait { color: #9a5b00; }
.pay-status .fail { color: #b42318; }

/* ---------- Cart sheet ---------- */
.cart-guest-note {
    display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; color: #6c757d;
    background: var(--primary-soft, #f4f0fc); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
}
.cart-guest-note ion-icon { flex: 0 0 auto; margin-top: 2px; color: var(--primary-color, #6133bd); }
#cartmodal .offcanvas-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#cartmodal .checkout-btn, #cartmodal .view-cart-btn { min-height: 48px; border-radius: 10px; font-weight: 600; }
@media (max-width: 575.98px) {
    #cartmodal.offcanvas-end { width: 100%; }
}

/* ---------- Product image zoom ---------- */
.mySwiper-preview .swiper-slide, .Product-Detail-card .mySwiper .swiper-slide { overflow: hidden; }
.mySwiper-preview .swiper-slide img, .Product-Detail-card .mySwiper .swiper-slide img { cursor: zoom-in; touch-action: pan-y; }
.pz-hover img { transition: transform .12s ease-out; will-change: transform; }
html.pz-lock, html.pz-lock body { overflow: hidden; }
.pz-viewer {
    position: fixed; inset: 0; z-index: 2100; background: rgba(12, 12, 14, .96);
    display: flex; align-items: center; justify-content: center;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.pz-viewer[hidden] { display: none; }
.pz-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; cursor: zoom-in; }
.pz-zoomed .pz-stage { cursor: grab; }
.pz-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; transform-origin: center center; }
.pz-close, .pz-nav {
    position: absolute; z-index: 2; border: 0; color: #fff; background: rgba(255, 255, 255, .14);
    width: 48px; height: 48px; border-radius: 50%; font-size: 30px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.pz-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.pz-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.pz-next { right: 12px; top: 50%; transform: translateY(-50%); }
.pz-nav[hidden] { display: none; }
.pz-close:focus-visible, .pz-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pz-bar {
    position: absolute; left: 0; right: 0; bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex; justify-content: center; gap: 14px; color: rgba(255, 255, 255, .8); font-size: 13px; pointer-events: none;
}
.pz-zoomed .pz-hint { display: none; }
@media (max-width: 575.98px) { .pz-nav { display: none; } }

/* ---------- Simple checkout ---------- */
.co-simple .co-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; counter-reset: s; font-size: .9rem; }
.co-simple .co-steps li { flex: 1; text-align: center; padding: 8px 4px; border-bottom: 3px solid #e3e3e8; color: #8a8f98; font-weight: 600; }
.co-simple .co-steps li.done, .co-simple .co-steps li.done a { color: #1a7f37; border-color: #1a7f37; text-decoration: none; }
.co-simple .co-steps li.active { color: var(--primary-color, #6133bd); border-color: var(--primary-color, #6133bd); }
.co-simple .billing-detail-section, .co-simple .wallet-use-section, .co-simple .Payment-Method-section, .co-simple .order-checkout-detail {
    background: #fff; border: 1px solid #ececf1; border-radius: 14px; padding: 16px; margin-bottom: 14px;
}
.co-simple .co-title { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; margin: 0 0 12px; }
.co-simple .co-num {
    width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-color, #6133bd); color: #fff; font-size: .9rem; flex: 0 0 auto;
}
.co-simple .co-fold { margin-top: 10px; }
.co-simple .co-fold summary { cursor: pointer; color: var(--primary-color, #6133bd); font-weight: 600; min-height: 36px; display: flex; align-items: center; list-style: none; }
.co-simple .co-fold summary::-webkit-details-marker { display: none; }
.co-simple .co-fold summary::before { content: "+"; margin-right: 8px; font-size: 1.1rem; }
.co-simple .co-fold[open] summary::before { content: "−"; }
.co-simple .time-slot { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.co-simple .time-slot .form-check { margin: 0; padding: 0; }
.co-simple .time-slot .form-check-label { display: flex; gap: 8px; align-items: center; border: 1px solid #e3e3e8; border-radius: 10px; padding: 10px 12px; cursor: pointer; width: 100%; min-height: 48px; }
.co-simple .time-slot .form-check-label:has(input:checked) { border-color: var(--primary-color, #6133bd); background: var(--primary-soft, #f4f0fc); }
.co-simple .time-slot .form-check-input { margin: 0; float: none; }
.co-simple .payment-type .form-check { display: grid; gap: 8px; padding: 0; margin: 0; }
.co-simple .payment-type .form-check-label { display: flex; align-items: center; gap: 12px; border: 1px solid #e3e3e8; border-radius: 12px; padding: 10px 14px; min-height: 56px; cursor: pointer; }
.co-simple .payment-type .form-check-label:has(input:checked) { border-color: var(--primary-color, #6133bd); background: var(--primary-soft, #f4f0fc); }
.co-simple .payment-type .form-check-input { margin: 0; float: none; flex: 0 0 auto; }
.co-simple .payment-type-img-box img { max-height: 36px; width: auto; }
.co-simple .ordered-product { align-items: center; }
.co-simple .ordered-product-img img { border-radius: 10px; max-height: 80px; object-fit: contain; }
.co-simple #place_order_btn { min-height: 52px; border-radius: 12px; font-size: 1.05rem; font-weight: 700; }
.co-simple .co-sticky { display: none; }
@media (max-width: 991.98px) {
    .co-simple .ordered-product-img { width: 64px; flex: 0 0 64px; }
    .co-simple .ordered-product-info { flex: 1; width: auto; }
    .co-simple .ordered-product-price { width: auto; }
    .co-simple .co-sticky {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; gap: 12px; align-items: center; justify-content: space-between;
        background: #fff; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 18px rgba(0, 0, 0, .08);
    }
    .co-simple .co-sticky small { display: block; color: #6c757d; line-height: 1; }
    .co-simple .co-sticky strong { font-size: 1.15rem; }
    .co-simple .co-sticky-btn { min-height: 48px; padding: 0 28px; border-radius: 12px; font-weight: 700; }
    .co-simple { padding-bottom: 84px; }
}
.co-simple .payment-type .form-check-label.co-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Checkout address card + popup ---------- */
.co-simple .co-addr { display: flex; gap: 12px; align-items: flex-start; border: 1px solid #e3e3e8; border-radius: 12px; padding: 14px; }
.co-simple .co-addr-pin { font-size: 24px; color: var(--primary-color, #6133bd); flex: 0 0 auto; margin-top: 2px; }
.co-simple .co-addr-body { flex: 1; min-width: 0; }
.co-simple .co-addr-body p { margin: 0 0 2px; line-height: 1.45; color: #444; overflow-wrap: anywhere; }
.co-addr-name { font-weight: 700; color: #222 !important; }
.co-addr-type, .co-addr-default {
    display: inline-block; font-size: .72rem; font-weight: 600; text-transform: capitalize; padding: 2px 8px; border-radius: 10px;
    background: var(--primary-soft, #efeafb); color: var(--primary-color, #6133bd); margin-left: 4px; vertical-align: middle;
}
.co-addr-default { background: #eaf7ee; color: #1a7f37; }
.co-simple .co-addr-change { flex: 0 0 auto; min-height: 40px; border-radius: 10px; font-weight: 600; }
.co-simple .co-addr-empty {
    display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 2px dashed var(--primary-color, #6133bd);
    background: var(--primary-soft, #f4f0fc); border-radius: 12px; padding: 16px; color: #222;
}
.co-simple .co-addr-empty ion-icon { font-size: 28px; color: var(--primary-color, #6133bd); }
.co-simple .co-addr-empty span { display: flex; flex-direction: column; }
.co-simple .co-addr-empty small { color: #6c757d; }
.co-simple #deliverable_status p { margin: 8px 0 0; font-size: .85rem; }

.co-addr-modal .modal-content { border-radius: 16px; border: 0; }
.co-addr-modal .modal-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.co-addr-modal .d-contents { display: contents; }
.co-addr-list { display: grid; gap: 10px; }
.co-addr-option {
    display: flex; gap: 12px; align-items: flex-start; border: 1px solid #e3e3e8; border-radius: 12px; padding: 14px; cursor: pointer; margin: 0;
}
.co-addr-option:has(input:checked) { border-color: var(--primary-color, #6133bd); background: var(--primary-soft, #f4f0fc); box-shadow: 0 0 0 1px var(--primary-color, #6133bd); }
.co-addr-option .form-check-input { flex: 0 0 auto; margin: 3px 0 0; float: none; width: 20px; height: 20px; }
.co-addr-option-body { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; color: #444; min-width: 0; overflow-wrap: anywhere; }
.co-addr-add {
    display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 12px; min-height: 48px;
    border: 2px dashed #d5d5dd; background: #fff; border-radius: 12px; color: var(--primary-color, #6133bd); font-weight: 600;
}
.co-addr-types { display: flex; gap: 8px; margin-bottom: 12px; }
.co-addr-types .btn { border-radius: 20px; min-height: 38px; padding: 4px 16px; }
.co-addr-form .form-label { font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.co-addr-form .form-control, .co-addr-form .form-select { min-height: 46px; border-radius: 10px; font-size: 16px; }
.co-addr-form [aria-invalid="true"] { border-color: #dc3545; }
.co-addr-modal .modal-footer { border-top: 1px solid #eee; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.co-addr-modal .modal-footer .btn { min-height: 48px; border-radius: 12px; font-weight: 700; }
@media (max-width: 575.98px) { .co-addr-modal .modal-content { border-radius: 0; } }
