/**
 * Betiptop Calculadora de Rollos - Estilos
 *
 * Color corporativo #9CAF88, estilo editorial limpio.
 * Compatible con Avada, responsive.
 * Sin variables CSS para evitar conflictos con Avada.
 */

/* ============================================
   Fix Avada: overflow y sticky en movil
   ============================================ */
html.avada-html-layout-boxed body,
html.avada-html-layout-boxed {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* ============================================
   Ocultar pewc solo cuando la calculadora esta activa
   ============================================ */
.single-product .btip-rollos-activo ~ .pewc-product-extra-groups-wrap,
.single-product .btip-rollos-activo ~ * .pewc-product-extra-groups-wrap,
.single-product:has(.btip-rollos-activo) .pewc-product-extra-groups-wrap {
    display: none !important;
}

/* ============================================
   Wrapper principal
   ============================================ */
.btip-calculadora-wrapper {
    max-width: 100%;
    margin: 20px 0;
    font-family: inherit;
    color: #333333;
    position: relative !important;
    transform: none !important;
    will-change: auto !important;
}

/* ============================================
   Info del producto
   ============================================ */
.btip-product-info {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.btip-precio-desde {
    font-size: 18px;
    margin-bottom: 8px;
    color: #333333;
}

.btip-precio-desde strong {
    font-size: 22px;
    color: #9CAF88;
}

.btip-medida-rollo,
.btip-rapport {
    font-size: 14px;
    color: #777777;
    margin-bottom: 4px;
}

.btip-label {
    font-weight: 600;
    color: #333333;
    margin-right: 4px;
}

/* ============================================
   Selector de materiales
   ============================================ */
.btip-materiales-section {
    margin-bottom: 24px;
}

.btip-section-title {
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    color: #333333;
}

.btip-materiales-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.btip-material-card {
    display: flex;
    align-items: stretch;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ffffff;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.btip-material-card:hover {
    border-color: #9CAF88;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.btip-material-card.btip-active {
    border-color: #9CAF88;
    background: rgba(156, 175, 136, 0.1);
    box-shadow: 0 0 0 1px #9CAF88;
}

.btip-material-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    border-radius: 50%;
    margin-right: 12px;
}

@media (max-width: 768px) {
    .btip-material-icon {
        display: flex;
    }
}

.btip-material-card.btip-active .btip-material-icon {
    background: #9CAF88;
    color: #fff;
}

/* Iconos Phosphor en tarjetas de material */
.btip-material-icon i {
    font-size: 20px;
    line-height: 1;
    color: #9CAF88;
}

.btip-material-card.btip-active .btip-material-icon i {
    color: #ffffff;
}

.btip-material-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.btip-material-nombre {
    font-weight: 600;
    font-size: 14px;
    color: #333333;
}

.btip-material-desc {
    font-size: 12px;
    color: #777777;
    line-height: 1.3;
    flex: 1;
}

.btip-material-precio {
    font-size: 13px;
    font-weight: 600;
    color: #9CAF88;
    margin-top: 8px;
}

/* Precio autoadhesivo */
/* Personalización del estampado */
.btip-personalizar-section {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}

.btip-personalizar-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #333333;
    user-select: none;
}

.btip-personalizar-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #9CAF88;
    cursor: pointer;
    margin: 0;
}

.btip-personalizar-fields {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.btip-personalizar-fields label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 6px;
}

.btip-personalizar-fields textarea {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    background: #ffffff;
}

.btip-personalizar-fields textarea:focus {
    outline: none;
    border-color: #9CAF88;
}

.btip-personalizar-help {
    font-size: 12px;
    color: #777777;
    line-height: 1.4;
    margin: 8px 0 0;
}

.btip-autoadhesivo-precio {
    font-size: 22px;
    font-weight: 700;
    color: #9CAF88;
    padding: 16px 0 4px;
}

.btip-autoadhesivo-desc {
    font-size: 13px;
    color: #777777;
    line-height: 1.4;
    margin: 0 0 24px;
}

/* ============================================
   Boton calculadora (outline corporativo)
   ============================================ */
.btip-calculadora-trigger {
    margin-bottom: 24px;
}

.btip-calc-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: #9CAF88;
    text-decoration: none;
    padding: 12px 20px;
    border: 2px solid #9CAF88;
    border-radius: 8px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    background: #ffffff;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 48px;
}

.btip-calc-link:hover {
    background: #9CAF88;
    color: #fff;
}

.btip-calc-link:hover strong {
    color: #fff;
}

.btip-calc-link strong {
    color: #9CAF88;
}

.btip-calc-arrow {
    font-size: 16px;
}

/* ============================================
   Selector de cantidad
   ============================================ */
.btip-cantidad-section {
    margin-bottom: 24px;
}

