/* ===========================================================
   NUEVA ADICIÓN: VARIABLES CSS (Fácil Personalización)
   =========================================================== */
   :root {
    --pcya-primary-color: #333333; /* Color Oscuro principal */
    --pcya-accent-color: #EA1917; /* Color Rojo de acento */
    --pcya-text-color: #333;
    --pcya-background-messages: #F4F4F4; /* Fondo de la ventana de mensajes */
    --pcya-bubble-bot-bg: #fff;
    --pcya-box-shadow-medium: 0 6px 22px rgba(0,0,0,0.35);
    --pcya-box-shadow-large: 0 12px 32px rgba(0,0,0,0.25);
}

/* ===========================================================
    BOTÓN FLOTANTE (Intercom Style adaptado a LG)
    =========================================================== */

#pcya-chat-launcher {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 999999999 !important;
}

.pcya-icon {
    width: 58px;
    height: 58px;
    background: var(--pcya-primary-color); /* Usando variable */
    border-radius: 50%;
    box-shadow: var(--pcya-box-shadow-medium); /* Usando variable */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s ease;
    overflow: hidden;
}

.pcya-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    transition: .25s ease;
    /* Puedes necesitar una regla aquí para hacer el SVG blanco si es necesario */
    /* filter: brightness(0) invert(1); */
}

/* CUANDO SE ABRE EL CHAT, CAMBIA A X */
.pcya-icon.open img {
    width: 15px;
    height: 15px;
    /* Si usas un SVG de "X", usa filter: brightness(0) invert(1) si es necesario */
}

.pcya-icon:hover {
    background: var(--pcya-accent-color); /* Usando variable */
    transform: scale(1.10);
    box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}

/* Cambiar icono al abrir */
#chatbot-toggle.open-icon {
    transform: rotate(45deg);
    background: var(--pcya-primary-color); /* Usando variable */
}


/* ===========================================================
    VENTANA DEL CHAT — ESTILO INTERCOM PRO
    =========================================================== */

#pcya-chat-window {
    position: fixed;
    bottom: 105px;
    right: 25px;
    width: 360px;
    height: 500px;
    background: #FFFFFF;
    border-radius: 20px;
    display: none;
    flex-direction: column;
    box-shadow: var(--pcya-box-shadow-large); /* Usando variable */
    overflow: hidden;
    animation: fadeInUp .25s ease-out;
    z-index: 999999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@keyframes fadeInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------------- HEADER ---------------- */

.pcya-header {
    background: var(--pcya-primary-color); /* Usando variable */
    color: white;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pcya-header button {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: .2s ease;
}

.pcya-header button:hover {
    color: var(--pcya-accent-color); /* Usando variable */
}


/* ---------------- MENSAJES (CONTENEDOR) ---------------- */

.pcya-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: var(--pcya-background-messages); /* Usando variable */
    /* CORRECCIÓN CLAVE PARA ALINEACIÓN DE BURBUJAS */
    display: flex;
    flex-direction: column;
}

/* NUEVA ADICIÓN: ESTILO DE SCROLLBAR */
.pcya-messages::-webkit-scrollbar {
    width: 6px;
}

.pcya-messages::-webkit-scrollbar-thumb {
    background-color: #b0b0b0;
    border-radius: 10px;
}

.pcya-messages::-webkit-scrollbar-track {
    background-color: var(--pcya-background-messages);
}


/* ---------------- BURBUJAS DE CHAT ---------------- */

.pcya-message {
    max-width: 80%;
    padding: 12px 16px;
    margin-bottom: 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.45;
    word-wrap: break-word;
}

.pcya-message.user {
    background: var(--pcya-accent-color); /* Usando variable */
    color: #fff;
    margin-left: auto; /* Alineación a la derecha */
    border-bottom-right-radius: 4px;
}

.pcya-message.bot {
    background: var(--pcya-bubble-bot-bg); /* Usando variable */
    color: var(--pcya-text-color); /* Usando variable */
    border: 1px solid #ddd;
    margin-right: auto; /* Alineación a la izquierda */
    border-bottom-left-radius: 4px;
}

/* NUEVA REGLA V7.0.0: Para mensajes que contienen la tarjeta de producto (ancho completo) */
.pcya-message.bot.full-width-card {
    max-width: 100% !important; /* Ancho completo */
    padding: 0 !important; /* Eliminar padding */
    border: none !important; /* Eliminar borde */
    background: transparent !important; /* Fondo transparente */
    margin-right: 0 !important; 
}

