/**
 * Estilos para el widget de chat en el frontend
 */

:root {
    --aicw-primary-color: #7c3aed;
    --aicw-text-color: #333;
    --aicw-bg-color: #fff;
    --aicw-border-color: #e5e7eb;
    --aicw-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    
    /* Tamaños de fuente personalizables */
    --aicw-title-size-desktop: 15px;
    --aicw-title-size-mobile: 13px;
    --aicw-message-size-desktop: 13px;
    --aicw-message-size-mobile: 13px;
    --aicw-status-size-desktop: 11px;
    --aicw-status-size-mobile: 10px;
}

/* Container principal */
#aicw-widget-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#aicw-widget-container.aicw-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#aicw-widget-container.aicw-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

#aicw-widget-container.aicw-position-top-right {
    top: 20px;
    right: 20px;
}

#aicw-widget-container.aicw-position-top-left {
    top: 20px;
    left: 20px;
}

/* Botón de chat */
.aicw-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aicw-primary-color);
    border: none;
    cursor: pointer;
    position: relative;
    box-shadow: var(--aicw-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.aicw-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

.aicw-chat-icon,
.aicw-close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    color: white;
    font-size: 24px;
}

.aicw-chat-icon {
    opacity: 1;
    color: var(--aicw-icon-color, #ffffff);
    transition: color 0.3s ease, transform 0.3s ease;
}

.aicw-close-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg);
}

/* El icono se mantiene visible, solo cambia de color */
#aicw-chat-button.aicw-open .aicw-chat-icon {
    color: var(--aicw-icon-color-hover, #ffffff);
    transform: translate(-50%, -50%) scale(1.1);
}

#aicw-chat-button:hover .aicw-chat-icon {
    color: var(--aicw-icon-color-hover, #ffffff);
}

#aicw-chat-button.aicw-open .aicw-close-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg);
}

.aicw-chat-button svg {
    color: white;
    transition: all 0.3s ease;
}

.aicw-chat-button .aicw-close-icon {
    display: none;
}

.aicw-chat-button.aicw-active .aicw-close-icon {
    display: block;
}

/* Ventana de chat */
.aicw-chat-window {
    position: absolute;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--aicw-bg-color);
    border-radius: 16px;
    box-shadow: var(--aicw-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.aicw-chat-window.aicw-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Posicionamiento de ventana según ubicación del widget - Bottom Right (default) */
.aicw-position-bottom-right .aicw-chat-window {
    bottom: 80px;
    right: 0;
}

/* Bottom Left - Ventana alineada a la izquierda */
.aicw-position-bottom-left .aicw-chat-window {
    bottom: 80px;
    left: 0;
}

/* Top Right - Ventana debajo del botón */
.aicw-position-top-right .aicw-chat-window {
    top: 80px;
    right: 0;
}

/* Top Left - Ventana debajo y a la izquierda */
.aicw-position-top-left .aicw-chat-window {
    top: 80px;
    left: 0;
}

/* Header */
.aicw-chat-header {
    background: var(--aicw-primary-color);
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
}

.aicw-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* Contenedor de botones del header */
.aicw-header-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.aicw-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.aicw-agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.aicw-agent-details {
    display: flex;
    flex-direction: column;
}

.aicw-agent-name {
    margin: 0;
    font-size: var(--aicw-title-size-desktop);
    font-weight: 600;
    color: white;
}

.aicw-agent-status {
    font-size: var(--aicw-status-size-desktop);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aicw-status-dot {
    width: 12px;
    height: 12px;
    background: #00d26a;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    box-shadow: 0 0 0 0 rgba(0, 210, 106, 0.7);
    animation: aicw-status-pulse 2s infinite;
}

.aicw-status-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #00d26a;
    box-shadow: 0 0 10px 2px rgba(0, 210, 106, 0.6),
                0 0 20px 4px rgba(0, 210, 106, 0.4),
                inset 0 0 8px rgba(255, 255, 255, 0.3);
}

@keyframes aicw-status-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 210, 106, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 210, 106, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 210, 106, 0);
    }
}

