/* ============================================
   BASE STYLES & VARIABLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --page-header-height: 40px;
    --page-footer-height: 30px;
}

body {
    font-family: 'Arial', sans-serif;
    min-height: 100vh;
    background-color: #FDFBF8;
    color: #222222;
}

.web-flyer {
    max-width: 1260px;
    margin: auto;
}

/* ============================================
   SEARCH BOX
   ============================================ */

.search-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: black;
    padding: 4px 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-box {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Arial', sans-serif;
}

.search-box::placeholder {
    color: #999;
}

.search-box:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 4px rgba(51, 51, 51, 0.2);
}

.clear-search-btn {
    padding: 8px 12px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    background-color: #e0e0e0;
    color: #333;
    border-color: #999;
}

.clear-search-btn:active {
    background-color: #d0d0d0;
}

/* ============================================
   PRINT SETUP
   ============================================ */

@page {
    size: A4;
    margin: 0;
}

/* ============================================
   PAGE HEADER & FOOTER
   ============================================ */

.page-header {
    position: relative;
    margin: 0;
    padding: 0;
}

.page-header img {
    width: 100%;
    display: block;
}

.page-header-left,
.page-header-right {
    font-weight: 600;
}

.page-header-left {
    justify-self: start;
}

.page-header-right {
    position: absolute;
    top: 6%;
    right: 2.8%;
    left: 55%;
    font-size: clamp(12px, 1.19vw, 18px);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: #eeeeee;
    background-color: #00BF63;
    padding: 4px 4px;
    border-radius: 8px;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: fit-content;
    margin-left: auto;
}

.page-footer {
    height: var(--page-footer-height);
    color: #eeeeee;
    background-color: #ff3131;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 20px;
    margin-top: 4px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85em;
    font-weight: 700;
    z-index: 1000;
}

.page-footer a {
    color: #eeeeee;
    text-decoration: none;
    font-weight: 900;
}

.whatsapp-button {
    background-image: url('img/WhatsAppButtonGreenSmall.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    padding: 0;
    border: none;
    cursor: pointer;
    overflow: hidden;
    width: 168px;
    height: 38px;
}

.pdf-download-button {
    display: block;
    background-image: url('img/pdf-download.svg');
    background-size: 100%;
    background-repeat: no-repeat;
    background-position: center;
    padding: 0;
    border: none;
    cursor: pointer;
    overflow: hidden;
    width: 42px;
    height: 42px;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); */
    transition: all 0.3s ease;
    text-decoration: none;
}

.pdf-download-button:hover {
    /* background-color: #b0b0b0; */
    /* box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); */
    transform: scale(1.05);
}

.pdf-download-button:active {
    transform: scale(0.95);
}

.sticky-footer {
    position: sticky;
    bottom: 0;
    z-index: 1000;
}

/* Align the sticky buttons on web flyer */
.web-flyer .sticky-footer.whatsapp-button {
    align-self: flex-end;
    margin: 4px 8px;
    bottom: 4px;
}

.web-flyer .sticky-footer.pdf-download-button {
    position: fixed;
    left: 4px;
    bottom: 4px;
    align-self: flex-start;
}

/* ============================================
   FLYER CONTAINER & HEADER
   ============================================ */

.flyer-container {
    margin: 0 auto;
    border-radius: 12px;
}

/* ============================================
   MASONRY GRID LAYOUT
   ============================================ */

.masonry-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: dense;
    grid-auto-rows: max-content;
    gap: 4px;
    /* align-content: space-around; */
    padding: 0 4px;
    margin-top: 4px;
}

/* Responsive columns: 2 on small, 3 on medium, 4 on big screens */
.web-flyer .masonry-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    .web-flyer .masonry-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .web-flyer .masonry-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   GRID ITEMS & SIZE VARIANTS
   ============================================ */

.grid-item {
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    position: relative;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    /* background-color: aquamarine; */
    page-break-inside: avoid;
    break-inside: avoid;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.grid-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.quantity-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #ff3131;
    color: white;
    border-radius: 4px;
    padding: 4px;
    ;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.large {
    grid-column: span 2;
    grid-row: span 2;
}

.tall {
    grid-row: span 2;
}

.wide {
    grid-column: span 2;
    flex-direction: row;
    gap: 4px;
}

.postage-stamp-9patch {
    border: 15px solid transparent;
    border-image-source: url('img/stampborder.png');
    border-image-slice: 24;
    border-image-repeat: repeat;
    background: #FFFC;
    background-clip: padding-box;
}

/* ============================================
   GRID ITEM CONTENT
   ============================================ */

.grid-item h2 {
    font-size: 2em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.grid-item p {
    font-size: 1.1em;
    opacity: 0.95;
}

.discount {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 10px;
}

.product-img {
    width: 90%;
    max-height: 13vh;
    object-fit: contain;
    /* optional blur borders */
    /* mask-image:
        linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%),
        linear-gradient(to bottom, transparent 0%, black 5%, black 96%, transparent 100%);
    mask-composite: intersect; */
}

.grid-item.wide .product-img {
    /* width: 50%; */
    /* object-fit: none; */
    max-height: 18vh;
}

.product-name {
    font-size: 14px;
    font-weight: bold;
    margin-top: 8px;
}

.meta {
    font-size: 12px;
}

.price {
    font-size: 22px;
    font-weight: bold;
    margin-top: 8px;
}

/* ============================================
   MULTI-PAGE PRODUCT LAYOUT
   ============================================ */

.flyer-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    page-break-after: always;
    break-after: page;
}

.flyer-page:last-child {
    page-break-after: auto;
}

/* ============================================
   POPUP MODAL
   ============================================ */

.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.popup-content {
    position: relative;
    background-color: white;
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.popup-content h3 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #222;
    text-transform: uppercase;
    line-height: 1.3;
}

.popup-price {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin: 40px 0;
}

.quantity-display {
    font-size: 48px;
    font-weight: 700;
    min-width: 80px;
    color: #222;
}

.btn-minus,
.btn-plus {
    width: 65px;
    height: 65px;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-minus {
    background-color: #E8B4B8;
}

.btn-minus.active {
    background-color: #EF5350;
}

.btn-plus {
    background-color: #00BF63;
}

.btn-minus:hover {
    background-color: #D89DA2;
    transform: scale(1.05);
}

.btn-minus.active:hover {
    background-color: #E53935;
    transform: scale(1.05);
}

.btn-plus:hover {
    background-color: #00A854;
    transform: scale(1.05);
}

.btn-minus:active,
.btn-plus:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.popup-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.btn-cancel,
.btn-add-cart {
    flex: 1;
    max-width: 200px;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, opacity 0.2s;
}

.btn-cancel {
    background-color: #E5E5E5;
    color: #666;
}

.btn-cancel:hover {
    background-color: #D0D0D0;
}

.btn-add-cart {
    background-color: #00BF63;
    color: white;
}

.btn-add-cart:hover {
    background-color: #00A854;
}

.btn-cancel:active,
.btn-add-cart:active {
    transform: scale(0.97);
    opacity: 0.9;
}