/* Estilos del Asistente de Compra IA - Elena's Haus */
#clictienda-ai-chat-widget {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 999999;
    overflow: hidden;
    font-family: inherit;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

#clictienda-ai-chat-widget.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Toggle Button */
#clictienda-ai-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bg-primary, #0f172a) 0%, var(--bg-secondary, #1e293b) 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#clictienda-ai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px 0 rgba(15, 23, 42, 0.55);
}

#clictienda-ai-chat-toggle svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Header */
.ct-ai-chat-header {
    background: linear-gradient(135deg, var(--bg-secondary, #1e293b) 0%, var(--bg-primary, #0f172a) 100%);
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.ct-ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ct-ai-chat-header-avatar {
    width: 32px;
    height: 32px;
    background: var(--color-accent, #f97316); /* Cambiado a naranja accent */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

.ct-ai-chat-header-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.ct-ai-chat-header-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
}

.ct-ai-chat-close {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: inherit;
    padding: 4px;
    display: flex;
    align-items: center;
}

.ct-ai-chat-close:hover {
    opacity: 1;
}

.ct-ai-chat-close svg {
    width: 20px;
    height: 20px;
}

/* Message Area */
.ct-ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.ct-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.ct-ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ct-ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}

/* Message bubble */
.ct-ai-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
    clear: both !important; /* Evitar solapamiento con flotados */
    flex-shrink: 0 !important; /* Impedir que el navegador lo encoja */
}

/* Reset y prevención de estilos heredados del tema (Storefront/WooCommerce) */
.ct-ai-chat-messages li,
.ct-ai-chat-messages ul,
.ct-ai-chat-messages ol {
    border: none !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
    box-shadow: none !important;
}

.ct-ai-chat-messages hr {
    display: none !important;
}

.ct-ai-message.bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.ct-ai-message.user {
    align-self: flex-end;
    background: var(--bg-primary, #0f172a); /* Fondo del usuario con el color tech de la tienda */
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.ct-ai-message.system {
    align-self: center;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #b45309;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 8px;
    max-width: 90%;
    clear: both !important;
}

.ct-ai-message-product {
    margin-top: 10px;
    background: #ffffff !important;
    border: 1px solid var(--border-color, #e2e8f0) !important;
    border-radius: 12px !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important; 
    cursor: pointer !important;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: var(--shadow-sm) !important;
    max-width: 100% !important;
    width: 100% !important; /* Garantizar ancho total */
    align-self: stretch !important;
    min-height: 90px !important;
    height: auto !important; 
    clear: both !important; /* Evitar que respuestas del usuario se monten sobre la tarjeta */
    flex-shrink: 0 !important;
}

.ct-ai-message-product:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent, #f97316); /* Borde naranja tecnológico en hover */
    box-shadow: 0 8px 20px rgba(249, 115, 22, 0.12);
}

.ct-ai-message-product-info {
    padding: 14px 16px !important;
    display: block !important; 
    background: #ffffff !important;
    overflow: visible !important;
}

.ct-ai-message-product-title {
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    color: var(--text-dark, #0f172a) !important;
    line-height: 1.4 !important;
    margin-bottom: 6px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important; /* Limitar descripciones extremadamente largas a 3 líneas */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important; /* Recorta texto sobrante con puntos suspensivos */
    text-overflow: ellipsis !important;
}

.ct-ai-message-product-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.ct-ai-message-product-sku {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.ct-ai-message-product-price {
    font-weight: 700;
    color: var(--color-accent, #f97316); /* Precio destacado en naranja tech */
    font-size: 0.85rem;
}

.ct-ai-product-select-action-bar {
    background: #f8fafc;
    border-top: 1px solid var(--border-color, #e2e8f0);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bg-primary, #0f172a);
    transition: background 0.2s, color 0.2s;
}

.ct-ai-message-product:hover .ct-ai-product-select-action-bar {
    background: var(--color-accent, #f97316); /* Barra en naranja tech en hover */
    color: #ffffff;
}


.ct-ai-message-product-btn {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    text-align: center;
}

.ct-ai-message-product-btn:hover {
    background: #1d4ed8;
}

/* Typing Indicator */
.ct-ai-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    width: 60px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
    align-self: flex-start;
}

.ct-ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ct-ai-typing 1.4s infinite ease-in-out both;
}

.ct-ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ct-ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ct-ai-typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.ct-ai-chat-input-area {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    background: #ffffff;
}

.ct-ai-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}

.ct-ai-chat-input:focus {
    border-color: #3b82f6;
    background: #ffffff;
}

.ct-ai-chat-send {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: #0f172a !important; /* Cambiado a gris/azul muy oscuro */
    color: #ffffff !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background 0.2s, transform 0.2s !important;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.ct-ai-chat-send:hover {
    background: #3b82f6 !important; /* Cambia a azul brillante en hover */
    transform: scale(1.05) !important;
}

.ct-ai-chat-send svg {
    width: 18px;
    height: 18px;
    fill: none !important;
    stroke: #ffffff !important; /* Forzar el trazo blanco puro */
    stroke-width: 2.5px !important;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

/* Mobile responsive styles */
@media (max-width: 480px) {
    #clictienda-ai-chat-widget {
        bottom: 85px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
        height: 70vh !important; /* Altura corta en vertical de 70% de la pantalla */
        max-height: 550px !important; /* Evita que crezca detrás de las barras del navegador */
        border-radius: 16px !important;
    }
    #clictienda-ai-chat-toggle {
        bottom: 15px !important;
        right: 15px !important;
    }
}
