/**
 * TUH Order Bump - Estilos
 * Feature isolada para ofertas especiais no checkout
 *
 * NOTA: Este CSS usa alta especificidade para garantir isolamento de temas.
 * Evitamos !important sempre que possível.
 */

.tuh-order-bump {
    /* Variáveis CSS com fallbacks - Não dependem de variáveis globais */
    --tuh-bump-bg: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    --tuh-bump-border: var(--tuh-primary, #8C52FF);
    --tuh-bump-badge-bg: var(--tuh-primary, #8C52FF);
    --tuh-bump-badge-text: #ffffff;
    --tuh-bump-text: #1f2937;
    --tuh-bump-price: var(--tuh-primary, #8C52FF);
    --tuh-bump-discount-bg: #ef4444;
    --tuh-bump-discount-text: #ffffff;
    --tuh-bump-success: #10b981;
    --tuh-bump-radius-lg: 12px;
    --tuh-bump-radius-md: 8px;
    --tuh-bump-radius-sm: 6px;

    /* Layout padrão - block para header em cima, content embaixo */
    /* Layouts específicos (inline, etc) podem sobrescrever */
    display: block;

    background: var(--tuh-bump-bg);
    border: 2px dashed var(--tuh-bump-border);
    border-radius: var(--tuh-bump-radius-lg);
    padding: 20px;
    margin: 20px 0;
    position: relative;
    transition: all 0.3s ease;
    /* NÃO usar overflow: hidden aqui - corta o badge ::before */
    box-sizing: border-box;
}

/* Espaçamento entre múltiplos bumps */
.tuh-order-bump + .tuh-order-bump {
    margin-top: 15px;
}

/* Último bump tem margem extra */
.tuh-order-bump:last-of-type {
    margin-bottom: 30px;
}

.tuh-order-bump::before {
    content: "OFERTA ESPECIAL";
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--tuh-bump-badge-bg);
    color: var(--tuh-bump-badge-text);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.tuh-bump-header {
    display: block;
    width: 100%;
    margin-bottom: 15px;
    position: relative;
}

/* ===========================================
   CHECKBOX STYLES - Alta especificidade para isolamento
   =========================================== */

/* Reset base para o label do checkbox */
.tuh-order-bump .tuh-bump-header .tuh-bump-checkbox,
.tuh-order-bump .tuh-bump-header label.tuh-bump-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background: transparent;
    border: none;
}

/* Elementos internos do checkbox */
.tuh-order-bump .tuh-bump-checkbox > * {
    display: inline-flex;
    flex-shrink: 0;
}

/* Título dentro do checkbox */
.tuh-order-bump .tuh-bump-checkbox .tuh-bump-title {
    display: inline-block;
    flex-shrink: 1;
    flex-grow: 1;
    width: auto;
    max-width: none;
    line-height: 1.4;
    margin: 0;
    padding: 0;
    float: none;
    clear: none;
    color: var(--tuh-bump-text);
}

/* Ocultar o input real do checkbox */
.tuh-order-bump .tuh-bump-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

/* Checkmark visual customizado */
.tuh-order-bump .tuh-bump-checkbox .tuh-checkmark {
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    border: 2px solid var(--tuh-bump-border);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: #fff;
    flex-shrink: 0;
    float: none;
    clear: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Estado checked via seletor de sibling */
.tuh-order-bump .tuh-bump-checkbox input:checked + .tuh-checkmark {
    background: var(--tuh-bump-badge-bg);
    border-color: var(--tuh-bump-badge-bg);
}

.tuh-order-bump .tuh-bump-checkbox input:checked + .tuh-checkmark::after {
    content: "\2713";
    color: var(--tuh-bump-badge-text);
    font-size: 16px;
    font-weight: bold;
}

/* Estado checked via classe .added no container (backup) */
.tuh-order-bump.added .tuh-bump-checkbox .tuh-checkmark {
    background: var(--tuh-bump-badge-bg);
    border-color: var(--tuh-bump-badge-bg);
}

.tuh-order-bump.added .tuh-bump-checkbox .tuh-checkmark::after {
    content: "\2713";
    color: var(--tuh-bump-badge-text);
    font-size: 16px;
    font-weight: bold;
}

/* Título standalone */
.tuh-order-bump .tuh-bump-title {
    color: var(--tuh-bump-text);
    display: inline;
    vertical-align: middle;
}

.tuh-bump-content {
    display: flex;
    flex-direction: row;
    gap: 15px;
    align-items: flex-start;
    width: 100%;
}

.tuh-order-bump .tuh-bump-image {
    flex-shrink: 0;
}

.tuh-order-bump .tuh-bump-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--tuh-bump-radius-md);
}

.tuh-order-bump .tuh-bump-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.tuh-order-bump .tuh-bump-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: var(--tuh-bump-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.tuh-bump-info p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--tuh-bump-text);
    opacity: 0.8;
}

