/**
 * WC AI Chat Agent - Styles MEJORADO
 * Version: 3.0.0
 * Tecnología: Computadoras, Cámaras, Redes, Videovigilancia, Control de Acceso
 */

/* Container principal */
#wc-ai-chat-agent-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

/* Posiciones */
#wc-ai-chat-agent-container.wc-ai-chat-position-right {
    right: 20px;
}

#wc-ai-chat-agent-container.wc-ai-chat-position-left {
    left: 20px;
}

/* Animación EVA */
.wc-ai-chat-launcher {
    position: relative;
    cursor: pointer;
    z-index: 1000;
}

.wc-ai-chat-launcher .wc-ai-chat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(102, 126, 234, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

/* Efecto de luz interna */
.wc-ai-chat-launcher .wc-ai-chat-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0.2) 0%,
            rgba(255, 255, 255, 0) 100%);
    border-radius: 50% 50% 0 0;
}

/* Robot EVA animado */
.wc-ai-chat-launcher .wc-ai-chat-icon img {
    width: 38px;
    height: 38px;
    animation: evaDance 6s infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    z-index: 1;
    position: relative;
}

@keyframes evaDance {

    0%,
    100% {
        transform:
            translateY(0) rotate(0deg) scale(1);
    }

    15% {
        transform:
            translateY(-6px) rotate(4deg) scale(1.05);
    }

    30% {
        transform:
            translateY(3px) rotate(-3deg) scale(0.98);
    }

    45% {
        transform:
            translateY(-3px) rotate(2deg) scale(1.02);
    }

    60% {
        transform:
            translateY(2px) rotate(-1deg) scale(0.99);
    }

    75% {
        transform:
            translateY(-1px) rotate(1deg) scale(1.01);
    }
}

/* Efecto hover - EVA se activa */
.wc-ai-chat-launcher:hover .wc-ai-chat-icon {
    box-shadow:
        0 6px 30px rgba(102, 126, 234, 0.6),
        inset 0 0 30px rgba(255, 255, 255, 0.2),
        0 0 20px rgba(102, 126, 234, 0.4);
}

.wc-ai-chat-launcher:hover .wc-ai-chat-icon img {
    animation: evaExcited 1.2s infinite ease-in-out;
}

@keyframes evaExcited {

    0%,
    100% {
        transform:
            translateY(0) rotate(0deg) scale(1.1);
    }

    50% {
        transform:
            translateY(-8px) rotate(8deg) scale(1.15);
    }
}

/* Pulso mejorado */
.wc-ai-chat-pulse {
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 2px solid rgba(102, 126, 234, 0.5);
    border-radius: 50%;
    animation: evaEnergyPulse 3s infinite;
    opacity: 0;
}

@keyframes evaEnergyPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.7;
        box-shadow:
            0 0 0 0 rgba(102, 126, 234, 0.6),
            0 0 0 0 rgba(255, 255, 255, 0.3);
    }

    70% {
        transform: scale(1.5);
        opacity: 0;
        box-shadow:
            0 0 0 15px rgba(102, 126, 234, 0),
            0 0 0 30px rgba(255, 255, 255, 0);
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Botón flotante - PULSO */
@keyframes wc-ai-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.3);
        opacity: 0;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Ventana del chat */
.wc-ai-chat-window {
    position: absolute;
    bottom: 10px;
    width: 450px;
    max-width: 90vw;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1999;
    overflow: hidden;
}

.wc-ai-chat-position-right .wc-ai-chat-window {
    right: 0;
}

.wc-ai-chat-position-left .wc-ai-chat-window {
    left: 0;
}

.wc-ai-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header del chat TÉCNICO - VERSIÓN CON X EN ESQUINA */
.wc-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    position: relative;
}

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

/* Avatar TÉCNICO */
.wc-ai-chat-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    backdrop-filter: blur(10px);
}

.wc-ai-chat-avatar-icon {
    width: 36px;
    height: 36px;
}

.wc-ai-chat-title h4 {
    margin: 0 0 2px 0;
    font-size: 15px;
    font-weight: 600;
}

.wc-ai-chat-status {
    font-size: 11px;
    opacity: 0.9;
    color: #a0f0a0;
}

/* Botón cerrar como ventana Windows - CORREGIDO */
.wc-ai-chat-actions {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 10;
}