.aicw-agent-contact {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
}

.aicw-agent-email,
.aicw-agent-whatsapp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.aicw-agent-email:hover {
    color: rgba(255, 255, 255, 1);
    text-decoration: underline;
}

.aicw-agent-whatsapp {
    color: rgba(37, 211, 102, 1); /* Verde WhatsApp */
}

.aicw-agent-whatsapp:hover {
    color: rgba(37, 211, 102, 0.8);
    text-decoration: underline;
}

.aicw-agent-email i,
.aicw-agent-whatsapp i {
    font-size: 10px;
}

.aicw-agent-whatsapp i {
    font-size: 12px; /* Icono WhatsApp un poco más grande */
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.aicw-minimize-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.aicw-minimize-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.aicw-minimize-button svg {
    color: white;
}

/* Messages container */
.aicw-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f9fafb;
}

.aicw-messages-container::-webkit-scrollbar {
    width: 6px;
}

.aicw-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.aicw-messages-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Message */
.aicw-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.aicw-message-user {
    flex-direction: row-reverse;
}

.aicw-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.aicw-message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    font-size: var(--aicw-message-size-desktop);
    line-height: 1.4;
    background: #f3f4f6;
}

.aicw-message-bot .aicw-message-bubble {
    background: white;
    color: var(--aicw-text-color);
    border: 1px solid var(--aicw-border-color);
    border-radius: 16px 16px 16px 4px;
}

.aicw-message-user .aicw-message-bubble {
    background: var(--aicw-primary-color);
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.aicw-message-error .aicw-message-bubble {
    background: #fee;
    border-color: #fcc;
    color: #c33;
}

.aicw-message-time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.6;
}

/* Typing indicator */
.aicw-typing-indicator {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 20px 10px;
    background: #f9fafb;
}

.aicw-typing-dots {
    background: white;
    border: 1px solid var(--aicw-border-color);
    padding: 12px 16px;
    border-radius: 16px;
    display: flex;
    gap: 4px;
}

.aicw-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.aicw-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.aicw-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Input container */
.aicw-input-container {
    padding: 16px;
    border-top: 1px solid var(--aicw-border-color);
    background: white;
    border-radius: 0 0 16px 16px;
}

.aicw-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f9fafb;
    border-radius: 12px;
    padding: 8px 12px;
    border: 1px solid var(--aicw-border-color);
    transition: all 0.2s;
}

.aicw-input-wrapper:focus-within {
    border-color: var(--aicw-primary-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

#aicw-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

/* Notificación burbuja */
.aicw-bubble-notification {
    position: absolute;
    background: white;
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    font-size: 12px;
    color: #374151;
    white-space: nowrap;
    animation: bubbleBounce 2s infinite;
    max-width: 160px;
    display: none;
    z-index: 999999;
}

.aicw-bubble-notification.aicw-show {
    display: block;
}

/* Posicionamiento según ubicación del widget - Bottom Right (default) */
.aicw-position-bottom-right .aicw-bubble-notification {
    bottom: 75px;
    right: 0;
}

.aicw-position-bottom-right .aicw-bubble-notification::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* Bottom Left - Burbuja a la derecha del botón */
.aicw-position-bottom-left .aicw-bubble-notification {
    bottom: 75px;
    left: 0;
}

.aicw-position-bottom-left .aicw-bubble-notification::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* Top Right - Burbuja debajo del botón */
.aicw-position-top-right .aicw-bubble-notification {
    top: 75px;
    right: 0;
}

.aicw-position-top-right .aicw-bubble-notification::after {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    border-top: none;
}

/* Top Left - Burbuja debajo y a la derecha del botón */
.aicw-position-top-left .aicw-bubble-notification {
    top: 75px;
    left: 0;
}

.aicw-position-top-left .aicw-bubble-notification::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    border-top: none;
}

@keyframes bubbleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Botón cerrar burbuja */
.aicw-bubble-close {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 8px;
    color: #999;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.aicw-bubble-close:hover {
    color: #666;
}

/* Tamaños de botón móvil */
.aicw-mobile-button-small .aicw-chat-button {
    width: 50px;
    height: 50px;
}

.aicw-mobile-button-medium .aicw-chat-button {
    width: 60px;
    height: 60px;
}

.aicw-mobile-button-large .aicw-chat-button {
    width: 70px;
    height: 70px;
}

/* Ocultar en dispositivos específicos */
.aicw-desktop-only {
    display: block;
}

.aicw-mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .aicw-desktop-only {
        display: none !important;
    }
    
    .aicw-mobile-only {
        display: block !important;
    }
}

