/* Reusable full-screen overlay (payment, bill step, pause bill, …) */
.app-overlay {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: none;
    pointer-events: none;
}

.app-overlay.is-open {
    /* !important beats global [x-cloak] until Alpine removes the attribute */
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    /* ບໍ່ຈັບ pointer ທີ່ root — ກັນກິດຄລິກເມື່ອ backdrop/panel ຍັງບໍ່ສະແດງ (Alpine ຍັງບໍ່ພ້ອມ) */
    pointer-events: none;
}

.app-overlay.is-open > .app-overlay-backdrop {
    pointer-events: auto;
}

/* Fallback when Alpine x-show lags behind store.is-open */
.app-overlay.is-open > .app-overlay-backdrop,
.app-overlay.is-open .app-overlay-panel {
    display: block !important;
}

.app-overlay.is-open .app-overlay-stage {
    display: flex !important;
}

.app-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    pointer-events: none;
}

.app-overlay-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
}

.app-overlay-panel {
    pointer-events: auto;
    width: 100%;
    max-width: 900px;
    transform-origin: center center;
}

.app-overlay-panel.animate__animated {
    --animate-duration: 0.35s;
}

.app-overlay-backdrop.animate__animated {
    --animate-duration: 0.28s;
}

.app-overlay--sm .app-overlay-panel {
    max-width: 420px;
}

.app-overlay--lg .app-overlay-panel {
    max-width: 900px;
}

.app-overlay--rounded .app-overlay-box {
    border-radius: 1rem;
}

.app-overlay--sm .app-overlay-body:not(.app-overlay-body--flush) {
    padding: 1rem 1.15rem;
}

.app-overlay--below-pay {
    z-index: 1055;
}

.app-overlay-box {
    background: #fff;
    border-radius: 0.35rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 2rem);
    overflow: auto;
}

/* —— ຢືນຢັນພັກບິນ: large clean confirm —— */
.app-overlay--pause-confirm .app-overlay-panel {
    max-width: min(32rem, calc(100vw - 2rem));
}

.app-overlay--pause-confirm .pause-confirm-box {
    border-radius: 1.25rem;
    box-shadow:
        0 25px 50px -12px rgba(15, 23, 42, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.65) inset;
    border: 1px solid rgba(226, 232, 240, 0.9);
    overflow: hidden;
}

.pause-confirm-body {
    position: relative;
    padding: 2.25rem 1.75rem 1.65rem;
    text-align: center;
}

.pause-confirm-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pause-confirm-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.pause-confirm-icon {
    width: 4.75rem;
    height: 4.75rem;
    margin: 0 auto 1.35rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 55%, #fff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #0d6efd);
    font-size: 2.65rem;
    box-shadow: 0 8px 24px rgba(13, 110, 253, 0.12);
}