/* Forzar color blanco si hay conflicto */
.wc-ai-chat-close svg line {
    stroke: white;
}

/* Área de mensajes MEJORADA para legibilidad */
.wc-ai-chat-messages {
    height: 400px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 transparent;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wc-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wc-ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wc-ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.wc-ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mensajes individuales MEJORADOS */
.wc-ai-chat-message {
    animation: wc-ai-message-appear 0.3s ease;
    max-width: 85%;
}

@keyframes wc-ai-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-ai-chat-message.user {
    align-self: flex-end;
    text-align: right;
}

.wc-ai-chat-message.user .wc-ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.wc-ai-chat-message.bot .wc-ai-message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

/* Contenido de mensajes MEJORADO - TÉCNICO */
.wc-ai-message-content {
    display: inline-block;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
    font-size: 14px;
    text-align: left;
}

/* Estilos específicos para mensajes de productos TECNOLÓGICOS */
.wc-ai-message-content .product-info {
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
}

.wc-ai-message-content .product-price {
    color: #4CAF50;
    font-weight: 600;
    font-size: 15px;
}

.wc-ai-message-content .product-sku {
    color: #666;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
}

.wc-ai-message-content .product-stock {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.wc-ai-message-content .product-stock.in-stock {
    background: #d4edda;
    color: #155724;
}

.wc-ai-message-content .product-stock.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

.wc-ai-message-content .product-specs {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    font-style: italic;
}

.wc-ai-message-content .tech-badge {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 5px;
    margin-bottom: 5px;
}

.wc-ai-message-content .tech-highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.wc-ai-message-content p {
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.wc-ai-message-content p:last-child {
    margin-bottom: 0;
}

.wc-ai-message-content ul,
.wc-ai-message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.wc-ai-message-content li {
    margin: 6px 0;
    line-height: 1.4;
}

.wc-ai-message-content strong {
    font-weight: 600;
    color: #2c3e50;
}

.wc-ai-message-content em {
    font-style: italic;
    color: #7f8c8d;
}

.wc-ai-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wc-ai-chat-message.user .wc-ai-message-time {
    justify-content: flex-end;
}

/* Contenedor de input */
.wc-ai-chat-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #e1e5e9;
}

.wc-ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px;
}

.wc-ai-chat-input textarea {
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    transition: border-color 0.3s ease;
    background: #f8f9fa;
}

.wc-ai-chat-input textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.wc-ai-chat-input textarea::placeholder {
    color: #999;
}

/* Botón de enviar */
.wc-ai-chat-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wc-ai-chat-send:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: scale(1.05);
}

.wc-ai-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.wc-ai-send-icon {
    font-size: 16px;
    font-weight: bold;
}

/* Fallback de WhatsApp */
.wc-ai-chat-fallback {
    text-align: center;
}

.wc-ai-whatsapp-fallback {
    background: #25D366;
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.wc-ai-whatsapp-fallback:hover {
    background: #128C7E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.wc-ai-whatsapp-icon {
    font-size: 16px;
}

/* Enlace de WhatsApp en mensajes */
.wc-ai-whatsapp-link {
    display: inline-block;
    background: #25D366;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.wc-ai-whatsapp-link:hover {
    background: #128C7E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

/* Loading TÉCNICO */
.wc-ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-style: italic;
}

.loading-dots {
    display: flex;
    gap: 3px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    animation: wc-ai-loading-bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes wc-ai-loading-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Estados responsivos */
@media (max-width: 480px) {
    #wc-ai-chat-agent-container {
        bottom: 10px;
    }

    #wc-ai-chat-agent-container.wc-ai-chat-position-right {
        right: 10px;
    }

    #wc-ai-chat-agent-container.wc-ai-chat-position-left {
        left: 10px;
    }

    .wc-ai-chat-window {
        width: calc(100vw - 20px);
        max-width: none;
        bottom: 70px;
    }

    .wc-ai-chat-messages {
        height: 350px;
        max-height: 50vh;
        padding: 15px;
    }

    .wc-ai-chat-message {
        max-width: 90%;
    }

    .wc-ai-message-content {
        padding: 12px 15px;
        font-size: 13px;
    }

    /* Ajustes para móviles - botón cerrar */
    .wc-ai-chat-actions {
        top: 10px;
        right: 12px;
    }

    .wc-ai-chat-close {
        width: 18px;
        height: 18px;
    }
}

