/* Chat Variables */
:root {
    /* Core Colors */
    --whatsapp-green: #25D366;
    --whatsapp-dark: #075E54;
    --whatsapp-teal: #128C7E;
    --whatsapp-light: #DCF8C6;
    --whatsapp-chat-bg: #E5DDD5;
    --whatsapp-panel: #F0F2F5;
    --whatsapp-bubble: #FFFFFF;
    --whatsapp-text: #303030;
    --whatsapp-header-height: 65px;
    --whatsapp-footer-height: 62px;
    --chat-radius: 8px;
    --online-indicator-size: 8px;
    --z-index-base: 10000;          /* Base para todos los elementos del widget */
    --z-index-overlay: 10001;       /* Overlay/backdrop */
    --z-index-widget: 10002;        /* Contenedor principal del widget */
    --z-index-window: 10003;        /* Ventana de chat */
    --z-index-modals: 10004;        /* Modales del chat (si existen) */
    --primary: #e9820d; /* Valor por defecto, será sobrescrito por el tenant */
}

/* Punto de montaje */
#contact-widget-mount {
    position: fixed;
    z-index: var(--z-index-base);
    bottom: 0;
    right: 0;
    display: block !important;
    visibility: visible !important;
    pointer-events: none; /* Permitir clicks en elementos debajo cuando está cerrado */
}

/* Base Widget Structure */
.contact-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: var(--z-index-widget);
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    pointer-events: all;
}

.contact-widget.visible {
    display: flex !important;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Asegurar que el chat tiene mayor z-index que los botones flotantes */
.chat-window {
    z-index: calc(var(--z-index-widget) + 1);
}

.contact-widget.visible .contact-button {
    display: flex !important;
    opacity: 1;
}

/* Button Components */
.contact-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    pointer-events: auto; /* Asegurar que los clicks funcionen */
}

.contact-button svg {
    color: white;
    width: 24px;
    height: 24px;
}

.contact-button.chat-button {
    background: var(--whatsapp-green);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.contact-widget.visible .contact-button.chat-button {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s; /* Pequeño delay para efecto escalonado */
}

.contact-button.chat-button svg {
    color: white;
}

/* Actualizar color del botón de llamada para usar --color-primary */
/* Usar el color dorado principal para el botón de llamada */
.contact-button.call-button {
    background: var(--primary-gold, #FF9500); /* Usa el color dorado principal */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.contact-widget.visible .contact-button.call-button {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.2s; /* Más delay para aparecer después */
}

.contact-button.call-button svg {
    color: white;
    transform: scale(1.1); /* Hacer el ícono de video un poco más grande */
}

.contact-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.contact-button:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.contact-tooltip {
    position: absolute;
    right: 75px;
    background: white;
    padding: 8px 12px;
    border-radius: var(--chat-radius);
    font-size: 0.875rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.contact-button:hover .contact-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* Chat Window Core */
.chat-window {
    position: fixed;
    bottom: 120px; /* Increased from 100px to give more space */
    right: 2rem;
    width: 400px; /* Aumentado de 360px a 400px */
    height: 520px;
    background: var(--whatsapp-chat-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none; /* Cambiamos a none por defecto */
    flex-direction: column;
    overflow: hidden;
    z-index: calc(var(--z-index-widget) + 1);
    opacity: 0; /* Cambiamos a 0 por defecto */
    transform: translateY(20px);
    visibility: hidden; /* Cambiado de hidden a visible */
    transition: all 0.3s ease;
    pointer-events: none; /* Cambiado de auto a none */
}

.chat-window.active {
    display: flex !important;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Añadido para permitir clicks */
}

/* Ajustar el tamaño cuando está centrado en desktop */
.chat-window.centered {
    width: 480px; /* Más ancho cuando está centrado */
    height: 580px; /* Un poco más alto también */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    bottom: auto;
    right: auto;
}

.chat-window.centered {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    margin: 0;
    z-index: 1003;
    width: 480px;
    height: 580px;
}

/* Header del Chat */
.chat-header {
    height: var(--whatsapp-header-height);
    background: var(--whatsapp-dark);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    position: relative;
    z-index: calc(var(--z-index-window) + 1);
}

.chat-header .avatar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header h3 {
    font-size: 1rem;
    font-weight: var(--font-weight-medium);
    margin: 0;
    color: white;
}

.chat-header small {
    font-size: 0.75rem;
    opacity: 0.8;
    display: block;
    margin-top: 2px;
}

.chat-header .close-chat {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-header .close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.chat-header .close-chat .lucide {
    width: 20px;
    height: 20px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: calc(var(--z-index-window) + 1);
}

.header-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

.header-action .lucide {
    width: 18px;
    height: 18px;
}

.call-action:hover {
    background: var(--whatsapp-green);
    transform: scale(1.05);
}

/* Estilo para el botón de video en el header */
.header-action.call-action svg {
    transform: scale(1.1);
}

.header-action.call-action:hover {
    background: var(--whatsapp-teal);
}

/* Añadir/modificar estos estilos */

.header-action.video-call-action {
    background: var(--whatsapp-green); /* Color diferente para video llamadas con IA */
    transition: all 0.3s ease;
}

.header-action.video-call-action:hover {
    background: var(--whatsapp-dark);
    transform: scale(1.05);
}

.header-action.video-call-action::after {
    content: none;
}

/* Añadir indicador de estado de videollamada */
.video-call-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem;
    border-radius: var(--chat-radius);
    z-index: 1004;
}

/* Status styles */
.status {
    display: flex;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, 0.8);
}

.status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--whatsapp-green);
    border-radius: 50%;
    margin-right: 4px;
}

/* Ajustar tamaños de avatar y contenedor */
.avatar-container {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.avatar-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
}

.avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--whatsapp-green);
    border: 2px solid var(--whatsapp-dark);
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

