/* =========================================================
   CARRINHO (desktop) — protótipo "Carrinho — estados"
   Tudo fica sob .bc-cart--brand para não afetar o carrinho mobile
   (componente CarrinhoMobile), que reaproveita os nomes .bc-cart__*.
   O <style> antigo do componente continua carregando; as regras aqui
   têm especificidade maior para prevalecer sobre ele.
   ========================================================= */

.bc-cart--brand {
    --cart-text: #2B1A0E;
    --cart-muted: #6F5A46;
    --cart-brown: #4A2C17;
    --cart-brown-hover: #3A2111;
    --cart-link: #7A4A24;
    --cart-line: #EFE5D8;
    --cart-line-soft: #F3EBE0;
    --cart-chip: #F3EBE0;
    --cart-stepper: #F6F1EA;
    --cart-thumb: #EADBC6;
    --cart-thumb-icon: #8A6A4A;
    --cart-summary: #FBF8F4;
    --cart-dash: #E3D5C3;
    --cart-subtotal: #5C4A3A;
    --cart-disabled-bg: #ECE6DF;
    --cart-disabled-text: #6B5D50;
    --cart-danger: #B5473A;       /* vermelho terroso: ação destrutiva, na mesma família de tons */
    --cart-danger-hover: #973A2F;

    display: flex;
    flex-direction: column;
    font-family: Inter, system-ui, sans-serif;
    color: var(--cart-text);
}

.bc-cart--brand.bc-cart-container {
    background: var(--bc-card);
    border: none;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(74, 44, 23, 0.06);
    overflow: hidden;
}

.bc-cart--brand button {
    font: inherit;
    cursor: pointer;
}

/* ---------- Cabeçalho ---------- */

.bc-cart--brand .bc-cart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--cart-line);
}

.bc-cart__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bc-cart__header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cart-chip);
    color: var(--cart-brown);
}

.bc-cart--brand .bc-cart__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--cart-text);
}

.bc-cart__count {
    font-size: 13px;
    color: var(--cart-muted);
}

/* Pílula como os botões do carrinho; a margem negativa mantém o texto alinhado à borda */
.bc-cart__clear {
    margin-right: -10px;
    padding: 8px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--cart-link);
    font-size: 13px;
    font-weight: 600;
    transition: background-color .2s ease, color .2s ease;
}

.bc-cart__clear:hover {
    background: var(--cart-chip);
    color: var(--cart-brown);
}

.bc-cart__clear:active {
    background: var(--cart-dash);
}

/* ---------- Itens (em linha, sem caixa) ---------- */

.bc-cart--brand .bc-cart__items-wrapper {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    scrollbar-color: var(--cart-dash) transparent;
}

.bc-cart--brand .bc-cart__items-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.bc-cart--brand .bc-cart__items-wrapper::-webkit-scrollbar-thumb {
    background: var(--cart-dash);
    border-color: transparent;
}

.bc-cart--brand .bc-cart__item,
.bc-cart--brand .bc-cart__item:last-child {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--cart-line-soft);
    border-radius: 0;
}

.bc-cart__thumb {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    align-self: flex-start;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--cart-thumb);
    background-size: cover;
    background-position: center;
    color: var(--cart-thumb-icon);
}

.bc-cart__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bc-cart__line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.bc-cart__line--controls {
    align-items: center;
}

.bc-cart--brand .bc-cart__item-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--cart-text);
}

.bc-cart__item-total {
    white-space: nowrap;
    font-size: 15px;
    font-weight: 700;
}

/* Acompanhamentos e observação (não existem no protótipo: texto discreto) */
.bc-cart--brand .bc-cart__acc-list {
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.bc-cart--brand .bc-cart__acc-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
    font-size: 12px;
    color: var(--cart-muted);
}

.bc-cart__obs {
    font-size: 12px;
    font-style: italic;
    color: var(--cart-muted);
}

/* Quantidade: − / lixeira, número e + numa pílula */
.bc-cart__stepper {
    display: flex;
    align-items: center;
    height: 36px;
    border-radius: 999px;
    background: var(--cart-stepper);
}