/* Animación de entrada del chat */
@keyframes wc-ai-chat-entrance {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.wc-ai-chat-window.active {
    animation: wc-ai-chat-entrance 0.3s ease;
}

/* Mejoras de accesibilidad */
.wc-ai-chat-close:focus,
.wc-ai-chat-send:focus,
.wc-ai-whatsapp-fallback:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.wc-ai-chat-input textarea:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* Estados de interactividad */
.wc-ai-chat-launcher.active .wc-ai-chat-icon {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Smooth transitions para todos los elementos interactivos */
.wc-ai-chat-launcher,
.wc-ai-chat-close,
.wc-ai-chat-send,
.wc-ai-whatsapp-fallback,
.wc-ai-chat-input textarea {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Indicador de caché */
.wc-ai-cache-indicator {
    font-size: 0.7em;
    opacity: 0.6;
    font-style: italic;
    margin-left: 8px;
}

/* Efecto de escritura palabra por palabra */
.wc-ai-message-content.typing-effect {
    overflow: hidden;
}

.wc-ai-message-content.typing-effect span.word {
    opacity: 0;
    animation: wordAppear 0.3s ease forwards;
}

@keyframes wordAppear {
    to {
        opacity: 1;
    }
}

/* Cursor parpadeante para efecto de escritura */
.wc-ai-typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #667eea;
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Estilos específicos para contenido técnico */
.tech-category {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 8px;
    margin-bottom: 8px;
}

.tech-specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.tech-spec-item {
    background: #f0f4f8;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
}

.tech-spec-value {
    font-weight: 600;
    color: #667eea;
    display: block;
    margin-top: 4px;
}

.price-comparison {
    background: #fff8e1;
    border-left: 4px solid #ffb300;
    padding: 10px;
    margin: 10px 0;
    border-radius: 0 6px 6px 0;
}

.price-old {
    text-decoration: line-through;
    color: #999;
    margin-right: 10px;
}

.price-new {
    color: #4CAF50;
    font-weight: 600;
    font-size: 1.2em;
}

.price-savings {
    color: #f44336;
    font-weight: 600;
    margin-left: 10px;
}

/* Badges para tipos de productos */
.product-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 5px;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.product-type-badge.computer {
    background: #e3f2fd;
    color: #1565c0;
}

.product-type-badge.camera {
    background: #f3e5f5;
    color: #7b1fa2;
}

.product-type-badge.network {
    background: #e8f5e9;
    color: #2e7d32;
}

.product-type-badge.storage {
    background: #fff3e0;
    color: #ef6c00;
}

.product-type-badge.accessory {
    background: #fce4ec;
    color: #c2185b;
}

/* Iconos de producto */
.product-icon {
    display: inline-block;
    margin-right: 5px;
    font-size: 14px;
}

/* Media queries adicionales para tablets */
@media (max-width: 768px) {
    .wc-ai-chat-window {
        width: 380px;
    }

    .tech-specs-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

/* Estilos para modo oscuro (si se implementa) */
@media (prefers-color-scheme: dark) {
    .wc-ai-chat-window {
        background: #2d2d2d;
        color: #ffffff;
    }

    .wc-ai-chat-messages {
        background: #1a1a1a;
    }

    .wc-ai-chat-input textarea {
        background: #3d3d3d;
        color: #ffffff;
        border-color: #555;
    }

    .wc-ai-message-content.bot {
        background: #3d3d3d;
        color: #ffffff;
        border-color: #555;
    }

    

    .product-info {
        background: #3d3d3d;
    }


    /* CON ID ÚNICO - prácticamente imposible de sobrescribir */
    #wc-ai-chat-close-btn {
        background: rgba(255, 255, 255, 0.2) !important;
        border: none !important;
        cursor: pointer !important;
        color: white !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 18px !important;
        height: 18px !important;
        border-radius: 50% !important;
        margin: 0 !important;
        outline: none !important;
        box-shadow: none !important;
    }

    #wc-ai-chat-close-btn:hover {
        background: rgba(255, 255, 255, 0.3) !important;
        transform: scale(1.1) !important;
    }

    #wc-ai-chat-close-btn:active {
        background: rgba(255, 255, 255, 0.4) !important;
        transform: scale(0.95) !important;
    }

    #wc-ai-chat-close-btn svg {
        width: 14px !important;
        height: 14px !important;
        stroke: white !important;
    }
}