/* ===== Contenedor general ===== */

.ia-chat-container {
    position: relative;
    z-index: 9990;
}

/* ===== Botón flotante ===== */

.ia-chat-trigger {
    position: fixed;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #0264B6;
    color: #ffffff;
    padding: 10px 16px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    border: 1px solid #0264B6;
    cursor: pointer;
    font-size: 14px;
    letter-spacing: 0.03em;
    isolation: isolate;
    overflow: visible;
}

.ia-chat-trigger-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.ia-chat-trigger:hover {
    background-color: #ffffff;
    color: #0264B6;
    border-color: #0264B6;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* Halo animado del botón */

.ia-chat-trigger::before,
.ia-chat-trigger::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 999px;
    background-color: rgba(2, 100, 182, 0.35);
    z-index: -1;
    opacity: 0;
    transform: scale(1);
    animation: ia-chat-pulse 1.8s infinite;
}

.ia-chat-trigger::after {
    animation-delay: 0.6s;
}

@keyframes ia-chat-pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }
    70% {
        opacity: 0;
        transform: scale(1.6);
    }
    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}

/* Posiciones del botón flotante (desktop) */

.ia-chat-position-bottom-right .ia-chat-trigger {
    right: 16px;
    bottom: 90px;
}

.ia-chat-position-bottom-center .ia-chat-trigger {
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
}

.ia-chat-position-bottom-left .ia-chat-trigger {
    left: 16px;
    bottom: 90px;
}

/* ===== Panel de chat (flotante) ===== */

.ia-chat-panel {
    position: fixed;
    width: 340px;
    max-height: 70vh;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Posiciones del panel flotante (desktop) */

.ia-chat-position-bottom-right .ia-chat-panel {
    right: 16px;
    bottom: 160px;
}

.ia-chat-position-bottom-center .ia-chat-panel {
    left: 50%;
    bottom: 160px;
    margin-left: -170px; /* mitad del ancho (340/2) */
}

.ia-chat-position-bottom-left .ia-chat-panel {
    left: 16px;
    bottom: 160px;
}

/* estado visible */

.ia-chat-panel-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Encabezado */

.ia-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: linear-gradient(135deg, #0264B6, #0B5FA8);
    color: #ffffff;
    border-radius: 10px 10px 0 0;
}

.ia-chat-header-main {
    display: flex;
    flex-direction: column;
}

.ia-chat-header-title {
    font-size: 14px;
    font-weight: 700;
}

.ia-chat-header-subtitle {
    font-size: 11px;
    opacity: 0.9;
}

.ia-chat-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
}

/* Cuerpo del chat */

.ia-chat-body {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    background-color: #f5f7fa;
}

.ia-chat-messages {
    flex: 1;
    min-height: 120px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 2px 4px 0;
}

/* Burbujas */

.ia-chat-message {
    margin-bottom: 8px;
    display: flex;
}

.ia-chat-message-inner {
    max-width: 85%;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
}

.ia-chat-message-user {
    justify-content: flex-end;
}

.ia-chat-message-user .ia-chat-message-inner {
    background-color: #0264B6;
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.ia-chat-message-assistant {
    justify-content: flex-start;
}

.ia-chat-message-assistant .ia-chat-message-inner {
    background-color: #ffffff;
    color: #1f2933;
    border-bottom-left-radius: 2px;
    border: 1px solid #d0d7de;
}

/* Estado / mensajes de sistema */

.ia-chat-status {
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
}

/* Área de entrada */

.ia-chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 8px 10px 10px;
    border-top: 1px solid #e5e7eb;
    background-color: #ffffff;
    border-radius: 0 0 10px 10px;
}

.ia-chat-input {
    flex: 1;
    resize: none;
    border-radius: 8px;
    border: 1px solid #d0d7de;
    padding: 8px 10px;
    font-size: 13px;
    min-height: 40px;
    max-height: 80px;
    margin-right: 8px;
    box-sizing: border-box;
}

.ia-chat-send-btn {
    background-color: #0264B6;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ia-chat-send-btn:hover {
    background-color: #0B5FA8;
}

/* ===== Modo página (shortcode [ia_chat_page]) ===== */

.ia-chat-page-container {
    max-width: 720px;
    margin: 20px auto;
    padding: 0 15px;
}

.ia-chat-page-container .ia-chat-panel {
    position: static;
    width: 100%;
    max-height: 70vh;
    margin-left: 0;
    bottom: auto;
    right: auto;
}

/* ===== Responsive (móvil) ===== */

@media (max-width: 767px) {

    .ia-chat-trigger {
        right: 12px;
        bottom: 80px;
        padding: 8px 14px;
        font-size: 13px;
    }

    /* En móvil el panel ocupa casi todo el ancho, independientemente de la posición seleccionada */
    .ia-chat-panel {
        right: 8px;
        left: 8px;
        bottom: 90px;
        width: auto;
        max-height: 70vh;
    }

    .ia-chat-page-container {
        padding: 0 10px;
    }

    .ia-chat-page-container .ia-chat-panel {
        max-height: 70vh;
    }
}