/* Posiciones móviles adicionales */
#aicw-widget-container.aicw-mobile-position-bottom-center {
    left: 50%;
    transform: translateX(-50%);
}

/* Desktop pequeño - Ajuste para pantallas entre 1024px y 1280px */
@media (max-width: 1280px) and (min-width: 1025px) {
    .aicw-chat-window {
        width: 380px;
        max-width: calc(100vw - 50px);
        height: 580px;
        max-height: calc(100vh - 100px);
    }
}

/* Tablet - Ajuste responsivo para tablets */
@media (max-width: 1024px) and (min-width: 769px) {
    .aicw-chat-window {
        width: 360px !important;
        max-width: calc(100vw - 60px) !important;
        height: 520px !important;
        max-height: calc(100vh - 100px) !important;
    }
    
    /* Widget más pequeño en tablets */
    .aicw-chat-button {
        width: 55px !important;
        height: 55px !important;
    }
    
    /* Asegurar que no se desborde en ninguna posición */
    .aicw-position-bottom-left .aicw-chat-window,
    .aicw-position-top-left .aicw-chat-window {
        max-width: calc(100vw - 60px) !important;
    }
    
    .aicw-position-bottom-right .aicw-chat-window,
    .aicw-position-top-right .aicw-chat-window {
        max-width: calc(100vw - 60px) !important;
    }
}

