/**
 * ThongDy Mobile Print Enhancement CSS
 * Styles for printing on mobile devices and POS printers
 */

@import url('https://fonts.googleapis.com/css2?family=Phetsarath&display=swap');

/* ===== Base Mobile Styles ===== */
body.is-mobile-app {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body.is-mobile-app button,
body.is-mobile-app .btn,
body.is-mobile-app a {
    min-height: 44px;
    min-width: 44px;
}

/* ===== Print Button Styles ===== */
.print-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 16px 0;
}

.print-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #111827;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.print-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.print-btn.primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.print-btn.primary:hover {
    background: #1d4ed8;
}

.print-btn svg,
.print-btn .icon {
    width: 18px;
    height: 18px;
}

/* ===== POS Receipt Styles (58mm / 88mm) ===== */
@media print {
    /* Hide non-print elements */
    .no-print,
    .print-btn-group,
    nav,
    header:not(.print-header),
    footer:not(.print-footer),
    .sidebar,
    .menu,
    .navbar,
    .nav-bar,
    .navigation,
    .modal,
    .popup,
    .toast,
    .actions,
    button:not(.print-btn),
    .btn:not(.print-btn),
    [class*='hide-print'] {
        display: none !important;
        visibility: hidden !important;
    }

    /* Show print-only elements */
    .print-only {
        display: block !important;
        visibility: visible !important;
    }

    /* Reset body */
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Receipt container */
    .receipt,
    .ticket,
    .invoice,
    .bill,
    .page,
    .sheet,
    [class*='print-container'] {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: #fff !important;
    }

    /* Tables */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: avoid !important;
    }

    table, th, td {
        border: 1px solid #333 !important;
    }

    th, td {
        padding: 4px 6px !important;
        text-align: left !important;
    }

    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid !important;
    }

    /* Headings */
    h1, h2, h3, h4, h5, h6 {
        margin: 6px 0 !important;
        page-break-after: avoid !important;
    }

    /* Dividers */
    .divider {
        border-top: 1px dashed #333 !important;
        margin: 6px 0 !important;
    }

    /* Barcodes */
    .barcode-box,
    .qr-code {
        page-break-inside: avoid !important;
        text-align: center !important;
    }

    /* Status pills */
    .status-pill {
        padding: 2px 8px !important;
        border-radius: 4px !important;
        font-weight: 700 !important;
    }

    .status-paid {
        background: #ecfdf3 !important;
        color: #166534 !important;
        border: 1px solid #bbf7d0 !important;
    }

    .status-unpaid {
        background: #fff7ed !important;
        color: #b45309 !important;
        border: 1px solid #fed7aa !important;
    }
}

/* ===== 58mm POS Paper ===== */
@media print and (max-width: 58mm) {
    @page {
        size: 58mm auto;
        margin: 2mm;
    }

    body {
        font-size: 12px !important;
        line-height: 1.35 !important;
        font-weight: 700 !important;
    }

    .receipt,
    .ticket,
    .page {
        width: 54mm !important;
        padding: 2mm !important;
    }

    .title {
        font-size: 16px !important;
    }

    .subtitle {
        font-size: 12px !important;
    }

    th, td {
        padding: 2px 4px !important;
        font-size: 11px !important;
    }
}

/* ===== 88mm POS Paper ===== */
@media print and (min-width: 59mm) and (max-width: 88mm) {
    @page {
        size: 88mm auto;
        margin: 3mm;
    }

    body {
        font-size: 13px !important;
        line-height: 1.4 !important;
        font-weight: 700 !important;
    }

    .receipt,
    .ticket,
    .page {
        width: 82mm !important;
        padding: 3mm !important;
    }

    .title {
        font-size: 18px !important;
    }

    .subtitle {
        font-size: 13px !important;
    }

    th, td {
        padding: 3px 5px !important;
        font-size: 12px !important;
    }
}

/* ===== A4 Paper ===== */
@media print and (min-width: 200mm) {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    body {
        font-size: 12px !important;
        line-height: 1.5 !important;
    }

    .receipt,
    .ticket,
    .page,
    .sheet {
        width: 100% !important;
        max-width: 190mm !important;
        padding: 10mm !important;
    }

    .title {
        font-size: 18px !important;
    }

    .subtitle {
        font-size: 14px !important;
    }

    th, td {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    .signatures {
        margin-top: 20mm !important;
    }
}

/* ===== Mobile App Specific Styles ===== */
.is-mobile-app .print-btn-group {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin: 0;
}

.is-mobile-app .receipt,
.is-mobile-app .ticket,
.is-mobile-app .page {
    margin-bottom: 80px;
}

/* ===== Lao Font (Primary: Phetsarath) ===== */
@font-face {
    font-family: 'Noto Sans Lao';
    src: url('https://fonts.gstatic.com/s/notosanslao/v21/bx6lNx2Ol_ixgdYWLm9BwxM3NW6BOkuf763Clj73CiQ_J1Djx9pidOt4ccbdf5MK3riB2w.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

.receipt,
.ticket,
.invoice,
.bill {
    font-family: 'Phetsarath', 'Phetsarath OT', 'Noto Sans Lao', Arial, sans-serif;
}

/* ===== POS Mobile Print Hub Styles ===== */
.pos-print-hub {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.pos-receipt-card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pos-receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.pos-receipt-id {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

.pos-receipt-total {
    font-size: 18px;
    font-weight: 700;
    color: #059669;
}

.pos-print-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pos-btn {
    flex: 1;
    min-width: 70px;
    padding: 12px 14px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.pos-btn-58 {
    background: #fef3c7;
    color: #92400e;
}

.pos-btn-58:hover, .pos-btn-58:active {
    background: #fde68a;
}

.pos-btn-88 {
    background: #dbeafe;
    color: #1e40af;
}

.pos-btn-88:hover, .pos-btn-88:active {
    background: #bfdbfe;
}

.pos-btn-print {
    background: #667eea;
    color: #fff;
}

.pos-btn-print:hover, .pos-btn-print:active {
    background: #5a67d8;
}

/* CSS Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Paper selector modal */
.paper-selector-modal {
    animation: slideUp 0.3s ease;
}

/* Toast animation */
.mobile-toast {
    animation: fadeIn 0.3s ease;
}

