/* Shared print document styles for payment receipt and booking confirmation */

.receipt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.receipt-modal-container {
    width: 100%;
    max-width: calc(210mm + 48px);
    height: min(95vh, calc(297mm + 80px));
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (max-width: 767px) {
    .receipt-overlay {
        padding: var(--space-3);
        align-items: flex-end;
    }

    .receipt-modal-container {
        height: min(92dvh, 720px);
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        max-width: 100%;
    }

    .receipt-toolbar {
        flex-wrap: wrap;
        gap: var(--space-2);
        padding: var(--space-3);
    }

    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .btn-tool {
        min-height: 2.75rem;
        touch-action: manipulation;
    }

    .receipt-scroll-area {
        padding: var(--space-4) var(--space-3);
    }

    .receipt-paper {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 297mm;
        padding: 12mm;
    }
}

.receipt-toolbar {
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.toolbar-title {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #94a3b8;
}

.toolbar-right {
    display: flex;
    gap: 12px;
}

.btn-tool {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-print {
    background: #0ea5e9;
    color: white;
}

.btn-print:hover {
    background: #0284c7;
    transform: translateY(-1px);
}

.btn-close {
    background: #334155;
    color: #cbd5e1;
    padding: 8px;
}

.btn-close:hover {
    background: #475569;
    color: white;
}

.receipt-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    background: #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.receipt-paper {
    background: #fff;
    width: 210mm;
    min-height: 297mm;
    max-height: 297mm;
    padding: 10mm;
    box-sizing: border-box;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    color: #2e004f;
    font-family: 'Times New Roman', Times, serif;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.receipt-border {
    border: 2px solid #2e004f;
    padding: 7mm;
    box-sizing: border-box;
    /* Full A4 frame — border runs edge-to-edge of the printable sheet */
    flex: 1 1 auto;
    width: 100%;
    min-height: calc(297mm - 20mm);
    height: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.receipt-watermark {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    width: min(52%, 160mm);
    max-width: 220px;
    height: auto;
    opacity: 0.08;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    object-fit: contain;
}

.receipt-border > *:not(.receipt-watermark) {
    position: relative;
    z-index: 1;
}

.receipt-header {
    text-align: center;
    margin-bottom: 16px;
}

.rule-ref {
    font-size: 10px;
    margin-bottom: 4px;
}

.receipt-badge {
    display: inline-block;
    background: #2e004f;
    color: #fff;
    padding: 3px 16px;
    border-radius: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 12px;
    letter-spacing: 1px;
}

.municipality-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.receipt-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
}

.fill-text {
    font-size: 18px;
    font-weight: 700;
    margin-left: 6px;
}

.receipt-content {
    line-height: 1.75;
    font-size: 14px;
}

.content-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.fill-line {
    border-bottom: 1px dotted #2e004f;
    padding: 0 6px 2px;
    font-weight: 700;
    font-style: italic;
    min-height: 22px;
    line-height: 1.3;
}

.receipt-footer {
    margin-top: 14px;
    padding-top: 4px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 4rem;
}

.receipt-bottom {
    margin-top: 0;
    padding-top: 8px;
    flex-shrink: 0;
}

.bottom-notes {
    font-size: 10px;
    font-style: italic;
    line-height: 1.35;
    border-top: 1px solid #2e004f1a;
    padding-top: 10px;
    margin-bottom: 0;
    color: #2e004f;
}

.bottom-notes p {
    margin: 0 0 4px;
}

.sig-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 20px;
    flex: 1 1 auto;
    margin-bottom: 0;
    min-height: 5.5rem;
}

.auth-sig {
    text-align: center;
    width: 180px;
    flex-shrink: 0;
    align-self: center; /* mid-right of the blank area */
    margin-top: 1.25rem;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.auth-sig::before {
    content: "";
    display: block;
    width: 100%;
    border-bottom: 1px dotted #2e004f;
    margin-bottom: 2px;
}

.sig-label {
    font-weight: 700;
    font-size: 13px;
}

.office-use {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    line-height: 1.5;
    align-self: flex-start;
}

.office-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.office-row:last-child {
    margin-bottom: 0;
}

.receipt-policy {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #2e004f44;
    font-size: 9.5px;
    line-height: 1.35;
}

.receipt-policy__title {
    font-size: 11px;
    font-weight: 700;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.receipt-policy__body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.receipt-policy__list {
    flex: 1;
    margin: 0;
    padding-left: 14px;
    min-width: 0;
}

.receipt-policy__list li {
    margin-bottom: 3px;
}

.receipt-policy__complaints {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    width: 118px;
    padding: 6px;
    border: 1px solid #2e004f33;
    border-radius: 6px;
    text-align: center;
}

.receipt-policy__qr img {
    display: block;
    width: 72px;
    height: 72px;
    border: 1px solid #2e004f22;
}

.receipt-policy__complaints-text p {
    margin: 1px 0;
    font-size: 8.5px;
    line-height: 1.2;
}

.receipt-policy__complaints-text strong {
    font-size: 9px;
}

.receipt-policy__email {
    font-weight: 600;
    word-break: break-all;
}

.receipt-policy__ref {
    font-size: 8px;
    opacity: 0.8;
}

/* Off-screen clone used only while the OS print dialog is open */
#kmc-print-root {
    position: fixed;
    left: -100vw;
    top: 0;
    width: 210mm;
    pointer-events: none;
    opacity: 0;
    z-index: -1;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html,
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Hide SPA chrome; receipt is cloned to #kmc-print-root on body */
    body.kmc-printing-receipt > *:not(#kmc-print-root) {
        display: none !important;
    }

    body.kmc-printing-receipt #kmc-print-root {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        opacity: 1 !important;
        z-index: auto !important;
        pointer-events: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body.kmc-printing-receipt #kmc-print-root,
    body.kmc-printing-receipt #kmc-print-root * {
        visibility: visible !important;
    }

    body.kmc-printing-receipt #kmc-print-root .receipt-paper {
        box-shadow: none !important;
        padding: 8mm !important;
        width: 210mm !important;
        max-width: 100% !important;
        min-height: 297mm !important;
        height: 297mm !important;
        max-height: 297mm !important;
        margin: 0 auto !important;
        border: none !important;
        background: #fff !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: avoid !important;
    }

    body.kmc-printing-receipt #kmc-print-root .receipt-border {
        border: 2px solid #2e004f !important;
        padding: 6mm !important;
        flex: 1 1 auto !important;
        width: 100% !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        position: relative !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    body.kmc-printing-receipt #kmc-print-root .receipt-watermark {
        opacity: 0.1 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Fallback when print helper did not run (e.g. Ctrl+P) */
    body:not(.kmc-printing-receipt) .receipt-overlay .no-print {
        display: none !important;
    }
}