/* Responsive - Móvil */
@media (max-width: 768px) {
    /* Aplicar tamaños móviles usando variables CSS */
    :root {
        --aicw-title-size-desktop: var(--aicw-title-size-mobile);
        --aicw-message-size-desktop: var(--aicw-message-size-mobile);
        --aicw-status-size-desktop: var(--aicw-status-size-mobile);
    }
    
    /* IMPORTANTE: Asegurar que el widget se vea en móvil */
    #aicw-widget-container {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
    }
    
    /* Botón más pequeño en móvil */
    .aicw-chat-button {
        width: 50px !important;
        height: 50px !important;
    }
    
    /* Ventana de chat en móvil - Casi fullscreen con margen */
    .aicw-chat-window {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 80px) !important;
        bottom: 70px !important;
        right: 10px !important;
        left: 10px !important;
        top: auto !important;
        border-radius: 16px !important;
        position: fixed !important;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* Anular posicionamientos personalizados en móvil - Siempre centrado */
    .aicw-position-bottom-right .aicw-chat-window,
    .aicw-position-bottom-left .aicw-chat-window,
    .aicw-position-top-right .aicw-chat-window,
    .aicw-position-top-left .aicw-chat-window {
        bottom: 70px !important;
        right: 10px !important;
        left: 10px !important;
        top: auto !important;
    }
    
    /* Header compacto en móvil */
    .aicw-chat-header {
        padding: 10px 12px !important;
        min-height: auto !important;
    }
    
    .aicw-agent-avatar {
        width: 32px !important;
        height: 32px !important;
    }
    
    .aicw-agent-email,
    .aicw-agent-whatsapp {
        font-size: 9px !important;
        gap: 3px;
    }
    
    .aicw-agent-email i {
        font-size: 8px !important;
    }
    
    .aicw-agent-whatsapp i {
        font-size: 10px !important;
    }
    
    .aicw-agent-details h3 {
        font-size: 10px !important;
    }
    
    .aicw-agent-name {
        font-size: 13px !important;
    }
    
    .aicw-agent-status {
        font-size: 10px !important;
    }
    
    /* Contenedor de mensajes más alto en móvil */
    .aicw-messages-container {
        height: calc(100% - 110px) !important;
        padding: 8px !important;
    }
    
    /* Mensajes más compactos */
    .aicw-message {
        margin-bottom: 8px !important;
    }
    
    .aicw-message-avatar {
        width: 28px !important;
        height: 28px !important;
    }
    
    .aicw-message-bubble {
        font-size: 13px !important;
        padding: 8px 10px !important;
        max-width: 75% !important;
    }
    
    /* Input compacto */
    .aicw-input-container {
        padding: 8px !important;
    }
    
    #aicw-message-input {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }
    
    .aicw-send-button {
        padding: 6px !important;
    }
    
    .aicw-send-button i {
        font-size: 14px !important;
    }
    
    /* Botones del header más pequeños */
    .aicw-clear-button,
    .aicw-minimize-button {
        padding: 6px !important;
    }
    
    .aicw-clear-button i,
    .aicw-minimize-button i {
        font-size: 16px !important;
    }
    
    /* Typing indicator más pequeño */
    .aicw-typing-indicator {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
    
    .aicw-typing-dots span {
        width: 5px !important;
        height: 5px !important;
    }
    
    .aicw-chat-window.aicw-open {
        transform: translateY(0) !important;
    }
    
    /* Enlaces más accesibles en móvil */
    .aicw-message-link {
        word-break: break-word;
        padding: 4px 6px;
    }
    
    .aicw-whatsapp-link {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .aicw-whatsapp-link i {
        font-size: 20px;
    }
    
    .aicw-message-link[href^="mailto:"] {
        padding: 4px 10px;
        font-size: 14px;
    }
}

/* Móviles muy pequeños (altura < 600px) */
@media (max-width: 768px) and (max-height: 650px) {
    /* Reducir aún más el header */
    .aicw-chat-header {
        padding: 8px 10px !important;
    }
    
    .aicw-agent-avatar {
        width: 28px !important;
        height: 28px !important;
    }
    
    .aicw-agent-name {
        font-size: 12px !important;
    }
    
    .aicw-agent-status {
        font-size: 9px !important;
    }
    
    .aicw-agent-email,
    .aicw-agent-whatsapp {
        font-size: 8px !important;
        gap: 2px;
    }
    
    .aicw-agent-email i {
        font-size: 7px !important;
    }
    
    .aicw-agent-whatsapp i {
        font-size: 9px !important;
    }
    
    /* Contenedor de mensajes aún más alto */
    .aicw-messages-container {
        height: calc(100% - 100px) !important;
        padding: 6px !important;
    }
    
    /* Mensajes ultra compactos */
    .aicw-message {
        margin-bottom: 6px !important;
    }
    
    .aicw-message-avatar {
        width: 24px !important;
        height: 24px !important;
    }
    
    .aicw-message-bubble {
        font-size: 12px !important;
        padding: 6px 8px !important;
        line-height: 1.3 !important;
    }
    
    /* Input ultra compacto */
    .aicw-input-container {
        padding: 6px !important;
    }
    
    #aicw-message-input {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }
    
    .aicw-send-button {
        padding: 5px !important;
    }
    
    .aicw-send-button i {
        font-size: 13px !important;
    }
    
    /* Botones header ultra pequeños */
    .aicw-clear-button,
    .aicw-minimize-button {
        padding: 5px !important;
    }
    
    .aicw-clear-button i,
    .aicw-minimize-button i {
        font-size: 14px !important;
    }
    
    /* Tamaño de ventana móvil: pantalla completa */
    .aicw-mobile-window-full .aicw-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        max-width: none !important;
        max-height: none !important;
    }
    
    .aicw-mobile-window-full .aicw-chat-window.aicw-open {
        transform: none !important;
    }
    
    /* Tamaño de ventana móvil: compacto */
    .aicw-mobile-window-compact .aicw-chat-window {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 100px) !important;
        bottom: 10px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(20px) !important;
        border-radius: 16px !important;
        position: fixed !important;
    }
    
    .aicw-mobile-window-compact .aicw-chat-window.aicw-open {
        transform: translateX(-50%) translateY(0) !important;
    }
    
    /* Ajustes generales móvil */
    .aicw-chat-header {
        padding: 12px 14px;
    }
    
    .aicw-messages-container {
        padding: 12px;
    }
    
    .aicw-input-container {
        padding: 10px;
    }
    
    #aicw-message-input {
        font-size: 14px;
        padding: 9px 12px;
    }
    
    /* Burbuja más pequeña en móvil */
    .aicw-bubble-notification {
        font-size: 11px;
        padding: 6px 10px;
        max-width: 140px;
        bottom: 70px;
        right: -5px;
    }
    
    .aicw-bubble-notification::after {
        right: 15px;
    }
}