/* ---------------- INPUT ---------------- */

.pcya-input {
    display: flex;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #ddd;
    align-items: flex-end;
}

#pcya-input {
    flex: 1;
    height: 50px;
    min-height: 50px;
    /* CORRECCIÓN DE GROSOR Y COLOR */
    border: 1px solid var(--pcya-accent-color); /* Usando variable */
    /* ------------------------------ */
    border-radius: 14px;
    padding: 10px 12px;
    resize: none;
    font-size: 15px;
    margin-right: 10px;
    max-height: 80px;
    overflow-y: auto;
}

#pcya-input:focus {
    border-color: var(--pcya-accent-color); /* Usando variable */
    outline: none; 
    box-shadow: 0 0 5px rgba(234, 25, 23, 0.5); 
}

#pcya-send {
    background: var(--pcya-primary-color); /* Usando variable */
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0; 
    cursor: pointer;
    transition: .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    /* ÍCONO DE ENVÍO (Flecha de Material Design, color blanco) */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="white" d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px;
}

#pcya-send:hover {
    /* CORRECCIÓN CLAVE: Usamos background-color para preservar el ícono (background-image) */
    background-color: var(--pcya-accent-color); /* Usando variable */
    /* ------------------------------------------------------------------------------------ */
}


/* ===========================================================
    TARJETAS DE PRODUCTO (FICHA)
    =========================================================== */

.pcya-product-card {
    background: var(--pcya-bubble-bot-bg); /* Usando variable */
    border-radius: 14px;
    padding: 16px;
    border: 1px solid #ddd;
    margin-bottom: 0;
    /* Asegura que la tarjeta se alinee con los mensajes del bot */
    align-self: flex-start;
    max-width: 100%; /* La tarjeta ocupa el 100% de la burbuja (que ahora es 100% del chat) */
}

.pcya-product-card img {
    max-width: 100%;
    max-height: 120px; /* Limita la altura de la imagen dentro del chat */
    display: block;
    margin: 0 auto 10px auto;
    object-fit: contain;
    border-radius: 8px;
}

.pcya-product-card strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
}

.pcya-product-card p {
    font-size: 13px;
    color: #666;
    margin: 0 0 8px 0;
}

.pcya-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--pcya-accent-color); /* Usando variable */
    margin-top: 6px;
    display: inline-block;
    margin-right: 10px;
}

.pcya-old-price {
    font-size: 14px;
    color: #999;
}

.pcya-buy-btn {
    background: var(--pcya-accent-color); /* Usando variable */
    color: #fff;
    padding: 10px 14px;
    text-align: center;
    display: block;
    margin-top: 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    transition: 0.25s ease; /* Transición añadida para hover */
}

.pcya-buy-btn:hover {
    opacity: 0.9;
}

/* ---------------- OTROS ESTILOS IA / CHIP / TYPING ---------------- */

.pcya-contact-btn {
    background-color: var(--pcya-primary-color) !important; /* Usando variable */
    color: #ffffff !important;
    border: none !important;
    padding: 10px 18px !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    transition: 0.25s ease !important;
    margin-top: 10px;
    display: inline-block;
}

.pcya-contact-btn:hover {
    background-color: var(--pcya-accent-color) !important; /* Usando variable */
}

.pcya-chip {
    display: inline-block;
    padding: 8px 14px;
    margin: 6px 6px 0 0;
    background: var(--pcya-bubble-bot-bg); /* Usando variable */
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: .2s;
}

.pcya-chip:hover {
    background: var(--pcya-accent-color); /* Usando variable */
    color: #fff;
    border-color: var(--pcya-accent-color); /* Usando variable */
}

.typing {
    background: #e6e6e6;
    padding: 10px 14px;
    border-radius: 14px;
    width: fit-content;
    display: flex;
    gap: 4px;
    margin: 6px 0;
    align-self: flex-start;
}

.typing span {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}


/* ===========================================================
    RESPONSIVE CHAT - AJUSTES
    =========================================================== */

@media (max-width: 480px) {

    #pcya-chat-window {
        width: 95%;
        height: 80%;
        bottom: 60px;
        right: 2.5%;
        border-radius: 16px;
    }

    #pcya-chat-launcher {
        bottom: 10px !important;
        right: 10px !important;
    }

    .pcya-icon {
        width: 46px;
        height: 46px;
    }

    .pcya-icon img {
        width: 24px;
        height: 24px;
    }
}