/* ==========================================================================
   Drawer Cart — BR Distribuidora
   ========================================================================== */

/* Garante que [hidden] funcione mesmo em elementos com display:flex definido abaixo */
.brd-drawer-loading[hidden],
.brd-drawer-empty[hidden],
.brd-drawer-items[hidden],
.brd-drawer-footer[hidden],
.brd-drawer-shipping-bar[hidden],
.brd-drawer-zoom[hidden] {
    display: none !important;
}

/* ── Overlay ─────────────────────────────────────────────────── */
.brd-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
    transition: background 0.35s ease;
}

.brd-drawer-overlay.is-visible {
    background: rgba(0, 0, 0, 0.45);
}

/* ── Drawer ──────────────────────────────────────────────────── */
.brd-drawer-cart {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 100vw;
    height: 100dvh;
    background: #ffffff;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid #e8e8e8;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
}

.brd-drawer-cart.is-open {
    transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────────── */
.brd-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 18px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #ffffff;
}

.brd-drawer-title-wrap {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brd-drawer-title {
    font-family: var(--brd-font-family, 'Galano Grotesque', sans-serif);
    font-size: 16px;
    font-weight: 700;
    color: #0D0D0D;
    margin: 0;
    line-height: 1.2;
}

.brd-drawer-count {
    font-size: 12px;
    color: #999999;
    font-weight: 400;
}

.brd-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 50%;
    color: #666666;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.brd-drawer-close:hover {
    background: #ebebeb;
    color: #0D0D0D;
}

/* ── Barra de frete grátis ───────────────────────────────────── */
.brd-drawer-shipping-bar {
    flex-shrink: 0;
    padding: 12px 20px 14px;
    background: #f9f9f9;
    border-bottom: 1px solid #eeeeee;
}

.brd-drawer-shipping-msg {
    font-size: 12px;
    color: #666666;
    margin: 0 0 10px;
    line-height: 1.4;
}

.brd-drawer-shipping-msg strong {
    color: #0D0D0D;
    font-weight: 700;
}

.brd-drawer-shipping-bar.is-achieved .brd-drawer-shipping-msg {
    color: #229a64;
}

.brd-drawer-shipping-bar.is-achieved .brd-drawer-shipping-msg strong {
    color: #229a64;
}

/* Estrada: trilho + bandeira lado a lado */
.brd-drawer-shipping-road {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 28px; /* espaço para o caminhão não sair pela esquerda em 0% */
}

.brd-drawer-shipping-track {
    flex: 1;
    height: 6px;
    background: #e4e4e4;
    border-radius: 99px;
    overflow: visible; /* carro pode ultrapassar a borda */
    position: relative;
}

.brd-drawer-shipping-fill {
    position: relative;
    height: 100%;
    min-width: 6px;
    background: linear-gradient(90deg, #206BB3 0%, #2d83d4 100%);
    border-radius: 99px;
    transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: visible;
}

.brd-drawer-shipping-bar.is-achieved .brd-drawer-shipping-fill {
    background: linear-gradient(90deg, #1a8a56 0%, #229a64 100%);
}

/* Caminhão: pílula com ícone outline animado */
.brd-drawer-shipping-truck {
    position: absolute;
    right: -28px; /* metade da largura da pílula */
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 34px;
    background: #ffffff;
    border: 2px solid #206BB3;
    border-radius: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 12px rgba(32, 107, 179, 0.3);
    color: #206BB3;
    animation: brd-truck-rumble 0.4s ease-in-out infinite alternate;
}

/* Linhas de velocidade dentro do SVG pulsam */
.brd-drawer-shipping-truck .brd-car-lines {
    animation: brd-lines-pulse 0.4s ease-in-out infinite alternate;
}

@keyframes brd-truck-rumble {
    from { transform: translateY(-53%); }
    to   { transform: translateY(-47%); }
}

@keyframes brd-lines-pulse {
    from { opacity: 0.2; }
    to   { opacity: 0.9; }
}

/* Estado chegada: fica verde e salta */
.brd-drawer-shipping-bar.is-achieved .brd-drawer-shipping-truck {
    border-color: #229a64;
    box-shadow: 0 2px 14px rgba(34, 154, 100, 0.4);
    color: #229a64;
    animation: brd-truck-arrive 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes brd-truck-arrive {
    0%   { transform: translateY(-50%) scale(1); }
    45%  { transform: translateY(-66%) scale(1.2); }
    72%  { transform: translateY(-43%) scale(0.93); }
    100% { transform: translateY(-50%) scale(1); }
}

/* Bandeira no destino */
.brd-drawer-shipping-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #c0c0c0;
    transition: color 0.4s;
}

.brd-drawer-shipping-bar.is-achieved .brd-drawer-shipping-flag {
    color: #229a64;
}

/* ── Body ────────────────────────────────────────────────────── */
.brd-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f4f4f4;
    scrollbar-width: thin;
    scrollbar-color: #d8d8d8 transparent;
}

.brd-drawer-body::-webkit-scrollbar {
    width: 4px;
}

.brd-drawer-body::-webkit-scrollbar-thumb {
    background: #d8d8d8;
    border-radius: 4px;
}

/* ── Loading ─────────────────────────────────────────────────── */
.brd-drawer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 0;
    color: #206BB3;
}

