/* ═══════════════════════════════════════════
   UNIFIED MODAL SYSTEM — v3
   All modals use .yz-modal class
   ═══════════════════════════════════════════ */

/* Backdrop */
.yz-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity .22s ease;
}
.yz-modal-backdrop.is-open {
    opacity: 1;
}
.yz-modal-backdrop.is-closing {
    opacity: 0;
}

/* Box */
.yz-modal {
    background: var(--bg-card);
    border-radius: 18px;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,.28);
    transform: translateY(18px) scale(.97);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
    opacity: 0;
    overflow: hidden;
    position: relative;
}
.yz-modal-backdrop.is-open .yz-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.yz-modal.modal-sm  { max-width: 380px; }
.yz-modal.modal-md  { max-width: 480px; }
.yz-modal.modal-lg  { max-width: 680px; }
.yz-modal.modal-xl  { max-width: 860px; }

/* Header */
.yz-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-card);
}
.yz-modal-title {
    font-weight: 800;
    font-size: .95rem;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}
.yz-modal-title i {
    color: var(--primary);
}
.yz-modal-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .88rem;
    transition: all .15s;
    flex-shrink: 0;
}
.yz-modal-close:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* Body */
.yz-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    overscroll-behavior: contain;
}
.yz-modal-body.p-0 { padding: 0; }

/* Footer */
.yz-modal-footer {
    padding: 13px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-body);
}

/* Loading state */
.yz-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

/* Mobile */
@media (max-width: 600px) {
    .yz-modal-backdrop {
        padding: .5rem;
        align-items: flex-end;
    }
    .yz-modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
    }
    .yz-modal-backdrop.is-open .yz-modal {
        transform: translateY(0);
    }
    .yz-modal.modal-sm,
    .yz-modal.modal-md,
    .yz-modal.modal-lg { max-width: 100%; }
    .yz-modal-body { padding: 14px; }
    .yz-modal-footer { padding: 10px 14px; }
}

/* Inline modals (jQuery-based, old pattern) — unified */
.yz-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    z-index: 8000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.yz-overlay.visible {
    display: flex !important;
}
.yz-overlay > .yz-modal {
    opacity: 1;
    transform: none;
}

/* ── PRINT INVOICE ── */
@media print {
    .yz-modal-backdrop,
    .yz-overlay { position: static; background: none; padding: 0; }
    .yz-modal-header, .yz-modal-footer { display: none; }
    .yz-modal { box-shadow: none; border-radius: 0; max-height: none; overflow: visible; }
    .yz-modal-body { overflow: visible; padding: 0; }
    #invoice-print-area { display: block !important; }
}

/* Invoice print area */
#invoice-print-area {
    display: none;
    font-family: 'Public Sans', sans-serif;
    padding: 32px;
    max-width: 640px;
    margin: auto;
}

/* ── YzConfirm ── */
.yz-confirm-body {
    padding: 24px 20px 16px;
    text-align: center;
}
.yz-confirm-body p {
    font-size: .9rem;
    color: var(--text-body);
    line-height: 1.6;
    margin: 0;
}

/* Product modal: only .pbox-body scrolls (no double scrollbar) */
.yz-modal-body:has(> .pbox), .modal-body:has(> .pbox) { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.yz-modal-body > .pbox, .modal-body > .pbox { height: auto; max-height: calc(88vh - 60px); min-height: 0; flex: 1; }
.pbox-body { min-height: 0; }
