/**
 * APN Commerce Conversion Engine — Frontend Styles v1.7.0
 * WhatsApp Commerce PRO & Smart Lead Capture Modal
 */

/* 1. Botón "Comprar por WhatsApp" en Ficha de Producto */
.apn-commerce-btn-wrapper,
.apn-commerce-out-of-stock-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    flex-wrap: wrap;
}

/* Selector de Cantidad [-] 1 [+] */
.apn-qty-control {
    display: inline-flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    height: 46px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.apn-qty-btn {
    background: transparent;
    border: none;
    width: 38px;
    height: 100%;
    font-size: 18px;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
    padding: 0;
}

.apn-qty-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.apn-qty-btn:active {
    background: #cbd5e1;
}

.apn-qty-input {
    width: 44px;
    height: 100%;
    border: none !important;
    background: transparent !important;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    -moz-appearance: textfield;
}

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

/* Botón de Compra por WhatsApp */
.apn-commerce-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #25D366;
    color: #ffffff !important;
    font-size: 15px;
    font-weight: 600;
    padding: 0 24px;
    height: 46px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    box-shadow: 0 3px 10px rgba(37, 211, 102, 0.35);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, opacity 0.2s ease;
    line-height: 1;
}

.apn-commerce-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
    color: #ffffff !important;
}

.apn-commerce-btn:active {
    transform: translateY(0);
}

.apn-commerce-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.apn-commerce-btn-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* 2. Modal Pre-WhatsApp (Captura Inteligente de Lead) */
.apn-lead-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.apn-lead-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    animation: apnModalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 28px 24px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

@keyframes apnModalPop {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.apn-lead-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: #f1f5f9;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #64748b;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.apn-lead-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.apn-lead-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.apn-lead-modal-badge {
    display: inline-block;
    background: #ecfdf5;
    color: #059669;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    border: 1px solid #a7f3d0;
}

.apn-lead-modal-title {
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.apn-lead-modal-subtitle {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

/* Resumen del Producto en Modal */
.apn-lead-modal-product-summary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apn-prod-badge {
    font-size: 11px;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
}

.apn-prod-name {
    font-size: 14px;
    color: #1e293b;
}

.apn-prod-price {
    font-size: 13px;
    color: #059669;
    font-weight: 700;
}

/* Formulario */
.apn-lead-modal-form .apn-form-group {
    margin-bottom: 14px;
}

.apn-lead-modal-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.apn-lead-modal-form label .req {
    color: #ef4444;
}

.apn-lead-modal-form label .opt {
    font-weight: 400;
    color: #94a3b8;
    font-size: 12px;
}

.apn-lead-modal-form input[type="text"],
.apn-lead-modal-form input[type="tel"],
.apn-lead-modal-form input[type="email"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.apn-lead-modal-form input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.apn-form-row {
    display: flex;
    gap: 12px;
}

.apn-form-row .apn-col {
    flex: 1;
}

/* Opciones de Intención */
.apn-intent-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.apn-intent-radio {
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #334155;
    margin: 0 !important;
    transition: background-color 0.2s, border-color 0.2s;
}

.apn-intent-radio:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.apn-intent-radio input[type="radio"] {
    margin: 0 !important;
}

.apn-intent-radio input[type="radio"]:checked + span {
    font-weight: 700;
    color: #059669;
}

/* Footer Submit */
.apn-lead-modal-footer {
    margin-top: 20px;
}

.apn-lead-submit-btn {
    width: 100%;
    height: 48px;
    background: #25D366;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.apn-lead-submit-btn:hover {
    background: #20ba59;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.5);
}

.apn-lead-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* 3. Burbuja Contextual en Botón Flotante */
.apn-context-bubble-wrapper {
    position: fixed;
    bottom: 95px;
    right: 24px;
    z-index: 999989;
    max-width: 320px;
    animation: apnBubbleFadeIn 0.35s ease;
}

@keyframes apnBubbleFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.apn-context-bubble-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    position: relative;
}

.apn-context-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.apn-context-bubble-close:hover {
    color: #334155;
}

.apn-context-bubble-body {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.apn-advisor-avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #25D366;
}

.apn-advisor-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ecfdf5;
    border: 2px solid #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.apn-advisor-name-tag {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.apn-advisor-name-tag .apn-role {
    font-weight: 400;
    color: #64748b;
    font-size: 11px;
}

.apn-context-msg {
    margin: 0;
    font-size: 12px;
    color: #334155;
    line-height: 1.35;
}

.apn-context-bubble-action {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.apn-context-chat-btn {
    display: block;
    text-align: center;
    background: #eff6ff;
    color: #2563eb !important;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background-color 0.2s;
}

.apn-context-chat-btn:hover {
    background: #dbeafe;
}

@media (max-width: 640px) {
    .apn-intent-options {
        grid-template-columns: 1fr;
    }
    .apn-form-row {
        flex-direction: column;
        gap: 0;
    }
    .apn-context-bubble-wrapper {
        right: 16px;
        left: 16px;
        max-width: none;
    }
}