.bc-cart__step {
    width: 40px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--cart-brown);
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    transition: background-color .2s ease;
}

.bc-cart__step:hover {
    background: var(--cart-chip);
}

.bc-cart__step:focus-visible,
.bc-cart__clear:focus-visible,
.bc-cart__cta:focus-visible {
    outline: 2px solid var(--cart-link);
    outline-offset: 2px;
}

.bc-cart__step-qty {
    width: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--cart-text);
    outline: none;
    pointer-events: none;
    appearance: textfield;
    -moz-appearance: textfield;
}

.bc-cart__step-qty::-webkit-outer-spin-button,
.bc-cart__step-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bc-cart__unit {
    margin-left: auto;
    font-size: 12px;
    color: var(--cart-muted);
}

/* Editar: botão redondo no mesmo tom do controle de quantidade.
   Em telas estreitas o "R$ x cada" desce para a linha de baixo em vez de estourar. */
.bc-cart__line--controls {
    justify-content: flex-start;
    flex-wrap: wrap;
    row-gap: 4px;
}

.bc-cart__edit {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cart-stepper);
    color: var(--cart-brown);
    transition: background-color .2s ease;
}

.bc-cart__edit:hover {
    background: var(--cart-chip);
}

.bc-cart__edit:focus-visible {
    outline: 2px solid var(--cart-link);
    outline-offset: 2px;
}

.bc-cart__edit.is-loading {
    color: transparent;
    cursor: default;
}

/* Mensagem curta no item (ex.: falha ao abrir a edição) */
.bc-cart__item-msg {
    display: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--cart-danger);
}

.bc-cart__item-msg.is-visible {
    display: block;
}

/* ---------- Resumo ---------- */

.bc-cart--brand .bc-cart__summary {
    margin: 16px 20px 0;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--cart-summary);
    border-radius: 12px;
    font-size: 14px;
}

.bc-cart__summary-row {
    display: flex;
    justify-content: space-between;
    color: var(--cart-subtotal);
}

.bc-cart--brand .bc-cart__total-row {
    display: flex;
    justify-content: space-between;
    margin: 0;
    padding-top: 10px;
    border-top: 1px dashed var(--cart-dash);
    font-size: 18px;
    font-weight: 700;
    color: var(--cart-text);
}

/* ---------- Botão de finalizar / entrar ---------- */

.bc-cart__footer {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bc-cart__cta {
    width: 100%;
    height: 56px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--cart-brown);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(74, 44, 23, 0.25);
    transition: background .2s, transform .1s;
}

.bc-cart__cta:hover {
    background: var(--cart-brown-hover);
}

.bc-cart__cta:active {
    transform: scale(.99);
}

.bc-cart__cta {
    gap: 12px;
}

.bc-cart__cta-label {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.bc-cart__cta-total {
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 700;
}

/* Carrinho vazio: botão desabilitado e centralizado */
.bc-cart__cta:disabled {
    justify-content: center;
    background: var(--cart-disabled-bg);
    color: var(--cart-disabled-text);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.bc-cart__note {
    font-size: 12px;
    text-align: center;
    color: var(--cart-muted);
}

/* ---------- Confirmação dentro do carrinho (remover item / limpar) ----------
   A barra fica escondida e aparece com .is-confirming no item (remover)
   ou no painel (limpar), no lugar do controle de quantidade / abaixo do cabeçalho. */

.bc-cart--brand .bc-cart__confirm {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 10px;
}

.bc-cart__item.is-confirming .bc-cart__confirm,
.bc-cart--brand.is-confirming > .bc-cart__confirm--all {
    display: flex;
}

.bc-cart__item.is-confirming .bc-cart__line--controls,
.bc-cart--brand.is-confirming .bc-cart__clear {
    display: none;
}

/* Limpar: faixa entre o cabeçalho e a lista */
.bc-cart--brand .bc-cart__confirm--all {
    padding: 12px 20px;
    background: var(--cart-summary);
    border-bottom: 1px solid var(--cart-line);
}

.bc-cart__confirm-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--cart-text);
}

.bc-cart__confirm-text.is-error {
    color: var(--cart-danger);
}