.pause-confirm-title {
    margin: 0 0 0.55rem;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.pause-confirm-msg {
    margin: 0 0 0.4rem;
    font-size: 1.0625rem;
    line-height: 1.45;
    color: #475569;
}

.pause-confirm-hint {
    margin: 0 0 1.85rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #94a3b8;
}

.pause-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.pause-confirm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 3.1rem;
    padding: 0.7rem 1rem;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 0.8rem;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.pause-confirm-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.pause-confirm-btn--ghost {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.pause-confirm-btn--ghost:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.pause-confirm-btn--primary {
    background: var(--primary, #0d6efd);
    border: none;
    color: #fff;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.38);
}

.pause-confirm-btn--primary:hover:not(:disabled) {
    background: #0b5ed7;
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.45);
}

.pause-confirm-btn--primary ion-icon {
    font-size: 1.25rem;
}

.pause-confirm-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

@media (max-width: 575.98px) {
    .pause-confirm-body {
        padding: 2rem 1.25rem 1.35rem;
    }

    .pause-confirm-actions {
        grid-template-columns: 1fr;
    }

    .pause-confirm-btn--primary {
        order: -1;
    }
}

/* —— ພັກບິນ: JSON list (Alpine) —— */
.app-overlay--pause-list .app-overlay-panel {
    max-width: min(48rem, calc(100vw - 1.5rem));
}

.pause-list-box {
    border-radius: 1.25rem;
    box-shadow:
        0 25px 50px -12px rgba(15, 23, 42, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.65) inset;
    border: 1px solid rgba(226, 232, 240, 0.9);
    overflow: hidden;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

.pause-list-head {
    position: relative;
    padding: 1.65rem 1.25rem 1rem;
    text-align: center;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-bottom: 1px solid #e2e8f0;
}

.pause-list-close {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 1.35rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pause-list-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.pause-list-head-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 55%, #fff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #0d6efd);
    font-size: 1.85rem;
    box-shadow: 0 6px 18px rgba(13, 110, 253, 0.1);
}

.pause-list-title {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.pause-list-sub {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
}

.pause-list-body {
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: min(52vh, 28rem);
    overflow-y: auto;
    padding: 0.85rem 1rem 0.5rem;
}

.pause-list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: #64748b;
    font-size: 0.9375rem;
}

.pause-list-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--primary, #0d6efd);
    border-radius: 50%;
    animation: pause-spin 0.7s linear infinite;
}

@keyframes pause-spin {
    to { transform: rotate(360deg); }
}

.pause-list-error {
    margin: 0;
    padding: 1rem;
    text-align: center;
    color: #dc3545;
    font-size: 0.9375rem;
}

.pause-list-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #94a3b8;
}

.pause-list-empty ion-icon {
    font-size: 2.75rem;
    margin-bottom: 0.5rem;
    display: block;
}

.pause-list-empty p {
    margin: 0;
    font-size: 0.9375rem;
}

.pause-list-table-wrap {
    margin: 0 -0.15rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pause-list-tbl {
    margin: 0;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.pause-list-tbl thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    padding: 0.45rem 0.5rem;
    vertical-align: middle;
}

.pause-list-tbl tbody td {
    padding: 0.45rem 0.5rem;
    vertical-align: middle;
    border-top: 1px solid #e2e8f0;
}

.pause-list-th-num {
    width: 2rem;
}

.pause-list-th-actions {
    width: 5.5rem;
}

.pause-list-row:hover {
    background: #f8fafc;
}

.pause-list-row--active {
    background: #f0fdf4;
}

.pause-list-row--active:hover {
    background: #ecfdf5;
}

.pause-list-num {
    font-size: 0.75rem;
    font-weight: 600;
}

.pause-list-code {
    font-weight: 700;
    color: #dc3545;
    word-break: break-all;
    white-space: nowrap;
}

.pause-list-dt,
.pause-list-seller {
    white-space: nowrap;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pause-list-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.2;
}

.pause-list-badge ion-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
}

.pause-list-badge--active {
    background: #dcfce7;
    color: #166534;
}

.pause-list-badge--active ion-icon {
    color: #16a34a;
}

.pause-list-badge--paused {
    background: #fee2e2;
    color: #991b1b;
}

.pause-list-badge--paused ion-icon {
    color: #dc2626;
}

.pause-list-actions {
    white-space: nowrap;
    text-align: center;
}

.pause-list-actions .pause-list-btn {
    min-height: 0;
    min-width: 2rem;
    padding: 0.25rem 0.4rem;
    line-height: 1;
}

.pause-list-actions .pause-list-btn + .pause-list-btn {
    margin-left: 0.25rem;
}

.pause-list-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.4rem;
}

.pause-list-btn ion-icon {
    font-size: 1.1rem;
    pointer-events: none;
}

.pause-list-btn--open {
    box-shadow: none;
}

.pause-list-btn--del {
    background: transparent;
}

.pause-list-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.pause-list-btn-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.65rem;
    border: 1px solid #fecaca;
    background: #fff;
    color: #dc2626;
}

.pause-list-btn-clear:hover:not(:disabled) {
    background: #fef2f2;
}

.pause-list-btn-clear:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pause-list-btn-close {
    padding: 0.5rem 1.15rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 0.65rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
}