.tuh-bump-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tuh-original-price {
    text-decoration: line-through;
    color: var(--tuh-bump-text);
    opacity: 0.5;
    font-size: 14px;
}

.tuh-bump-final-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--tuh-bump-price);
}

.tuh-bump-discount {
    background: var(--tuh-bump-discount-bg);
    color: var(--tuh-bump-discount-text);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* Seletor de variações */
.tuh-bump-variations {
    margin: 10px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.tuh-bump-variation-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tuh-bump-variation-row:last-child {
    margin-bottom: 0;
}

.tuh-bump-variation-row label {
    font-size: 12px;
    font-weight: 600;
    color: var(--tuh-bump-text);
    min-width: 60px;
}

.tuh-bump-variation-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.tuh-bump-variation-select:focus {
    outline: none;
    border-color: var(--tuh-bump-border);
    box-shadow: 0 0 0 2px rgba(140, 82, 255, 0.2);
}

.tuh-order-bump.has-variations .tuh-bump-checkbox-input:not(:checked) ~ .tuh-checkmark {
    opacity: 0.6;
}

/* Seletor de quantidade */
.tuh-bump-quantity-selector {
    margin: 12px 0;
}

.tuh-qty-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tuh-qty-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
}

.tuh-qty-option:hover {
    border-color: var(--tuh-bump-border);
}

.tuh-qty-option.selected {
    border-color: var(--tuh-bump-border);
    background: rgba(140, 82, 255, 0.1);
}

.tuh-qty-option input {
    display: none;
}

.tuh-qty-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.tuh-qty-label strong {
    color: var(--tuh-bump-text);
}

.tuh-qty-discount-badge {
    background: var(--tuh-bump-success);
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.tuh-qty-price {
    font-size: 12px;
    color: var(--tuh-bump-border);
    font-weight: 600;
    margin-top: 2px;
}

/* Badge de economia */
.tuh-bump-savings {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid var(--tuh-bump-success);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tuh-bump-success);
}

.tuh-bump-savings svg {
    flex-shrink: 0;
}

.tuh-bump-savings .woocommerce-Price-amount {
    color: var(--tuh-bump-success);
    font-weight: 700;
}

/* Estado: Adicionado */
.tuh-order-bump.added {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: var(--tuh-bump-success);
}

.tuh-order-bump.added::before {
    background: var(--tuh-bump-success);
    content: "ADICIONADO!";
}

/* Estado: Loading */
.tuh-order-bump.loading {
    pointer-events: none;
}

.tuh-order-bump.loading .tuh-bump-content {
    opacity: 0.5;
}

.tuh-bump-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tuh-order-bump.loading .tuh-bump-spinner {
    display: block;
}

.tuh-bump-spinner span {
    display: block;
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--tuh-bump-border);
    border-radius: 50%;
    animation: tuh-spin 0.8s linear infinite;
}

@keyframes tuh-spin {
    to { transform: rotate(360deg); }
}

/* Mensagem de feedback */
.tuh-bump-message {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.tuh-bump-message.error {
    background: #fef2f2;
    color: var(--tuh-bump-discount-bg);
    border: 1px solid var(--tuh-bump-discount-bg);
}

.tuh-bump-message.success {
    background: var(--tuh-success-bg, #f0fdf4);
    color: var(--tuh-bump-success);
    border: 1px solid var(--tuh-bump-success);
}

/* ========================================
   CARROSSEL DE ORDER BUMPS
   ======================================== */

.tuh-order-bumps-wrapper {
    margin: 20px 0;
}

/* Incentivo de Combo */
.tuh-combo-incentive {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #22c55e;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 600;
    color: #15803d;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: tuh-pulse-green 2s infinite;
}

.tuh-combo-incentive .tuh-combo-icon {
    flex-shrink: 0;
    color: #22c55e;
}

@keyframes tuh-pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}


/* ========================================
   MÚLTIPLOS PRODUTOS (Category/Mix Mode)
   ======================================== */

.tuh-bump-multi-products {
    margin-top: 15px;
}

.tuh-bump-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.tuh-bump-product-item {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e5e7eb;
    border-radius: var(--tuh-bump-radius-md);
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
    position: relative;
}

.tuh-bump-product-item:hover {
    border-color: var(--tuh-bump-border);
    box-shadow: 0 4px 12px rgba(140, 82, 255, 0.15);
}

.tuh-bump-product-item.added {
    border-color: var(--tuh-bump-success);
    background: rgba(240, 253, 244, 0.9);
}

.tuh-bump-product-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.tuh-bump-product-image {
    margin-bottom: 10px;
}

.tuh-bump-product-image img {
    width: 100%;
    max-width: 120px;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--tuh-bump-radius-sm);
    margin: 0 auto;
    display: block;
}