@media (max-width: 480px) {
    /* Ventana fullscreen en móviles pequeños */
    .aicw-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Forzar ventana centrada en todas las posiciones */
    .aicw-position-bottom-right .aicw-chat-window,
    .aicw-position-bottom-left .aicw-chat-window,
    .aicw-position-top-right .aicw-chat-window,
    .aicw-position-top-left .aicw-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
    }
    
    .aicw-message-bubble {
        max-width: 85%;
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .aicw-agent-avatar {
        width: 32px;
        height: 32px;
    }
    
    .aicw-message-avatar {
        width: 26px;
        height: 26px;
    }
    
    .aicw-chat-button {
        width: 50px !important;
        height: 50px !important;
    }
    
    .aicw-chat-icon,
    .aicw-close-icon {
        width: 22px;
        height: 22px;
    }
    
    /* Ocultar burbuja en pantallas muy pequeñas */
    .aicw-bubble-notification {
        display: none !important;
    }
}

/* Estados del widget */
.aicw-widget-offline .aicw-agent-status .aicw-status-dot {
    background: #ef4444;
}

.aicw-widget-offline .aicw-agent-status {
    opacity: 0.8;
}

/* Loader para respuestas */
.aicw-message-loader {
    display: inline-flex;
    gap: 4px;
    padding: 8px;
}

.aicw-message-loader span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

/* Animaciones mejoradas */
.aicw-message {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animación del botón flotante */
.aicw-chat-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.aicw-chat-button:hover {
    transform: scale(1.05);
}

.aicw-chat-button:active {
    transform: scale(0.95);
}

/* Animación de apertura de ventana */
.aicw-chat-window {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animación de typing mejorada */
.aicw-typing-dots span {
    animation: typingBounce 1.4s infinite ease-in-out;
}

.aicw-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.aicw-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.aicw-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Transición smooth en inputs */
#aicw-message-input,
.aicw-send-button,
.aicw-minimize-button {
    transition: all 0.2s ease;
}

/* Estilos para iconos FontAwesome en botones */
.aicw-minimize-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.aicw-minimize-button i {
    font-size: 18px;
}

.aicw-send-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--aicw-primary-color);
}

.aicw-send-button i {
    font-size: 16px;
}

/* Hover effects mejorados */
.aicw-send-button:hover {
    background: rgba(124, 58, 237, 0.1);
    transform: scale(1.1);
}

.aicw-minimize-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.aicw-send-button:active,
.aicw-minimize-button:active {
    transform: scale(0.9);
}

/* Email del agente en header */
.aicw-agent-email-display {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
}

.aicw-agent-email-display a {
    color: white;
    text-decoration: none;
}

.aicw-agent-email-display a:hover {
    text-decoration: underline;
}

/* Botón limpiar conversación */
.aicw-clear-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.aicw-clear-button:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: rotate(15deg);
}

.aicw-clear-button i {
    font-size: 16px;
    color: white;
}

/* Botón copiar mensaje - Más pequeño y con margen */
.aicw-copy-button {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 4px;
    padding: 4px 5px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    line-height: 1;
}

.aicw-message-bot:hover .aicw-copy-button {
    opacity: 0.7;
}

.aicw-copy-button:hover {
    background: rgba(0, 0, 0, 0.12);
    opacity: 1 !important;
    transform: scale(1.05);
}

.aicw-copy-button:active {
    transform: scale(0.95);
}

.aicw-copy-button i {
    font-size: 11px;
    color: #6b7280;
}