.pause-list-btn-close:hover {
    background: #f1f5f9;
}

@media (max-width: 575.98px) {
    .pause-list-foot {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .pause-list-btn-close {
        width: 100%;
    }
}

.app-overlay-body {
    position: relative;
    padding: 1rem;
}

.app-overlay-box--payment {
    position: relative;
}

.app-overlay-payment-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
    z-index: 3;
}

.app-overlay-payment-close:hover {
    background: #e2e8f0;
    color: #334155;
}

.app-overlay-payment-close:active {
    transform: scale(0.94);
}

.app-overlay--payment .app-overlay-body {
    padding-top: 2.35rem;
}

/* iOS / Android — keep fields tappable inside overlay (stage has pointer-events: none) */
.app-overlay-panel input,
.app-overlay-panel select,
.app-overlay-panel textarea,
.app-overlay-panel .form-control,
.app-overlay-panel .select2-container,
.app-overlay-panel label,
.app-overlay-panel .btn {
    pointer-events: auto;
    touch-action: manipulation;
}

.app-overlay-body--flush {
    padding: 0;
}

body.app-overlay-open {
    overflow: hidden;
}

/* POS mobile cart layer uses z-index ~10050 !important; overlays need higher + !important */
@media (max-width: 991.98px) {
    .app-overlay.is-open,
    #md-billStep.modal.show,
    #md-billDiscount.app-overlay.is-open {
        z-index: 10150 !important;
    }

    /* Payment: centered zoom/fade panel (same as desktop) */
    .app-overlay--payment.is-open {
        z-index: 10160 !important;
        padding: 0.75rem;
        align-items: center;
        justify-content: center;
    }

    .app-overlay--payment .app-overlay-stage {
        padding: 0.75rem;
        align-items: center;
        justify-content: center;
    }

    .app-overlay--payment .app-overlay-panel {
        max-width: min(100%, 32rem);
        width: 100%;
        max-height: calc(100vh - 1.5rem);
        transform-origin: center center;
    }

    .app-overlay--payment .app-overlay-box {
        max-height: calc(100vh - 1.5rem);
        border-radius: 1rem;
        box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
    }

    .app-overlay--payment .app-overlay-body {
        max-height: calc(100vh - 4rem);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding: 2.1rem 0.85rem 0.85rem;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    }

    .app-overlay--payment .app-overlay-panel.animate__zoomIn {
        animation-duration: 0.32s;
    }

    .app-overlay--payment .app-overlay-panel.animate__zoomOut {
        animation-duration: 0.26s;
    }

    /* Bill step (ອອກບິນ): Bootstrap static modal — mobile panel sizing */
    #md-billStep.bill-step-modern.modal.show .bill-step-panel-wrap {
        max-width: min(100%, 27.5rem);
        width: 100%;
        max-height: calc(100vh - 1.5rem);
        transform-origin: center center;
    }

    #md-billStep.bill-step-modern .bill-step-box {
        max-height: calc(100vh - 1.5rem);
    }
}

/* Payment success Swal above overlay */
body.app-overlay-swal-open .swal2-container,
.swal2-container.pay-success-swal-container {
    z-index: 1085 !important;
}

.pay-success-popup.swal2-popup {
    border-radius: 0.5rem;
}

.pos-pay-autoclose-details {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: #6c757d;
}

.pos-pay-autoclose-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    color: #6c757d;
    transition: background 0.15s ease, color 0.15s ease;
}

.pos-pay-autoclose-summary::-webkit-details-marker {
    display: none;
}

.pos-pay-autoclose-summary::after {
    content: "▾";
    font-size: 0.65rem;
    opacity: 0.55;
    transition: transform 0.15s ease;
}

.pos-pay-autoclose-details[open] .pos-pay-autoclose-summary::after {
    transform: rotate(180deg);
}

.pos-pay-autoclose-summary:hover {
    background: #f1f5f9;
    color: #495057;
}

.pos-pay-autoclose-summary ion-icon {
    font-size: 0.95rem;
    opacity: 0.75;
}