.bc-cart__confirm-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* Mesma altura e formato de pílula do controle de quantidade */
.bc-cart__confirm-btn {
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--cart-chip);
    color: var(--cart-brown);
    font-size: 13px;
    font-weight: 600;
    transition: background-color .2s ease;
}

.bc-cart__confirm-btn:hover {
    background: var(--cart-dash);
}

.bc-cart__confirm-btn--danger {
    background: var(--cart-danger);
    color: #fff;
}

.bc-cart__confirm-btn--danger:hover {
    background: var(--cart-danger-hover);
}

.bc-cart__confirm-btn:disabled {
    cursor: default;
}

.bc-cart__confirm-btn:focus-visible {
    outline: 2px solid var(--cart-link);
    outline-offset: 2px;
}

/* ---------- Carregando (dentro do carrinho, junto à ação) ----------
   Classes ligadas pelo script do componente enquanto a requisição roda. */

@keyframes bc-cart-spin {
    to { transform: rotate(360deg); }
}

/* Item sendo alterado/removido: linha esmaecida e sem cliques repetidos */
.bc-cart--brand .bc-cart__item.is-busy {
    pointer-events: none;
}

.bc-cart__item.is-busy .bc-cart__thumb,
.bc-cart__item.is-busy .bc-cart__body > :not(.bc-cart__line--controls):not(.bc-cart__confirm),
.bc-cart__item.is-busy .bc-cart__unit {
    opacity: 0.5;
    transition: opacity .15s ease;
}

/* Spinner no lugar do número da quantidade */
.bc-cart__stepper.is-loading {
    position: relative;
}

.bc-cart__stepper.is-loading .bc-cart__step {
    opacity: 0.35;
}

.bc-cart__stepper.is-loading .bc-cart__step-qty {
    color: transparent;
}

.bc-cart__stepper.is-loading::after,
.bc-cart__edit.is-loading::after,
.bc-cart__confirm-btn.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(74, 44, 23, 0.18);
    border-top-color: var(--cart-brown);
    border-radius: 50%;
    animation: bc-cart-spin .7s linear infinite;
}

/* Spinner no botão de confirmar (Remover / Limpar): branco sobre o vermelho */
.bc-cart__confirm-btn.is-loading {
    position: relative;
    color: transparent !important;
    cursor: default;
}

.bc-cart__confirm-btn--danger.is-loading::after {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

/* Limpar em andamento: lista, resumo e botão esmaecidos */
.bc-cart--brand.is-busy .bc-cart__items-wrapper,
.bc-cart--brand.is-busy .bc-cart__summary,
.bc-cart--brand.is-busy .bc-cart__footer {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity .15s ease;
}

@media (prefers-reduced-motion: reduce) {
    .bc-cart__stepper.is-loading::after,
    .bc-cart__confirm-btn.is-loading::after {
        animation-duration: 1.6s;
    }
}

/* ---------- Bottom Sheet (modal .bc-sheet, usado pelo #modalCarrinhoMobile) ----------
   Continua sendo um modal do Bootstrap: fundo escuro, toque fora, Esc e foco funcionam igual.
   Aqui só muda a apresentação: painel preso à base da tela que desliza de baixo para cima.
   Celular: largura toda. Telas maiores: coluna centralizada, ainda presa à base. */

.modal.fade.bc-sheet {
    /* O painel não esmaece, só desliza. A duração aqui também é o tempo que o Bootstrap
       espera antes de esconder o modal ao fechar, então acompanha a animação de saída. */
    opacity: 1;
    transition: opacity .34s linear;
}

.modal.fade.bc-sheet .modal-dialog {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    transform: translateY(100%);
    transition: transform .34s cubic-bezier(.32, .72, 0, 1);
}

.modal.fade.bc-sheet.show .modal-dialog {
    transform: none;
}

.bc-sheet .bc-sheet__content {
    max-height: calc(100vh / var(--app-zoom, 1) - 24px);
    max-height: calc(100dvh / var(--app-zoom, 1) - 24px);
    overflow: hidden;
    border: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(42, 21, 8, 0.18);
    /* respeita a barra de gestos do iPhone */
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bc-card);
}