/* Área de Mensajes */
.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-image: var(--default-chat-background);
    position: relative; /* Añadido para crear un nuevo contexto de apilamiento */
}

.chat-message {
    padding: 0.75rem 1rem;
    border-radius: 7.5px;
    max-width: 85%;
    position: relative;
    font-size: 0.9375rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1; /* Menor que el typing indicator */
}

.chat-message.user {
    background: var(--whatsapp-light);
    color: var(--whatsapp-text);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.system {
    background: var(--whatsapp-bubble);
    color: var(--whatsapp-text);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    word-break: break-word;
    padding-bottom: 12px;
}

.chat-message.system a {
    color: var(--whatsapp-teal);
    text-decoration: none;
    font-weight: 500;
}

.chat-message.system a:hover {
    text-decoration: underline;
}

/* Estilos para enlaces en mensajes del sistema */
.chat-message.system .privacy-link {
    color: var(--whatsapp-teal);
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin-top: 8px;
}

.chat-message.system .privacy-link:hover {
    text-decoration: underline;
}

/* Estilos para el separador de fechas */
.date-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
    opacity: 0.7;
}

.date-separator::before,
.date-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--primary, #e9820d);
}

.date-separator span {
    padding: 0 10px;
    color: #222; /* Antes: var(--color-text-light); Cambiado a negro para resaltar */
    font-size: 0.8rem;
    font-weight: bold;
}

/* Input y Footer */
.chat-input {
    height: var(--whatsapp-footer-height);
    padding: 0.75rem 0.75rem; /* Reducido de 1rem a 0.75rem */
    background: var(--whatsapp-panel);
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Reducido de 0.75rem a 0.5rem */
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: calc(var(--z-index-window) + 1);
}

.chat-input input {
    flex: 1;
    padding: 0.75rem 0.875rem; /* Reducido el padding horizontal */
    border: none;
    border-radius: 18px; /* Reducido de 24px a 18px para hacerlo menos redondeado */
    background: white;
    font-size: 0.9375rem;
    outline: none;
    margin: 0 4px; /* Reducido de 8px a 4px */
}

.chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--whatsapp-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-input button:hover {
    background: var(--whatsapp-teal);
    transform: scale(1.05);
}