.pos-pay-autoclose-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.08);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}

.pos-pay-autoclose-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    margin-top: 0.35rem;
    padding: 0.4rem 0.5rem;
    border-left: 2px solid #e2e8f0;
    padding-left: 0.65rem;
}

.pos-pay-autoclose-lbl {
    margin: 0;
    font-size: 0.75rem;
    color: #868e96;
    white-space: nowrap;
}

.pos-pay-autoclose-panel select {
    width: auto;
    min-width: 6.5rem;
    max-width: 100%;
    font-size: 0.8rem;
}

/* app-overlay fade (replaces animate.css for payment/pause only) */
@keyframes ppOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ppOverlayFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.app-overlay-panel.animate__fadeIn,
.pos-pay-modal-panel.animate__fadeIn {
    animation: ppOverlayFadeIn 0.28s ease both;
}

.app-overlay-panel.animate__fadeOut,
.pos-pay-modal-panel.animate__fadeOut,
.app-overlay-backdrop.animate__fadeOut,
.pos-pay-modal-backdrop.animate__fadeOut {
    animation: ppOverlayFadeOut 0.28s ease both;
}

.app-overlay-backdrop.animate__fadeIn,
.pos-pay-modal-backdrop.animate__fadeIn {
    animation: ppOverlayFadeIn 0.28s ease both;
}

@keyframes ppOverlayZoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.9, 0.9, 0.9);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes ppOverlayZoomOut {
    from {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
    to {
        opacity: 0;
        transform: scale3d(0.92, 0.92, 0.92);
    }
}

.app-overlay-panel.animate__zoomIn,
#md-payment .app-overlay-panel.animate__zoomIn,
#md-billStep .bill-step-panel-wrap.animate__zoomIn,
#md-billDiscount .bill-discount-panel-wrap.animate__zoomIn {
    animation: ppOverlayZoomIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app-overlay-panel.animate__zoomOut,
#md-payment .app-overlay-panel.animate__zoomOut,
#md-billStep .bill-step-panel-wrap.animate__zoomOut,
#md-billDiscount .bill-discount-panel-wrap.animate__zoomOut {
    animation: ppOverlayZoomOut 0.26s ease both;
}

/* Bootstrap product modals — layout only; do not override .modal.fade / .modal-dialog */
.modal.pos-product-modal .modal-content {
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}

.modal.pos-product-modal .modal-header {
    border-bottom: 1px solid #e2e8f0;
}

.modal.pos-product-modal .modal-dialog {
    width: calc(100% - 2rem);
    max-width: min(52rem, calc(100vw - 2rem));
}

.modal.pos-product-modal .modal-body {
    max-height: min(78vh, calc(100vh - 8rem));
    overflow-y: auto;
}

@media (max-width: 575.98px) {
    .modal.pos-product-modal .modal-dialog {
        max-width: calc(100vw - 1rem);
        margin: 0.5rem auto;
    }
}

/* Bootstrap modals — centered zoom in + fade (override default slide-up) */
.modal-zoom-fade.modal.fade {
    opacity: 1;
    transition: none;
}

.modal-zoom-fade.fade .modal-dialog {
    transform: scale(0.88) translateY(10px);
    opacity: 0;
    transform-origin: center center;
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.38s ease !important;
}

.modal-zoom-fade.show .modal-dialog {
    transform: scale(1) translateY(0) !important;
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .modal-zoom-fade.fade .modal-dialog,
    .modal-zoom-fade.show .modal-dialog {
        transform: none !important;
        opacity: 1;
        transition: none !important;
    }
}

/* viewCart edit — primary header */
#md-viewCart .modal-header.bg-primary {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

#md-viewCart .modal-header.bg-primary .modal-title {
    color: #fff;
}

#md-viewCart .modal-header.bg-primary .close {
    color: #fff;
    opacity: 0.85;
    text-shadow: none;
}

#md-viewCart .modal-header.bg-primary .close:hover {
    opacity: 1;
    color: #fff;
}
