/**
 * =====================================================
 * HF IMPORTS - WIDGET DE CHAT CON IA
 * =====================================================
 * Estilos premium para el widget flotante
 */

/* Variables CSS */
:root {
    --hf-primary: #1a237e;
    --hf-primary-light: #3949ab;
    --hf-primary-dark: #0d1442;
    --hf-accent: #ff6d00;
    --hf-accent-light: #ff9100;
    --hf-success: #00c853;
    --hf-whatsapp: #25d366;
    --hf-white: #ffffff;
    --hf-gray-50: #fafafa;
    --hf-gray-100: #f5f5f5;
    --hf-gray-200: #eeeeee;
    --hf-gray-300: #e0e0e0;
    --hf-gray-600: #757575;
    --hf-gray-800: #424242;
    --hf-gray-900: #212121;
    --hf-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --hf-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
    --hf-radius: 16px;
    --hf-radius-sm: 8px;
    --hf-radius-full: 50px;
    --hf-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================ */
/* BOTÓN FLOTANTE DE CHAT */
/* ============================================ */
.hf-chat-toggle {
    position: fixed;
    bottom: 120px;
    right: 24px;
    width: auto;
    height: 52px;
    padding: 0 20px;
    background: linear-gradient(135deg, #111111 0%, #333333 100%);
    border: none;
    border-radius: var(--hf-radius-full);
    cursor: pointer;
    box-shadow: var(--hf-shadow-lg);
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--hf-white);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    font-weight: 600;
    transition: var(--hf-transition);
    animation: hf-pulse 3s infinite;
}

.hf-chat-toggle:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 25px 70px rgba(26, 35, 126, 0.35);
}

.hf-chat-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.hf-chat-toggle .hf-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: var(--hf-accent);
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: hf-bounce 1s infinite;
}

@keyframes hf-pulse {

    0%,
    100% {
        box-shadow: 0 20px 60px rgba(26, 35, 126, 0.3);
    }

    50% {
        box-shadow: 0 20px 60px rgba(26, 35, 126, 0.5), 0 0 0 8px rgba(26, 35, 126, 0.1);
    }
}

@keyframes hf-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ============================================ */
/* VENTANA DE CHAT */
/* ============================================ */
.hf-chat-window {
    position: fixed;
    bottom: 185px;
    right: 24px;
    width: 370px;
    max-width: calc(100vw - 48px);
    height: 480px;
    max-height: calc(100vh - 220px);
    background: var(--hf-white);
    border-radius: 16px;
    box-shadow: var(--hf-shadow-lg);
    z-index: 9991;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: hf-slideUp 0.3s ease-out;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.hf-chat-window.active {
    display: flex;
}

@keyframes hf-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================ */
/* HEADER DEL CHAT */
/* ============================================ */
.hf-chat-header {
    background: linear-gradient(135deg, var(--hf-primary) 0%, var(--hf-primary-light) 100%);
    color: var(--hf-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.hf-chat-header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), transparent);
}

.hf-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--hf-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hf-chat-avatar img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.hf-chat-info {
    flex: 1;
}

.hf-chat-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.hf-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hf-chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--hf-success);
    border-radius: 50%;
    animation: hf-blink 1.5s infinite;
}

@keyframes hf-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.hf-chat-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: var(--hf-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--hf-transition);
}

.hf-chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ============================================ */
/* ÁREA DE MENSAJES */
/* ============================================ */
.hf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--hf-gray-50);
}

.hf-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.hf-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.hf-chat-messages::-webkit-scrollbar-thumb {
    background: var(--hf-gray-300);
    border-radius: 3px;
}

/* Mensaje genérico */
.hf-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    animation: hf-fadeIn 0.3s ease-out;
}

@keyframes hf-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mensaje del usuario */
.hf-message.user {
    background: linear-gradient(135deg, var(--hf-primary) 0%, var(--hf-primary-light) 100%);
    color: var(--hf-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Mensaje de la IA */
.hf-message.ai {
    background: var(--hf-white);
    color: var(--hf-gray-900);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Indicador de escribiendo */
.hf-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
    background: var(--hf-white);
    border-radius: 16px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.hf-typing span {
    width: 8px;
    height: 8px;
    background: var(--hf-gray-400);
    border-radius: 50%;
    animation: hf-typing 1.4s infinite;
}

.hf-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.hf-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes hf-typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        background: var(--hf-gray-300);
    }

    30% {
        transform: translateY(-8px);
        background: var(--hf-primary);
    }
}

/* ============================================ */
/* MENSAJE DE ADVERTENCIA */
/* ============================================ */
.hf-disclaimer {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-left: 4px solid var(--hf-accent);
    padding: 10px 14px;
    font-size: 11px;
    color: var(--hf-gray-800);
    margin: 0 16px 12px;
    border-radius: var(--hf-radius-sm);
}

.hf-disclaimer strong {
    color: var(--hf-accent);
}

/* ============================================ */
/* ANUNCIO EN EL CHAT */
/* ============================================ */
.hf-ad-banner {
    background: linear-gradient(135deg, var(--hf-primary-dark) 0%, var(--hf-primary) 100%);
    color: var(--hf-white);
    padding: 12px 16px;
    margin: 8px 16px;
    border-radius: var(--hf-radius-sm);
    font-size: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--hf-transition);
}

.hf-ad-banner:hover {
    transform: scale(1.02);
}

.hf-ad-banner strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