.aicw-copy-button.aicw-copied {
    background: #10b981;
    opacity: 1 !important;
}

.aicw-copy-button.aicw-copied i {
    color: white;
}

/* Ajustar padding del mensaje para no sobreponerse */
.aicw-message-bot .aicw-message-bubble {
    padding-right: 32px;
}

/* Enlaces clickeables en mensajes */
.aicw-message-link {
    color: #3b82f6;
    text-decoration: underline;
    word-break: break-all;
    transition: all 0.2s ease;
    font-weight: 500;
}

.aicw-message-link:hover {
    color: #2563eb;
    text-decoration: none;
    background-color: rgba(59, 130, 246, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

.aicw-message-user .aicw-message-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: underline;
}

.aicw-message-user .aicw-message-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.2);
}

/* Enlaces de WhatsApp con estilo especial */
.aicw-whatsapp-link {
    color: #25D366 !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(37, 211, 102, 0.15);
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid rgba(37, 211, 102, 0.3);
    transition: all 0.2s ease;
}

.aicw-whatsapp-link:hover {
    background-color: rgba(37, 211, 102, 0.25);
    color: #128C7E !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    border-color: rgba(37, 211, 102, 0.5);
}

.aicw-whatsapp-link i {
    font-size: 18px;
    color: #25D366;
}

.aicw-message-user .aicw-whatsapp-link {
    background-color: rgba(255, 255, 255, 0.25);
    color: white !important;
    border-color: rgba(255, 255, 255, 0.3);
}

.aicw-message-user .aicw-whatsapp-link:hover {
    background-color: rgba(255, 255, 255, 0.4);
    color: white !important;
    border-color: rgba(255, 255, 255, 0.5);
}

.aicw-message-user .aicw-whatsapp-link i {
    color: white;
}

/* Enlaces de email con estilo especial */
.aicw-message-link[href^="mailto:"] {
    color: #8b5cf6;
    font-weight: 500;
    background-color: rgba(139, 92, 246, 0.08);
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    text-decoration: none;
    transition: all 0.2s ease;
}

.aicw-message-link[href^="mailto:"]:hover {
    color: #7c3aed;
    background-color: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.aicw-message-link[href^="mailto:"]::before {
    content: '✉ ';
    margin-right: 4px;
    opacity: 0.7;
}

.aicw-message-user .aicw-message-link[href^="mailto:"] {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.aicw-message-user .aicw-message-link[href^="mailto:"]:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Formato Markdown en mensajes */
.aicw-message-bubble strong {
    font-weight: 700;
    color: inherit;
}

.aicw-message-bubble em {
    font-style: italic;
}

.aicw-inline-code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.aicw-message-user .aicw-inline-code {
    background: rgba(255, 255, 255, 0.2);
}

.aicw-code-block {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--aicw-primary-color);
    padding: 10px;
    border-radius: 6px;
    margin: 8px 0;
    overflow-x: auto;
}

.aicw-code-block code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.aicw-heading {
    font-weight: 700;
    margin: 8px 0 4px 0;
    line-height: 1.3;
}

.aicw-heading:first-child {
    margin-top: 0;
}

.aicw-message-bubble h1 {
    font-size: 1.2em;
}

.aicw-message-bubble h2 {
    font-size: 1.1em;
}

.aicw-message-bubble h3 {
    font-size: 1em;
}

.aicw-list {
    margin: 8px 0;
    padding-left: 20px;
    list-style: none;
}

.aicw-list-item {
    position: relative;
    margin: 4px 0;
    padding-left: 4px;
}

.aicw-list-item:before {
    content: "•";
    position: absolute;
    left: -12px;
    color: var(--aicw-primary-color);
    font-weight: bold;
}

.aicw-message-user .aicw-list-item:before {
    color: rgba(255, 255, 255, 0.8);
}

/* Toast notification */
.aicw-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.aicw-toast.aicw-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Posicionamiento relativo para copy button */
.aicw-message-bubble {
    position: relative;
}

.aicw-message-bot .aicw-message-bubble {
    padding-right: 36px;
}