/* Botón de adjuntar */
.attach-button {
    background: transparent;
    border: none;
    color: #919191;
    cursor: pointer;
    padding: 6px; /* Reducido de 8px a 6px */
    width: 36px; /* Reducido de 40px a 36px */
    height: 36px; /* Reducido de 40px a 36px */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.attach-button:hover {
    color: var(--whatsapp-teal);
}

.attach-button svg {
    width: 20px; /* Reducido de 22px a 20px */
    height: 20px;
}

/* Ajustar el padding del input para compensar el nuevo layout */
.chat-input input[type="text"] {
    flex: 1;
    padding: 0.75rem 0.875rem; /* Reducido el padding horizontal */
    margin: 0 4px; /* Reducido de 8px a 4px */
}

/* Animaciones */
@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message {
    animation: messageIn 0.3s ease forwards;
}

/* Scrollbar Personalizada */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Adaptación Móvil */
@media (max-width: 480px) {
    /* Estructura principal del chat */
    .chat-window {
        width: 95vw !important;
        height: 80vh !important;
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        margin: 0;
        border-radius: 12px;
        z-index: var(--z-index-window);
        display: none;
        flex-direction: column;
        background: var(--whatsapp-chat-bg);
        transform: translate(-50%, -50%) !important;
    }

    .chat-window.active {
        display: flex;
    }

    .chat-window.centered {
        width: 95vw !important;
        height: 80vh !important;
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%) !important;
        border-radius: 12px;
    }

    /* Ajustar header para dispositivos con notch */
    .chat-header {
        padding-top: max(0.75rem, env(safe-area-inset-top));
        height: auto;
        min-height: var(--whatsapp-header-height);
    }

    /* Ajustar área de mensajes */
    .chat-messages {
        flex: 1;
        padding: 1rem;
        -webkit-overflow-scrolling: touch; /* Mejor scroll en iOS */
    }

    /* Optimizar input y footer para mobile */
    .chat-input {
        padding: 0.5rem 0.75rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        background: var(--whatsapp-panel);
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 2;
    }

    /* Ajustar tamaño de botones para mejor tap target */
    .chat-input button,
    .header-action,
    .close-chat {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }

    /* Ajustar input de texto */
    .chat-input input[type="text"] {
        height: 40px;
        padding: 8px 12px;
        font-size: 16px; /* Prevenir zoom en iOS */
        margin: 0 8px;
    }

    /* Mejorar visibilidad de mensajes */
    .chat-message {
        max-width: 90%;
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }

    /* Ajustar botones flotantes */
    .contact-widget {
        bottom: env(safe-area-inset-bottom, 1rem);
        right: 1rem;
        z-index: 1001;
    }

    .contact-button {
        width: 50px;
        height: 50px;
    }

    /* Mejorar visibilidad de tooltips */
    .contact-tooltip {
        display: none; /* Ocultar tooltips en mobile */
    }

    /* Optimizar previsualizaciones de archivos */
    .file-preview {
        max-width: 80%;
        margin: 0.5rem 0;
    }

    .file-preview img {
        max-height: 200px;
        object-fit: contain;
    }

    /* Ajustar indicador de escritura */
    .typing-indicator {
        margin: 0.5rem 1rem;
        padding: 0.375rem 0.75rem;
    }

    /* Mejorar overlay */
    body.chat-prompt-active::before {
        background: rgba(0, 0, 0, 0.7);
    }

    /* Estados de mensaje más compactos */
    .message-footer {
        margin-top: 2px;
        gap: 4px;
    }

    .message-status,
    .message-time {
        font-size: 0.6875rem;
    }

    /* Ajustes para iOS */
    @supports (-webkit-touch-callout: none) {
        .chat-window {
            height: -webkit-fill-available;
        }

        .chat-input {
            padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
        }
    }

    /* Mejoras de rendimiento */
    .chat-window {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        backface-visibility: hidden;
        perspective: 1000;
        will-change: transform;
    }

    /* Animaciones optimizadas para mobile */
    @keyframes messageIn {
        from {
            opacity: 0;
            transform: translateY(8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Gestos de scroll suaves */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Mejoras para íconos en mobile */
    @media (max-width: 480px) {
        /* Asegurar que los íconos SVG sean visibles y tengan el tamaño correcto */
        .contact-button svg,
        .header-action svg,
        .chat-input button svg,
        .close-chat svg {
            width: 22px;
            height: 22px;
            color: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
        }

        /* Ajustar el tamaño del botón de enviar para mejor tap target */
        .chat-input button svg {
            width: 20px;
            height: 20px;
            margin: auto;
        }

        /* Mejorar visibilidad del icono de adjuntar */
        .attach-button svg {
            width: 22px;
            height: 22px;
            stroke-width: 2;
            color: #919191;
        }

        /* Asegurar que los íconos en el header sean visibles */
        .header-action svg {
            color: white;
            opacity: 0.9;
        }

        /* Mejorar visibilidad del icono de cerrar */
        .close-chat svg {
            color: white;
            opacity: 0.9;
        }

        /* Ajustar icono de llamada en el header */
        .header-action.call-action svg {
            transform: scale(1.1);
            color: white;
        }

        /* Botones flotantes más visibles */
        .contact-button.chat-button svg,
        .contact-button.call-button svg {
            width: 24px;
            height: 24px;
            color: white;
        }

        /* Asegurar que los íconos estén centrados en sus contenedores */
        .contact-button,
        .header-action,
        .chat-input button,
        .close-chat,
        .attach-button {
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }

    /* Ajustes específicos para iOS */
    @supports (-webkit-touch-callout: none) {
        @media (max-width: 480px) {
            .contact-button svg,
            .header-action svg,
            .chat-input button svg,
            .close-chat svg {
                transform: translateZ(0);
                -webkit-transform: translateZ(0);
            }
        }
    }
}

/* Orientación landscape en móviles */
@media (max-width: 480px) and (orientation: landscape) {
    .chat-window {
        height: 100vh;
    }

    .chat-messages {
        padding: 0.75rem;
    }

    .chat-input {
        padding: 0.375rem 0.75rem;
    }

    .chat-message {
        max-width: 75%;
        margin-bottom: 0.375rem;
    }
}

/* Estilos para elementos de lista dentro de mensajes del chat */
.chat-message ul,
.chat-message ol {
    padding-left: 20px; /* Reduce default padding to keep bullets inside */
    margin: 0.5rem 0;
}

.chat-message li {
    margin-bottom: 0.25rem;
    position: relative;
}

/* Estilos especiales para listas en mensajes del sistema */
.chat-message.system ul,
.chat-message.system ol {
    padding-left: 20px; /* Padding más pequeño para los bullets */
    margin: 0.5rem 0;
}

.chat-message.system li {
    list-style-position: inside; /* Asegura que los bullets estén dentro */
    text-indent: -1em;
    padding-left: 1em;
}

/* Estilos para listas anidadas */
.chat-message li > ul,
.chat-message li > ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Corrección para formato HTML en general dentro de mensajes */
.chat-message .message-content {
    width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Asegurar que los enlaces en mensajes tengan el estilo correcto */
.chat-message.system .message-content a {
    color: var(--whatsapp-teal);
    text-decoration: none;
    font-weight: 500;
}

.chat-message.system .message-content a:hover {
    text-decoration: underline;
}

/* Indicador de Progreso de Scroll */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(to right, #53bdeb, #25D366);
    transition: width 0.2s ease-out;
    z-index: 1000;
}

.scroll-progress[data-progress]::after {
    content: attr(data-progress);
    position: absolute;
    right: 0;
    top: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transform: translateY(4px);
    opacity: 0;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

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

/* Mejorar transiciones del widget */
.chat-window {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
}

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

.chat-window.centered {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 20px));
    margin: 0;
}

.chat-window.centered.active {
    transform: translate(-50%, -50%);
}

/* Ajustar overlay para mejor contraste */
body.chat-prompt-active::before {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

#contact-widget-mount, .contact-widget {
    position: fixed !important;
    z-index: 10002 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    right: 2rem !important;
    bottom: 2rem !important;
}

/* Estilos para la hora y estado de mensajes tipo WhatsApp */
.message-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    justify-content: flex-end;
    font-size: 0.78em;
    opacity: 0.7;
    min-height: 18px;
    padding-right: 2px;
}

.chat-message.user .message-footer {
    justify-content: flex-end;
    flex-direction: row-reverse;
    gap: 6px;
}

.chat-message.system .message-footer {
    justify-content: flex-start;
    gap: 6px;
}

.message-time {
    font-size: 0.78em;
    color: #555; /* Antes: #888 */
    margin-left: 2px;
    margin-right: 2px;
    letter-spacing: 0.1px;
    min-width: 36px;
    text-align: right;
    opacity: 0.85; /* Antes: 0.7 */
}

.chat-message.user .message-time {
    color: #3a4a4a; /* Antes: #6b7a7a */
    text-align: right;
    opacity: 0.9;
}

.chat-message.system .message-time {
    color: #7a7a7a; /* Antes: #b0b0b0 */
    text-align: left;
    opacity: 0.85;
}

.message-status {
    font-size: 0.78em;
    margin-left: 2px;
    margin-right: 2px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 0.8;
    vertical-align: middle;
    min-width: 18px;
}

.message-status.sent::after {
    content: "✓";
    color: #b0b0b0;
    font-size: 1em;
    margin-left: 1px;
}

.message-status.delivered::after {
    content: "✓✓";
    color: #b0b0b0;
    font-size: 1em;
    margin-left: 1px;
}

.message-status.read::after {
    content: "✓✓";
    color: #25D366;
    font-size: 1em;
    margin-left: 1px;
    font-weight: bold;
}

.message-status.error::after {
    content: "!";
    color: #e74c3c;
    font-size: 1em;
    margin-left: 1px;
    font-weight: bold;
}

.message-status {
    cursor: pointer;
    transition: color 0.2s;
}
.message-status:hover {
    color: #25D366;
}

.message-footer .message-status {
    margin-left: 0;
    margin-right: 4px;
}

.chat-message.system .message-status {
    display: none;
}

/* Typing Indicator Styles */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: var(--whatsapp-bubble);
    border-radius: 7.5px;
    border-bottom-left-radius: 4px;
    max-width: 85%;
    margin-right: auto;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2; /* Mayor que los mensajes normales */
}

.typing-indicator.active {
    opacity: 1;
    transform: translateY(0);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

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

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

.typing-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Add typing indicator text for better UX */
.typing-indicator::before {
    content: attr(data-agent-name);
    font-size: 0.75rem;
    color: #666;
    margin-right: 8px;
    font-style: italic;
}

/* Ensure typing indicator appears above other elements */
.chat-messages .typing-indicator {
    position: relative;
    z-index: 2;
}