/* O painel do carrinho acompanha os cantos do sheet */
.bc-sheet .bc-cart--mobile.bc-cart-container {
    border-radius: 20px 20px 0 0;
}

/* Alça visual no topo, padrão de bottom sheet */
.bc-sheet .bc-sheet__content::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: #E3D5C3;
}

.bc-sheet .bc-cart--mobile .bc-cart__header {
    padding-top: 12px;
    touch-action: none; /* o arrastar para baixo fecha o sheet (wwwroot/js/carrinho.js) */
}

/* Tablet e desktop: coluna centralizada presa à base, com respiro nas laterais */
@media (min-width: 576px) {
    .modal.fade.bc-sheet .modal-dialog {
        max-width: 480px;
    }
}

@media (min-width: 992px) {
    .modal.fade.bc-sheet .modal-dialog {
        max-width: 520px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade.bc-sheet,
    .modal.fade.bc-sheet .modal-dialog {
        transition-duration: .01s;
    }
}

/* ---------- Carrinho mobile (modal #modalCarrinhoMobile) ----------
   Mesma identidade do desktop; aqui só o que muda por estar dentro do modal. */

.bc-cart--mobile.bc-cart-container {
    border-radius: 20px;
    box-shadow: none;
}

/* A lista rola por dentro para o resumo e os botões ficarem sempre visíveis */
.bc-cart--mobile .bc-cart__items-wrapper {
    max-height: calc(48vh / var(--app-zoom, 1));
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

/* Cabeçalho mobile: "Limpar" + fechar lado a lado */
.bc-cart__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bc-cart--mobile .bc-cart__clear {
    margin-right: 0;
}

.bc-cart__close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cart-stepper);
    color: var(--cart-brown);
    transition: background-color .2s ease;
}

.bc-cart__close:hover {
    background: var(--cart-chip);
}

/* Botão secundário (fechar / continuar comprando) */
.bc-cart__secondary {
    width: 100%;
    height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    background: var(--cart-chip);
    color: var(--cart-brown);
    font-size: 15px;
    font-weight: 600;
    transition: background-color .2s ease;
}

.bc-cart__secondary:hover {
    background: var(--cart-dash);
}

.bc-cart__close:focus-visible,
.bc-cart__secondary:focus-visible {
    outline: 2px solid var(--cart-link);
    outline-offset: 2px;
}

/* Telas estreitas: menos respiro lateral e miniatura menor */
@media (max-width: 400px) {
    .bc-cart--mobile .bc-cart__header {
        padding: 16px 16px 12px;
    }

    .bc-cart--mobile .bc-cart__item,
    .bc-cart--mobile .bc-cart__item:last-child {
        gap: 10px;
        padding: 12px 16px;
    }

    .bc-cart--mobile .bc-cart__thumb {
        width: 44px;
        height: 44px;
    }

    .bc-cart--mobile .bc-cart__item-name,
    .bc-cart--mobile .bc-cart__item-total {
        font-size: 14px;
    }

    .bc-cart--mobile .bc-cart__summary {
        margin: 12px 16px 0;
    }

    .bc-cart--mobile .bc-cart__footer {
        padding: 12px 16px 16px;
    }

    .bc-cart--mobile .bc-cart__cta {
        height: 52px;
        padding: 0 12px 0 16px;
        font-size: 14px;
    }

    .bc-cart--mobile .bc-cart__cta-label {
        gap: 6px;
    }

    .bc-cart--mobile .bc-cart__cta-total {
        padding: 5px 8px;
    }
}

/* ---------- Carrinho vazio ---------- */

.bc-cart__empty {
    padding: 40px 24px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.bc-cart__empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cart-chip);
    color: var(--cart-thumb-icon);
}

.bc-cart__empty-title {
    font-size: 16px;
    font-weight: 700;
}

.bc-cart__empty-text {
    font-size: 14px;
    color: var(--cart-muted);
}

/* "+" travado no limite do estoque */
.bc-cart__step:disabled { opacity: .35; cursor: not-allowed; }
.bc-cart__step:disabled:hover { background: inherit; color: inherit; }
