/* Product detail modal (aligned with routes/cardapio/style.css) */

#product-modal {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
#product-modal:not([hidden]) { pointer-events: auto; }
#product-modal.modal-open    { opacity: 1; }

#product-modal-sheet {
    position: relative;
    z-index: 1;
    width: calc(100% - 2rem);
    max-width: 960px;
    height: 88dvh;
    max-height: 700px;
    background: #fff;
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
}
#product-modal.modal-open #product-modal-sheet {
    transform: scale(1);
    opacity: 1;
}

#modal-img-col {
    position: relative;
    flex-shrink: 0;
    height: 220px;
    background: #f1f3f4;
    overflow: hidden;
}
#modal-img-col img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#modal-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 3px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#modal-badge.hidden { display: none; }

#modal-details-col {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid rgba(0,0,0,.08);
}
#modal-close {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: none;
    background: #f1f3f4;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, transform .15s;
}
#modal-close:hover  { background: #e0e0e0; }
#modal-close:active { transform: scale(.88); }

#modal-variations {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    scrollbar-width: none;
}
#modal-variations::-webkit-scrollbar { display: none; }

#modal-footer {
    flex-shrink: 0;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid rgba(0,0,0,.08);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #fff;
}
#modal-qty-ctrl {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #f1f3f4;
    border-radius: 0.75rem;
    padding: 0.25rem 0.5rem;
}
#modal-qty-ctrl button {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: background .15s, transform .15s;
}
#modal-qty-ctrl button:hover  { background: #e0e0e0; }
#modal-qty-ctrl button:active { transform: scale(.88); }
#modal-qty {
    font-weight: 700;
    font-size: 1rem;
    color: #1c1b1a;
    min-width: 1.5rem;
    text-align: center;
    user-select: none;
}
#modal-add-btn {
    background: #00693E;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.625rem 2rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,105,62,.3);
    transition: background .15s, transform .15s;
}
#modal-add-btn:hover  { background: #005432; }
#modal-add-btn:active { transform: scale(.95); }

@media (min-width: 768px) {
    #product-modal-sheet {
        flex-direction: row;
    }
    #modal-img-col {
        width: 42%;
        flex-shrink: 0;
        height: 100%;
    }
    #modal-details-col {
        flex: 1;
        height: 100%;
    }
}

.variation-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 1.5px solid rgba(0,0,0,.1);
    cursor: pointer;
    background: transparent;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.variation-option:hover:not(.variation-option--checked) {
    background: rgba(0,0,0,.03);
}
.variation-option--checked {
    border-color: #00693E;
    background: rgba(0, 105, 62, 0.06);
}
.variation-option input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: #00693E;
    flex-shrink: 0;
}
.variation-option__name  { font-size: .875rem; color: #1c1b1a; }
.variation-option__extra { font-size: .75rem; color: #00693E; font-weight: 600; }

.variation-group--error {
    animation: shake 0.35s ease;
    outline: 2px solid #ba1a1a;
    outline-offset: 4px;
    border-radius: 12px;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    60%       { transform: translateX(6px); }
}

/* ── Desktop layout: cart list left + summary sidebar right ─────── */
@media (min-width: 1024px) {
    #cart-main {
        margin-left: 16px;
        margin-right: 0;
        width: calc(100vw - 380px - 32px);
        max-width: none;
        box-sizing: border-box;
    }

    #cart-items,
    #cart-items > .group {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    #bottom-summary {
        left: auto;
        right: 16px;
        top: calc(env(safe-area-inset-top, 0px) + 76px + 16px);
        bottom: 16px;
        width: 380px;
        z-index: 40;
        border-top: none;
        border-left: 1px solid rgba(0,0,0,.08);
        border-radius: 24px;
        box-shadow: 0 12px 40px rgba(28,27,26,0.12);
        overflow: hidden;
        padding-bottom: 0; /* ignore safe-area in sidebar */
        display: flex;
        flex-direction: column;
    }

    /* Total + Enviar pedido sempre visível no rodapé da sidebar */
    #bottom-summary > .max-w-2xl {
        flex-shrink: 0;
        margin-top: auto;
        max-width: none;
        width: 100%;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        padding: 12px 16px 16px;
    }

    #cart-progress-section.cart-progress--sidebar {
        flex: 1 1 auto;
        min-height: 0;
        margin-top: 0 !important;
        padding: 12px 12px 8px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
    }

    #cart-progress-section.cart-progress--sidebar > p {
        font-size: 0.75rem;
        line-height: 1.35;
    }

    #cart-progress-section.cart-progress--sidebar #minimum-order-card {
        padding: 0.75rem 1rem;
    }

    /* Atacado e varejo lado a lado na sidebar desktop */
    #cart-progress-section.cart-progress--sidebar #cart-price-breakdown .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    #cart-progress-section.cart-progress--sidebar .cart-price-card {
        padding: 0.625rem 0.75rem !important;
    }

    #cart-progress-section.cart-progress--sidebar .cart-price-card #total-atacado,
    #cart-progress-section.cart-progress--sidebar .cart-price-card #total-varejo {
        font-size: 1rem;
    }

    #cart-progress-section.cart-progress--sidebar #shipping-status-banner {
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
        font-size: 0.8125rem;
    }
}

/* Cards varejo / atacado no resumo */
.cart-price-card {
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.cart-price-card--active {
    border-color: rgb(var(--md-sys-color-secondary-rgb, 14 90 46) / 0.55) !important;
    background-color: rgb(var(--md-sys-color-secondary-container-rgb, 180 220 190) / 0.22);
    box-shadow: 0 2px 12px rgba(14, 90, 46, 0.12);
}

.cart-price-card--active #total-varejo,
.cart-price-card--active #total-atacado {
    color: inherit;
}

#card-total-varejo.cart-price-card--active #total-varejo {
    color: var(--md-sys-color-primary, #7d5700);
}

#card-total-atacado.cart-price-card--active #total-atacado {
    color: var(--md-sys-color-secondary, #0e5a2e);
}

.cart-atacado-progress-fill--complete {
    background: linear-gradient(90deg, var(--md-sys-color-secondary, #0e5a2e), #1a7a3e);
}

#card-total-atacado.cart-price-card--active .cart-atacado-progress-track {
    background-color: rgb(var(--md-sys-color-secondary-rgb, 14 90 46) / 0.15);
}
