/* ============================================================
   OrderBump Inteligente
   Checkout block styles — v3.0.0 "Escada de Desconto"
   Mobile-first (grade 2 colunas em 390px), zero libs externas.
   Blindagens do Instagram In-App Browser PRESERVADAS da v2.3.8:
   - wrapper pointer-events:none, só o card/botão clicável;
   - campos do checkout sempre acima (z-index) e clicáveis;
   - checkbox real invisível mas presente no form.
   ========================================================== */

.em-ob-wrapper {
    position: relative;
    margin: 24px 0 26px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    font-family: Figtree, 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: visible;
    pointer-events: none;
    z-index: auto;
    max-width: 100%;
}
.em-ob-wrapper * {
    box-sizing: border-box;
}

.em-ob-heading {
    text-align: center;
    margin: 0 0 6px;
    padding: 0;
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.em-ob-heading::before,
.em-ob-heading::after {
    content: none !important;
}
.em-ob-intro {
    text-align: center;
    margin: 0 0 14px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.5;
}
.em-ob-intro strong {
    color: #15803d;
}

/* ---------- Escada / barra de progresso ---------- */

.em-ob-ladder {
    position: relative;
    margin: 0 0 16px;
    padding: 14px 14px 12px;
    border-radius: 14px;
    border: 1.6px solid #fde68a;
    background: linear-gradient(180deg, #fffbeb 0%, #fefce8 100%);
    overflow: hidden;
    transition: border-color .25s ease, background .25s ease;
}
.em-ob-ladder.has-discount {
    border-color: #86efac;
    background: linear-gradient(180deg, #f0fdf4 0%, #ecfdf5 100%);
}
.em-ob-ladder.at-max {
    border-color: #22c55e;
    box-shadow: 0 8px 22px rgba(34, 197, 94, .18);
}

.em-ob-ladder-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.em-ob-ladder-pct {
    font-size: 22px;
    font-weight: 800;
    color: #b45309;
    line-height: 1;
    letter-spacing: -0.02em;
    transition: color .25s ease;
}
.em-ob-ladder.has-discount .em-ob-ladder-pct {
    color: #15803d;
}
.em-ob-ladder-pct .em-ob-pct-num {
    font-size: 28px;
}
.em-ob-ladder-saving {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    animation: em-ob-pop .3s ease;
}
.em-ob-ladder-saving[hidden] {
    display: none;
}
.em-ob-ladder-saving .em-ob-saving-val,
.em-ob-ladder-saving .em-ob-saving-val .woocommerce-Price-amount {
    color: #15803d;
    font-weight: 800;
}

.em-ob-progress-bar {
    position: relative;
    width: 100%;
    height: 10px;
    background: #e7e5e4;
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
    /* espaço EMBAIXO para as flags dos marcos (ficam sob a barra —
       nunca colidem com o selo de economia que fica em cima) */
    margin: 10px 0 26px;
}
.em-ob-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #f59e0b 0%, #22c55e 100%);
    border-radius: 999px;
    transition: width .45s cubic-bezier(.22, .8, .36, 1);
}
.em-ob-milestone {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid #d6d3d1;
    transition: border-color .25s ease, background .25s ease, transform .25s ease;
    z-index: 2;
}
.em-ob-milestone.is-reached {
    border-color: #16a34a;
    background: #22c55e;
    transform: translateY(-50%) scale(1.15);
}
.em-ob-milestone-flag {
    position: absolute;
    top: 14px; /* abaixo da barra — não tampa o selo de economia nem o % */
    left: 50%;
    transform: translateX(-50%);
    font-size: 10.5px;
    font-weight: 800;
    color: #a8a29e;
    white-space: nowrap;
    transition: color .25s ease;
}
.em-ob-milestone.is-reached .em-ob-milestone-flag {
    color: #15803d;
}

.em-ob-ladder-msg {
    margin-top: 2px;
    text-align: center;
    font-size: 13px;
    color: #57534e;
    line-height: 1.45;
}
.em-ob-ladder-msg strong {
    color: #15803d;
    font-weight: 800;
}

/* Confete leve em CSS puro nos marcos (sem libs) */
.em-ob-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}
.em-ob-confetti-bit {
    position: absolute;
    top: -10px;
    width: 7px;
    height: 11px;
    border-radius: 2px;
    opacity: 0;
    animation: em-ob-fall 1.4s ease-in forwards;
}
.em-ob-confetti-0 { left: 6%;  background: #f59e0b; animation-delay: 0s; }
.em-ob-confetti-1 { left: 20%; background: #22c55e; animation-delay: .08s; }
.em-ob-confetti-2 { left: 34%; background: #3b82f6; animation-delay: .04s; }
.em-ob-confetti-3 { left: 48%; background: #ef4444; animation-delay: .12s; }
.em-ob-confetti-4 { left: 62%; background: #a855f7; animation-delay: .02s; }
.em-ob-confetti-5 { left: 76%; background: #eab308; animation-delay: .1s; }
.em-ob-confetti-6 { left: 90%; background: #10b981; animation-delay: .06s; }
.em-ob-confetti-bit:nth-child(n+8) {
    top: -18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation-duration: 1.6s;
}
@keyframes em-ob-fall {
    0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
    12%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(130px) rotate(340deg); }
}
@keyframes em-ob-pop {
    0%   { transform: scale(.7); opacity: 0; }
    70%  { transform: scale(1.06); }
    100% { transform: scale(1); opacity: 1; }
}
.em-ob-ladder.em-ob-celebrating .em-ob-ladder-pct {
    animation: em-ob-pop .45s ease;
}

/* ---------- Grade de cards (2 colunas mobile-first) ---------- */

.em-ob-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.em-ob-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    border-radius: 13px;
    border: 1.6px dashed #fbbf24;
    background: #fffbeb;
    padding: 8px 8px 10px;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.em-ob-card:hover {
    border-color: #f59e0b;
    box-shadow: 0 8px 18px rgba(245, 158, 11, .12);
}
.em-ob-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
}
.em-ob-card.is-selected {
    border-color: #22c55e;
    border-style: solid;
    background: #f0fdf4;
    box-shadow: 0 8px 18px rgba(34, 197, 94, .14);
}
.em-ob-card.is-syncing {
    opacity: .65;
    cursor: wait;
}

.em-ob-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 9px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #f3e8c9;
    pointer-events: none;
}
.em-ob-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.em-ob-added-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(21, 128, 61, .35);
    opacity: 0;
    transform: scale(.5);
    transition: opacity .18s ease, transform .18s ease;
}
.em-ob-card.is-selected .em-ob-added-badge {
    opacity: 1;
    transform: scale(1);
}

.em-ob-info {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 2px 6px;
    text-align: center;
    pointer-events: none;
}
.em-ob-info-title {
    color: #111827;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 3px;
}
.em-ob-info-desc {
    color: #6b7280;
    font-size: 11px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.em-ob-price-line {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: auto;
    color: #374151;
    font-size: 11.5px;
    line-height: 1.25;
    min-height: 17px;
}
.em-ob-price-anchor {
    color: #9ca3af;
    font-size: 11px;
}
.em-ob-price-line del,
.em-ob-price-line del .woocommerce-Price-amount {
    color: #9ca3af;
    font-size: 11px;
    font-weight: 400;
}
.em-ob-price,
.em-ob-price .woocommerce-Price-amount {
    color: #111827;
    font-size: 13px;
    font-weight: 800;
}
.em-ob-price.is-discounted,
.em-ob-price.is-discounted .woocommerce-Price-amount {
    color: #15803d;
}

/* Checkbox real: invisível mas SEMPRE no form (reconciliação server-side). */
.em-ob-checkbox {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

/* Botão de 1 toque — área ≥44px */
.em-ob-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 8px;
    border-radius: 10px;
    border: 0;
    background: #16a34a;
    color: #ffffff;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: .01em;
    cursor: pointer;
    pointer-events: none; /* o card inteiro é o alvo do toque; o botão é visual */
    transition: background .18s ease, color .18s ease;
}
.em-ob-btn.is-added {
    background: #dcfce7;
    color: #15803d;
    border: 1.5px solid #86efac;
}
.em-ob-btn.is-busy {
    opacity: .75;
}

/* ---------- Botão "× remover" no resumo do pedido ---------- */

.em-ob-remove-bump {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 9px 3px;
    background: transparent;
    border: 1px solid #fecaca;
    border-radius: 999px;
    color: #b91c1c !important;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none !important;
    line-height: 1.4;
    transition: all .15s ease;
    vertical-align: middle;
    white-space: nowrap;
    position: relative;
}
/* Área de toque efetiva >=44px sem mudar o visual (público 99% touch). */
.em-ob-remove-bump::after {
    content: '';
    position: absolute;
    top: -12px;
    bottom: -12px;
    left: -8px;
    right: -8px;
}
.em-ob-remove-bump:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b !important;
}
.em-ob-remove-bump.is-busy {
    opacity: .55;
    pointer-events: none;
    cursor: wait;
}
.em-ob-remove-icon {
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
}
.woocommerce-checkout-review-order-table .product-name {
    line-height: 1.5;
}

/* Proteção extra para templates CartFlows/Elementor e navegador interno do Instagram:
   campos do checkout sempre ficam clicáveis acima de qualquer área visual do bump. */
.woocommerce-checkout #customer_details,
.woocommerce-checkout .woocommerce-billing-fields,
.woocommerce-checkout .woocommerce-shipping-fields,
.woocommerce-checkout .woocommerce-additional-fields,
.woocommerce-checkout .form-row,
.woocommerce-checkout .woocommerce-input-wrapper,
.woocommerce-checkout input,
.woocommerce-checkout select,
.woocommerce-checkout textarea,
.wcf-embed-checkout-form #customer_details,
.wcf-embed-checkout-form .woocommerce-billing-fields,
.wcf-embed-checkout-form .woocommerce-input-wrapper,
.wcf-embed-checkout-form .form-row,
.wcf-embed-checkout-form input,
.wcf-embed-checkout-form select,
.wcf-embed-checkout-form textarea {
    position: relative;
    z-index: 20;
    pointer-events: auto !important;
}
/* Exceção: os checkboxes do próprio bump continuam invisíveis/não-clicáveis. */
.woocommerce-checkout input.em-ob-checkbox,
.wcf-embed-checkout-form input.em-ob-checkbox {
    pointer-events: none !important;
    position: absolute !important;
    opacity: 0 !important;
    z-index: 0;
}

/* ---------- Telas maiores ---------- */

@media (min-width: 640px) {
    .em-ob-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }
    .em-ob-heading {
        font-size: 19px;
    }
    .em-ob-info-title {
        font-size: 13.5px;
    }
    .em-ob-info-desc {
        font-size: 12px;
    }
}

@media (min-width: 992px) {
    .em-ob-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Telas muito estreitas (<330px): 1 coluna para não espremer o toque. */
@media (max-width: 329px) {
    .em-ob-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .em-ob-remove-bump {
        margin: 4px 0 0;
        font-size: 10px;
    }
}

/* ============================================================
   v3.1 — LAYOUT LISTA (1 por linha): imagem à esquerda,
   título/descrição/preço à direita, botão embaixo do preço.
   ========================================================== */

.em-ob-layout-list .em-ob-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}
.em-ob-layout-list .em-ob-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 10px;
}
.em-ob-layout-list .em-ob-thumb {
    grid-row: 1 / span 2;
    width: 92px;
    height: 92px;
    aspect-ratio: auto;
    align-self: start;
}
.em-ob-layout-list .em-ob-info {
    grid-column: 2;
    grid-row: 1;
    text-align: left;
    padding: 0;
}
.em-ob-layout-list .em-ob-info-title {
    font-size: 13.5px;
    -webkit-line-clamp: 2;
}
.em-ob-layout-list .em-ob-info-desc {
    font-size: 11.5px;
    -webkit-line-clamp: 1;
    margin-bottom: 4px;
}
.em-ob-layout-list .em-ob-price-line {
    justify-content: flex-start;
    margin-top: 0;
    font-size: 12px;
}
.em-ob-layout-list .em-ob-price,
.em-ob-layout-list .em-ob-price .woocommerce-Price-amount {
    font-size: 14px;
}
.em-ob-layout-list .em-ob-btn {
    grid-column: 2;
    grid-row: 2;
    margin-top: 8px;
    min-height: 40px;
    max-width: 240px;
}
@media (min-width: 640px) {
    .em-ob-layout-list .em-ob-grid {
        grid-template-columns: 1fr; /* lista continua 1 por linha no desktop */
    }
    .em-ob-layout-list .em-ob-card {
        grid-template-columns: 104px minmax(0, 1fr) 190px;
        grid-template-rows: auto;
    }
    .em-ob-layout-list .em-ob-thumb {
        grid-row: 1;
        width: 104px;
        height: 104px;
    }
    .em-ob-layout-list .em-ob-btn {
        grid-column: 3;
        grid-row: 1;
        margin-top: 0;
        align-self: center;
    }
}

/* Marco especial "LEVE TUDO" (50%) — dourado */
.em-ob-milestone.is-all {
    border-color: #d97706;
    background: #fef3c7;
}
/* Marco em 100% da barra: flag ancorada à direita (o .em-ob-ladder tem
   overflow:hidden — centralizada, "50% TUDO" sairia cortado). */
.em-ob-progress-bar .em-ob-milestone:last-child .em-ob-milestone-flag {
    left: auto;
    right: -4px;
    transform: none;
}
/* LEVE TUDO inatingível (menos cards que o mínimo): não promete. */
.em-ob-milestone.is-all.is-unreachable {
    display: none;
}
.em-ob-milestone.is-all.is-reached {
    border-color: #b45309;
    background: #f59e0b;
}
.em-ob-milestone.is-all .em-ob-milestone-flag {
    color: #b45309;
    font-weight: 800;
}

/* ============================================================
   v3.1 — POPUP DE ÚLTIMA CHANCE
   ========================================================== */

.em-ob-lc-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(15, 23, 42, .62);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
.em-ob-lc-overlay[hidden] {
    display: none;
}
.em-ob-lc-modal {
    width: 100%;
    max-width: 360px;
    background: #ffffff;
    border-radius: 18px;
    padding: 18px 16px 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
    text-align: center;
    animation: em-ob-pop .3s ease;
}
.em-ob-lc-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #b45309;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 10px;
}
.em-ob-lc-title {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
}
.em-ob-lc-title .em-ob-lc-pct {
    color: #15803d;
}
.em-ob-lc-product {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 14px;
}
.em-ob-lc-product img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.em-ob-lc-pname {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.em-ob-lc-pprice {
    font-size: 12.5px;
    color: #4b5563;
    margin-top: 2px;
}
.em-ob-lc-pprice strong,
.em-ob-lc-pprice .woocommerce-Price-amount {
    color: #15803d;
}
.em-ob-lc-accept {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 12px;
    background: #16a34a;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    margin-bottom: 8px;
    animation: em-ob-lc-pulse 1.6s ease-in-out infinite;
}
.em-ob-lc-accept.is-busy {
    opacity: .7;
    animation: none;
}
.em-ob-lc-decline {
    display: block;
    width: 100%;
    background: transparent;
    border: 0;
    color: #9ca3af;
    font-family: inherit;
    font-size: 12.5px;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
    min-height: 40px;
}
/* Pulso só com sombra: sem transform, o botão fica geometricamente estável
   (leitores de tela e automação não veem o elemento "em movimento"). */
@keyframes em-ob-lc-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .35); }
    50%      { box-shadow: 0 0 0 9px rgba(22, 163, 74, 0); }
}

/* Acessibilidade: respeita usuários com redução de movimento. */
@media (prefers-reduced-motion: reduce) {
    .em-ob-progress-fill,
    .em-ob-card,
    .em-ob-btn,
    .em-ob-added-badge {
        transition: none;
    }
    .em-ob-confetti-bit {
        animation: none;
        display: none;
    }
    .em-ob-ladder.em-ob-celebrating .em-ob-ladder-pct,
    .em-ob-ladder-saving,
    .em-ob-lc-accept,
    .em-ob-lc-modal {
        animation: none;
    }
}