.brd-drawer-spinner {
    animation: brd-drawer-spin 1s linear infinite;
    display: block;
}

@keyframes brd-drawer-spin {
    to { transform: rotate(360deg); }
}

/* ── Estado vazio ────────────────────────────────────────────── */
.brd-drawer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 24px;
    text-align: center;
    color: #cccccc;
}

.brd-drawer-empty p {
    font-size: 14px;
    color: #999999;
    margin: 0;
}

.brd-drawer-explore {
    display: inline-block;
    margin-top: 6px;
    padding: 8px 20px;
    background: rgba(32, 107, 179, 0.07);
    border: 1px solid rgba(32, 107, 179, 0.3);
    border-radius: 20px;
    color: #206BB3;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.brd-drawer-explore:hover {
    background: rgba(32, 107, 179, 0.14);
    border-color: rgba(32, 107, 179, 0.5);
    color: #206BB3;
    text-decoration: none;
}

/* ── Lista de itens ──────────────────────────────────────────── */
.brd-drawer-items {
    list-style: none;
    margin: 0;
    padding: 12px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.brd-drawer-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 12px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #ebebeb;
    position: relative;
    transition: opacity 0.2s;
}

.brd-drawer-item.is-updating {
    opacity: 0.35;
    pointer-events: none;
}

/* Coluna esquerda: imagem + preço unitário */
.brd-drawer-item-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.brd-drawer-item-unit-price {
    font-size: 11px;
    color: #aaaaaa;
    white-space: nowrap;
}

/* Thumbnail — botão de zoom */
.brd-drawer-item-thumb {
    flex-shrink: 0;
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #ebebeb;
    padding: 0;
    cursor: zoom-in;
    transition: opacity 0.15s;
}

.brd-drawer-item-thumb:hover {
    opacity: 0.85;
}

.brd-drawer-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Info */
.brd-drawer-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 20px;
}

.brd-drawer-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #0D0D0D;
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s;
}

.brd-drawer-item-name:hover {
    color: #206BB3;
    text-decoration: none;
}

.brd-drawer-item-sku {
    color: #7a7a7a;
    font-weight: 400;
    white-space: nowrap;
}