.btip-cantidad-control {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    max-width: 180px;
}

.btip-qty-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e0e0e0;
    background: #ffffff;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #333333;
    line-height: 1;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Los hijos de los botones no deben capturar eventos */
.btip-qty-btn span,
.btip-material-card * {
    pointer-events: none;
}

/* Botón añadir al carrito */
.btip-add-to-cart-section {
    margin-bottom: 24px;
}

.btip-add-to-cart-btn {
    width: 100%;
    height: 52px;
    background: #2c2c2c;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btip-add-to-cart-btn:hover {
    background: #1a1a1a;
}

.btip-cart-message {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.btip-cart-message.btip-success {
    background: rgba(156, 175, 136, 0.15);
    color: #6b8a5e;
}

.btip-cart-message.btip-error {
    background: rgba(214, 54, 56, 0.1);
    color: #d63638;
}


.btip-qty-minus {
    border-radius: 8px 0 0 8px;
    border-right: none;
}

.btip-qty-plus {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

.btip-qty-btn:hover {
    background: #f8f8f8;
    border-color: #9CAF88;
}

.btip-qty-input {
    width: 60px;
    height: 44px;
    text-align: center;
    border: 2px solid #e0e0e0;
    border-left: none;
    border-right: none;
    font-size: 16px;
    font-weight: 600;
    -moz-appearance: textfield;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.btip-qty-input::-webkit-outer-spin-button,
.btip-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============================================
   Precio total
   ============================================ */
.btip-precio-total {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.btip-precio-total-label {
    color: #777777;
}

.btip-precio-total-valor {
    font-size: 24px;
    font-weight: 700;
    color: #9CAF88;
}

/* ============================================
   Trust badges
   ============================================ */
.btip-trust-badges {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.btip-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}

.btip-badge .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #9CAF88;
}

.btip-badge-text {
    font-size: 11px;
    color: #777777;
    line-height: 1.3;
}

.btip-badge-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    gap: 6px;
}

.btip-badge-link:hover .btip-badge-text {
    color: #9CAF88;
}

/* ============================================
   Popup calculadora
   ============================================ */
.btip-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    box-sizing: border-box;
}

.btip-popup {
    background: #ffffff;
    border-radius: 12px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    margin: auto;
}

.btip-popup-overlay.btip-visible .btip-popup {
    transform: translateY(0);
}

.btip-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.btip-popup-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333333;
}

.btip-popup-close {
    width: 44px;
    height: 44px;
    border: none;
    background: #f8f8f8;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #777777;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.btip-popup-close:hover {
    background: #e0e0e0;
    color: #333333;
}

.btip-popup-body {
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    overscroll-behavior: contain;
}

.btip-popup-desc {
    font-size: 14px;
    color: #777777;
    margin: 0 0 20px;
    line-height: 1.5;
}

.btip-popup-material-info {
    padding: 10px 14px;
    background: rgba(156, 175, 136, 0.1);
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}

.btip-popup-material-label {
    color: #777777;
    margin-right: 4px;
}

.btip-popup-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.btip-popup-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333333;
}

.btip-popup-input {
    width: 100%;
    height: 44px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 0 14px;
    font-size: 16px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    -webkit-appearance: none;
}

.btip-popup-input::placeholder {
    color: #bbbbbb;
}

.btip-popup-input:focus {
    outline: none;
    border-color: #9CAF88;
}

.btip-popup-btn {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btip-popup-calcular {
    background: #2c2c2c;
    color: #fff;
}

.btip-popup-calcular:hover {
    background: #1a1a1a;
}

.btip-popup-resultado {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e0e0e0;
}

.btip-resultado-numero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.btip-resultado-numero #btip-resultado-rollos {
    font-size: 48px;
    font-weight: 700;
    color: #9CAF88;
    line-height: 1;
}

.btip-resultado-label {
    font-size: 14px;
    color: #777777;
    margin-top: 4px;
}

.btip-popup-usar {
    background: #9CAF88;
    color: #fff;
}

.btip-popup-usar:hover {
    background: #8a9e76;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .btip-materiales-grid {
        grid-template-columns: 1fr;
    }

    .btip-trust-badges {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .btip-material-card {
        padding: 12px;
    }

    .btip-precio-total-valor {
        font-size: 20px;
    }

    .btip-popup-overlay {
        padding: 10px;
        align-items: flex-start;
    }

    .btip-popup {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        margin: auto;
    }

    .btip-popup-body {
        padding: 16px;
    }

    .btip-calc-link {
        font-size: 14px;
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .btip-trust-badges {
        grid-template-columns: 1fr 1fr;
    }

    .btip-popup {
        width: 100%;
        border-radius: 8px;
    }
}
