/* Explain: Styles for buttons, barcode/QR code labels, and toasts. */
.btn-pantry-primary {
    border: 0;
    border-radius: var(--radius-soft);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 10px 25px rgba(39, 162, 67, 0.25);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-pantry-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(39, 162, 67, 0.35);
}

.btn-pantry-ghost {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-soft);
    background: white;
    color: var(--text-color);
    font-weight: 700;
    transition: all 250ms ease;
}

.btn-pantry-ghost:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.paw-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 9999px;
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: var(--shadow-soft);
}

.toast-pantry {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 70;
    max-width: min(24rem, calc(100vw - 2rem));
    border-radius: 1.25rem;
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-hover);
    padding: 1rem 1.25rem;
    transform: translateY(1rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease, transform 250ms ease;
    font-weight: 700;
}

.toast-pantry.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* معاينة ملصق الباركود على الشاشة — كبيرة وواضحة */
.barcode-label-preview {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 0.6rem;
    width: min(30rem, 100%);
    margin-inline: auto;
    padding: 1.25rem;
    background: #ffffff;
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
}

.barcode-label-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.barcode-label-name {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-weight: 900;
    font-size: 1.2rem;
    line-height: 1.15;
    text-align: right;
    color: var(--text-color);
    overflow: hidden;
}

.barcode-label-price {
    flex: 0 0 auto;
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 2rem;
    line-height: 1;
    color: #111827;
    white-space: nowrap;
}

.barcode-label-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 13rem;
    object-fit: contain;
}

.barcode-print-root {
    display: none;
}

/* إزالة هوامش الصفحة الافتراضية في Chrome حتى تطبع الملصقات بمقاسها الحقيقي */
@page {
    size: 50mm 30mm;
    margin: 0;
}

@media print {
    html,
    body.barcode-printing {
        width: 50mm;
        min-width: 50mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.barcode-printing > *:not(.barcode-print-root) {
        display: none !important;
    }

    body.barcode-printing .barcode-print-root {
        display: block !important;
        width: 50mm;
        margin: 0 !important;
        padding: 0 !important;
    }

    .barcode-print-root .barcode-label {
        break-inside: avoid;
        page-break-inside: avoid;
        break-after: page;
        page-break-after: always;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0.4mm;
        box-sizing: border-box;
        width: 50mm;
        height: 30mm;
        margin: 0;
        padding: 1mm;
        text-align: center;
        border: none;
        border-radius: 0;
        overflow: hidden;
    }

    .barcode-print-root .barcode-label:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .barcode-print-root .barcode-label-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1mm;
        width: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .barcode-print-root .barcode-label-name {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        font-size: 7.5pt;
        font-weight: 900;
        line-height: 1.12;
        text-align: right;
        white-space: normal;
        overflow-wrap: anywhere;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .barcode-print-root .barcode-label-img {
        display: block;
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 16mm;
        margin: 0 auto;
        object-fit: contain;
        object-position: center;
    }

    .barcode-print-root .barcode-label-price {
        flex: 0 0 auto;
        margin: 0;
        font-family: var(--font-heading);
        font-size: 9pt;
        font-weight: 900;
        line-height: 1;
        white-space: nowrap;
        color: #000;
    }

    .barcode-print-root .barcode-label.qr-label {
        align-items: center;
        justify-content: flex-start;
    }

    .barcode-print-root .barcode-label.qr-label .barcode-label-head {
        width: 100%;
        margin-bottom: 0.3mm;
    }

    .barcode-print-root .barcode-label.qr-label .qr-label-img {
        display: block;
        flex: 1 1 auto;
        width: auto;
        max-width: 100%;
        height: auto;
        max-height: 19mm;
        object-fit: contain;
        margin: 0 auto;
    }
}