/* Pills de variação */
.brd-drawer-item-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.brd-drawer-item-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* Cores por posição — até 4 atributos */
.brd-drawer-item-pill:nth-child(1) { background: #e8f0fa; color: #1a5a99; }
.brd-drawer-item-pill:nth-child(2) { background: #f0eafa; color: #6b3fa0; }
.brd-drawer-item-pill:nth-child(3) { background: #e6f7ef; color: #1a7a4a; }
.brd-drawer-item-pill:nth-child(4) { background: #fdf3e6; color: #a05a10; }

/* Estoque — ao lado do stepper */
.brd-drawer-stock {
    font-size: 11px;
    font-weight: 500;
    color: #555555;
    white-space: nowrap;
}

.brd-drawer-stock--low {
    color: #d07010;
    font-weight: 600;
}

.brd-drawer-stock--out {
    color: #d94040;
    font-weight: 600;
}

.brd-drawer-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    gap: 6px;
}

.brd-drawer-item-foot .brd-drawer-stock {
    flex: 1;
    text-align: center;
}

/* Stepper de quantidade */
.brd-drawer-stepper {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.brd-drawer-stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 15px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    transition: background 0.12s, color 0.12s;
}

.brd-drawer-stepper-btn:hover:not(:disabled) {
    background: #e8e8e8;
    color: #0D0D0D;
}

.brd-drawer-stepper-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.brd-drawer-stepper-val {
    min-width: 24px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #0D0D0D;
    padding: 0 2px;
    user-select: none;
}

/* Preço do item */
.brd-drawer-item-total {
    font-size: 13px;
    font-weight: 700;
    color: #0D0D0D;
    white-space: nowrap;
}

/* Botão remover */
.brd-drawer-item-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    padding: 0;
    color: #cccccc;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.brd-drawer-item-remove:hover {
    color: #d94040;
    background: rgba(217, 64, 64, 0.08);
}

/* ── Footer ──────────────────────────────────────────────────── */
.brd-drawer-footer {
    flex-shrink: 0;
    padding: 16px 20px 24px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Totais */
.brd-drawer-totals {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eeeeee;
}
.brd-drawer-totals[hidden] { display: none; }

.brd-drawer-subtotal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #aaaaaa;
}

.brd-drawer-subtotal {
    background: linear-gradient(
        to top right,
        transparent calc(50% - 0.7px),
        #aaaaaa calc(50% - 0.7px),
        #aaaaaa calc(50% + 0.7px),
        transparent calc(50% + 0.7px)
    );
}

.brd-drawer-pix-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
    color: #0D0D0D;
}

.brd-drawer-pix-row > span:first-child {
    display: flex;
    align-items: center;
    gap: 7px;
}

.brd-drawer-pix-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(34, 154, 100, 0.1);
    border: 1px solid rgba(34, 154, 100, 0.25);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #229a64;
    letter-spacing: 0.02em;
}

.brd-drawer-subtotal-pix {
    color: #229a64;
}

/* CTA — wrapper em linha */
.brd-drawer-footer-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

/* Botão Voltar — visível só no mobile */
.brd-drawer-back {
    display: none;
}

/* CTA Finalizar / Carrinho */
.brd-drawer-checkout[hidden] { display: none; }
.brd-drawer-checkout {
    flex: 1;
    display: block;
    padding: 8px;
    background: #183357;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    font-family: var(--brd-font-family);
    font-size: 18px;
    font-weight: 500;
    border-radius: 9999px;
    letter-spacing: 0.01em;
    transition: background 0.15s, transform 0.1s;
}

/* Setas nos botões do footer */
.brd-btn-arrow {
    font-size: 18px;
    line-height: 1;
    vertical-align: middle;
}

.brd-drawer-checkout:hover {
    background: #206BB3;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
}


/* ── Zoom de imagem ──────────────────────────────────────────── */
.brd-drawer-zoom {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.brd-drawer-zoom-img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
    cursor: default;
    display: block;
}

.brd-drawer-zoom-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
}

.brd-drawer-zoom-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .brd-drawer-cart {
        width: 100vw;
        border-left: none;
    }

    .brd-drawer-back {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        white-space: nowrap;
        padding: 13px 16px;
        background: rgba(32, 107, 179, 0.1);
        background-color: rgba(32, 107, 179, 0.1);
        border: 1.5px solid #183357;
        color: #183357;
        border-radius: 9999px;
        font-family: var(--brd-font-family, 'Galano Grotesque', sans-serif);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 0.01em;
        cursor: pointer;
        transition: background 0.15s;
        -webkit-tap-highlight-color: transparent;
    }

    .brd-drawer-back:hover,
    .brd-drawer-back:focus,
    .brd-drawer-back:focus-visible {
        background: rgba(32, 107, 179, 0.18) !important;
        background-color: rgba(32, 107, 179, 0.18) !important;
        color: #183357;
        outline: none;
    }
}