.tuh-bump-product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--tuh-bump-text);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}

.tuh-bump-product-price {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.tuh-bump-product-price .tuh-original-price {
    font-size: 12px;
}

.tuh-bump-product-price .tuh-bump-final-price {
    font-size: 16px;
}

.tuh-bump-product-price .tuh-bump-discount {
    font-size: 10px;
    padding: 2px 6px;
}

/* Botão de adicionar individual */
.tuh-bump-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: var(--tuh-bump-border);
    color: #fff;
    border: none;
    border-radius: var(--tuh-bump-radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tuh-bump-add-btn:hover {
    background: #7040d9;
    transform: translateY(-1px);
}

.tuh-bump-add-btn:active {
    transform: translateY(0);
}

.tuh-bump-add-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Estado: produto já adicionado */
.tuh-bump-product-item.added .tuh-bump-add-btn {
    background: var(--tuh-bump-success);
    pointer-events: none;
}

.tuh-bump-product-item.added .tuh-bump-add-btn::after {
    content: "✓ Adicionado";
}

.tuh-bump-product-item.added .tuh-bump-add-btn span,
.tuh-bump-product-item.added .tuh-bump-add-btn svg {
    display: none;
}

/* Spinner no item individual */
.tuh-bump-product-item .tuh-bump-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.tuh-bump-product-item.loading .tuh-bump-spinner {
    display: block;
}

/* Badge de melhor oferta (opcional) */
.tuh-bump-product-item[data-best-deal]::before {
    content: "MELHOR OFERTA";
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tuh-bump-success);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* ========================================
   RESPONSIVO
   ======================================== */

@media (max-width: 768px) {
    .tuh-order-bump {
        padding: 16px;
        margin: 16px 0;
    }

    .tuh-order-bump::before {
        left: 16px;
        font-size: 10px;
        padding: 3px 10px;
    }

    .tuh-bump-header {
        margin-bottom: 12px;
    }

    .tuh-bump-checkbox {
        gap: 8px;
        font-size: 14px;
    }

    .tuh-checkmark {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .tuh-bump-title {
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .tuh-order-bump {
        padding: 14px;
        margin: 14px 0;
    }

    .tuh-bump-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .tuh-bump-image {
        display: flex;
        justify-content: center;
    }

    .tuh-bump-image img {
        width: 100px;
        height: 100px;
        object-fit: cover;
    }

    .tuh-bump-info {
        width: 100%;
    }

    .tuh-bump-info h4 {
        font-size: 15px;
        margin-bottom: 4px;
    }

    .tuh-bump-info p {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .tuh-bump-price {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .tuh-original-price {
        font-size: 13px;
    }

    .tuh-bump-final-price {
        font-size: 18px;
    }

    .tuh-bump-discount {
        font-size: 11px;
        padding: 2px 6px;
    }

    .tuh-bump-savings {
        justify-content: center;
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Seletor de quantidade mobile */
    .tuh-qty-options {
        justify-content: center;
    }

    .tuh-qty-option {
        min-width: 60px;
        padding: 6px 10px;
    }

    .tuh-qty-label {
        font-size: 12px;
    }

    .tuh-qty-price {
        font-size: 11px;
    }

    /* Carrossel mobile */
    .tuh-combo-incentive {
        font-size: 12px;
        padding: 10px 12px;
        flex-direction: column;
        text-align: center;
        gap: 6px;
    }

    .tuh-carousel-nav {
        gap: 8px;
        padding: 8px;
    }

    .tuh-carousel-prev,
    .tuh-carousel-next {
        width: 30px;
        height: 30px;
    }

    .tuh-carousel-prev svg,
    .tuh-carousel-next svg {
        width: 14px;
        height: 14px;
    }

    .tuh-carousel-counter {
        font-size: 13px;
        min-width: 45px;
    }

    .tuh-carousel-counter .current {
        font-size: 15px;
    }

    .tuh-carousel-nav .tuh-added-count {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* Variações mobile */
    .tuh-bump-variations {
        padding: 8px;
    }

    .tuh-bump-variation-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .tuh-bump-variation-row label {
        min-width: auto;
    }

    .tuh-bump-variation-select {
        width: 100%;
    }

    /* Grid de múltiplos produtos mobile */
    .tuh-bump-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tuh-bump-product-item {
        padding: 10px;
    }

    .tuh-bump-product-image img {
        max-width: 80px;
    }

    .tuh-bump-product-name {
        font-size: 12px;
        min-height: 32px;
    }

    .tuh-bump-product-price .tuh-bump-final-price {
        font-size: 14px;
    }

    .tuh-bump-add-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .tuh-bump-product-item[data-best-deal]::before {
        font-size: 8px;
        padding: 2px 6px;
    }
}