/* ============================================ */
/* ÁREA DE INPUT */
/* ============================================ */
.hf-chat-input-area {
    padding: 16px;
    background: var(--hf-white);
    border-top: 1px solid var(--hf-gray-200);
}

.hf-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.hf-chat-input {
    flex: 1;
    border: 2px solid var(--hf-gray-200);
    border-radius: var(--hf-radius);
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    transition: var(--hf-transition);
    outline: none;
}

.hf-chat-input:focus {
    border-color: var(--hf-primary);
    box-shadow: 0 0 0 4px rgba(26, 35, 126, 0.1);
}

.hf-chat-input::placeholder {
    color: var(--hf-gray-600);
}

.hf-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--hf-primary) 0%, var(--hf-primary-light) 100%);
    border: none;
    border-radius: 50%;
    color: var(--hf-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--hf-transition);
    flex-shrink: 0;
}

.hf-chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(26, 35, 126, 0.4);
}

.hf-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hf-chat-send svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ============================================ */
/* FORMULARIO DE CONTACTO */
/* ============================================ */
.hf-contact-form {
    padding: 16px;
    background: var(--hf-white);
    display: none;
    flex-direction: column;
    overflow-y: auto;
    max-height: 350px;
    border-top: 2px solid var(--hf-primary);
}

.hf-contact-form.active {
    display: flex;
}

.hf-contact-form h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--hf-gray-900);
    margin: 0 0 16px;
    text-align: center;
}

.hf-form-group {
    margin-bottom: 12px;
}

.hf-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--hf-gray-600);
    margin-bottom: 6px;
}

.hf-form-group input,
.hf-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--hf-gray-200);
    border-radius: var(--hf-radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--hf-transition);
    outline: none;
    box-sizing: border-box;
}

.hf-form-group input:focus,
.hf-form-group textarea:focus {
    border-color: var(--hf-primary);
}

.hf-form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.hf-form-submit {
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg, var(--hf-primary) 0%, var(--hf-primary-light) 100%);
    color: var(--hf-white);
    border: none;
    border-radius: var(--hf-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--hf-transition);
}

.hf-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 35, 126, 0.3);
}

.hf-form-cancel {
    padding: 14px 20px;
    background: var(--hf-gray-200);
    color: var(--hf-gray-800);
    border: none;
    border-radius: var(--hf-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--hf-transition);
}

.hf-form-cancel:hover {
    background: var(--hf-gray-300);
}

/* ============================================ */
/* BOTÓN DE WHATSAPP FLOTANTE */
/* ============================================ */
.hf-whatsapp-btn {
    position: fixed;
    bottom: 55px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: #25d366;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    z-index: 9989;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--hf-transition);
}

.hf-whatsapp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 35px rgba(37, 211, 102, 0.5);
}

.hf-whatsapp-btn svg {
    width: 32px;
    height: 32px;
    fill: var(--hf-white);
}

/* Animación de atención cada 10 segundos */
.hf-whatsapp-btn.shake {
    animation: hf-shake 0.8s ease-in-out;
}

@keyframes hf-shake {

    0%,
    100% {
        transform: rotate(0deg);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: rotate(-5deg);
    }

    20%,
    40%,
    60%,
    80% {
        transform: rotate(5deg);
    }
}

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */
@media (max-width: 480px) {
    .hf-chat-toggle {
        bottom: 150px;
        right: 12px;
        padding: 10px 16px;
        height: auto;
        font-size: 12px;
        flex-direction: row;
        gap: 8px;
        background: linear-gradient(135deg, #000000 0%, #333333 100%);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .hf-chat-toggle .hf-toggle-text {
        display: block !important;
        text-align: left;
        line-height: 1.3;
    }

    .hf-chat-toggle .hf-toggle-text span:first-child {
        font-size: 12px !important;
        font-weight: 600;
    }

    .hf-chat-toggle .hf-toggle-text span:last-child {
        font-size: 10px !important;
        opacity: 0.9;
        color: #00ff88;
    }

    .hf-chat-toggle svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .hf-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: none;
        /* Mantener oculto por defecto */
        flex-direction: column;
    }

    .hf-chat-window.active {
        display: flex;
        /* Solo mostrar cuando tiene clase active */
        z-index: 99999;
        /* Asegurar que esté por encima del nav móvil */
    }

    .hf-chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 15px;
    }

    .hf-chat-input-area {
        padding: 10px 12px 75px 12px;
        /* padding-bottom extra para el nav móvil */
        flex-shrink: 0;
    }

    .hf-chat-input-area>div:first-child {
        margin-bottom: 8px !important;
    }

    .hf-chat-input-area .hf-quick-action {
        padding: 10px 8px !important;
        font-size: 11px !important;
    }

    .hf-contact-form {
        max-height: none;
        flex: 1;
        overflow-y: auto;
        padding: 12px;
    }

    .hf-form-group {
        margin-bottom: 8px;
    }

    .hf-form-group input,
    .hf-form-group textarea {
        padding: 10px;
        font-size: 14px;
    }

    .hf-form-buttons {
        margin-top: 10px;
        position: sticky;
        bottom: 0;
        background: white;
        padding: 10px 0;
    }

    .hf-whatsapp-btn {
        bottom: 84px;
        right: 12px;
        width: 52px;
        height: 52px;
    }

    .hf-whatsapp-btn svg {
        width: 28px;
        height: 28px;
    }
}