/* ============================================
   MESSENGER - Chat flotante
   ============================================ */

/* Botón de la navbar */
.nav-messenger-btn {
    position: relative;
}

.nav-messenger-btn svg {
    transition: all 0.3s ease;
    color: #ec4899;
}

.nav-messenger-btn:hover svg {
    transform: scale(1.1);
    color: #f472b6;
}

.nav-messenger-btn:hover {
    color: #f472b6;
}

/* Cuando el chat está abierto */
.nav-messenger-btn.active {
    color: #db2777;
}

.nav-messenger-btn.active svg {
    color: #db2777;
}

/* Cuando hay mensajes no leídos */
.nav-messenger-btn.has-unread svg {
    color: #f472b6;
    filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.6));
}

/* Container principal - esquina inferior derecha */
.messenger-container {
    position: fixed;
    bottom: 70px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* IMPORTANTE: No capturar eventos cuando el chat está cerrado */
    pointer-events: none;
}

/* Solo el widget visible debe capturar eventos */
.messenger-container .messenger-widget:not(.hidden),
.messenger-container .messenger-collapsed-tab {
    pointer-events: auto;
}

/* Estado colapsado - solo línea visible */
.messenger-collapsed-tab {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 200px;
    height: 6px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.messenger-collapsed-tab:hover {
    height: 30px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
}

.messenger-collapsed-tab:hover::after {
    content: 'Abrir Chat';
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.messenger-collapsed-tab .unread-badge {
    position: absolute;
    top: -8px;
    right: 10px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Widget principal del chat */
.messenger-widget {
    width: 480px;
    height: 500px;
    background: #1a1a2e;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -5px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    transform: translateY(0);
}

.messenger-widget.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   NOTIFICACIÓN GLOBO - Mensajes no leídos
   Globo flotante con cuerda anclada al icono
   ============================================ */
.messenger-balloon {
    position: fixed;
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    width: 60px;
}

.messenger-balloon.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Conjunto globo + cuerda que se balancea desde el punto de anclaje */
.messenger-balloon .balloon-assembly {
    position: relative;
    /* El punto de pivote está al final de la cuerda (donde se conecta al icono) */
    transform-origin: 50% 100%;
    animation: balloon-sway 3s ease-in-out infinite;
}

/* El globo */
.messenger-balloon .balloon {
    width: 60px;
    height: 72px;
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 50%, #db2777 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset -8px -4px 20px rgba(0, 0, 0, 0.15),
        inset 8px 8px 20px rgba(255, 255, 255, 0.3),
        0 8px 30px rgba(236, 72, 153, 0.4);
}

/* Brillo del globo */
.messenger-balloon .balloon::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 20px;
    background: linear-gradient(135deg, rgba(255,255,255,0.6) 0%, transparent 100%);
    border-radius: 50%;
    top: 12px;
    left: 12px;
}

/* Nudo del globo */
.messenger-balloon .balloon::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid #db2777;
}

/* Número dentro del globo */
.messenger-balloon .balloon-count {
    font-size: 26px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1;
    margin-top: -8px;
}

/* Texto curvado "mensajes" */
.messenger-balloon .balloon-text {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.messenger-balloon .balloon-text text {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* La cuerda - línea simple que sale del nudo */
.messenger-balloon .balloon-string {
    width: 2px;
    height: 70px;
    background: linear-gradient(to bottom, #d1d5db, #9ca3af);
    margin: 0 auto;
    border-radius: 1px;
}

/* Animación de balanceo - pivotea desde el punto de anclaje inferior */
@keyframes balloon-sway {
    0%, 100% {
        transform: rotate(-4deg);
    }
    50% {
        transform: rotate(4deg);
    }
}

/* Animación de elevarse (aparecer desde el borde inferior de la ventana) */
@keyframes balloon-rise {
    0% {
        transform: translateY(100vh);
        opacity: 1;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Animación de hundirse (desaparecer hacia el borde inferior de la ventana) */
@keyframes balloon-sink {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 1;
    }
}

/* Estados de animación del globo */
.messenger-balloon.rising {
    animation: balloon-rise 2s ease-out forwards;
}

.messenger-balloon.sinking {
    animation: balloon-sink 2s ease-in forwards;
}

/* Animación de entrada */
.messenger-balloon.appearing .balloon {
    animation: balloon-appear 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes balloon-appear {
    0% {
        opacity: 0;
        transform: scale(0) translateY(50px);
    }
    60% {
        opacity: 1;
        transform: scale(1.2) translateY(-10px);
    }
    80% {
        transform: scale(0.9) translateY(5px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

/* Animación de salida */
.messenger-balloon.disappearing .balloon {
    animation: balloon-disappear 0.5s ease-in forwards;
}

@keyframes balloon-disappear {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) translateY(-30px);
    }
}

/* Hover en el globo */
.messenger-balloon .balloon:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow:
        inset -8px -4px 20px rgba(0, 0, 0, 0.15),
        inset 8px 8px 20px rgba(255, 255, 255, 0.3),
        0 15px 40px rgba(236, 72, 153, 0.5);
}

/* Pulso cuando hay muchos mensajes */
.messenger-balloon.many-messages .balloon {
    animation: balloon-pulse 1s ease-in-out infinite;
}

@keyframes balloon-pulse {
    0%, 100% {
        box-shadow:
            inset -8px -4px 20px rgba(0, 0, 0, 0.15),
            inset 8px 8px 20px rgba(255, 255, 255, 0.3),
            0 8px 30px rgba(236, 72, 153, 0.4);
    }
    50% {
        box-shadow:
            inset -8px -4px 20px rgba(0, 0, 0, 0.15),
            inset 8px 8px 20px rgba(255, 255, 255, 0.3),
            0 8px 40px rgba(236, 72, 153, 0.7),
            0 0 60px rgba(244, 114, 182, 0.4);
    }
}

/* Layout de 2 columnas */
.messenger-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.messenger-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* Barra toggle del sidebar */
.sidebar-toggle {
    width: 16px;
    background: #1e1e3a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-toggle:hover {
    background: #2a2a4a;
}

.sidebar-toggle .toggle-arrow {
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.3s;
}

.sidebar-toggle:hover .toggle-arrow {
    color: white;
}

.sidebar-toggle.collapsed .toggle-arrow {
    transform: rotate(180deg);
}

/* Sidebar de usuarios online */
.messenger-sidebar {
    width: 120px;
    display: flex;
    flex-direction: column;
    background: #16162a;
    transition: width 0.3s, opacity 0.3s;
    overflow: hidden;
}

.messenger-sidebar.hidden {
    width: 0;
    opacity: 0;
    border: none;
}

/* Widget más pequeño cuando sidebar está oculto */
.messenger-widget.sidebar-collapsed {
    width: 360px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

.sidebar-count {
    background: #22c55e;
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.sidebar-empty {
    padding: 20px 10px;
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
}

/* Usuario online compacto (solo nombre) */
.online-user-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.online-user-compact:hover {
    background: rgba(99, 102, 241, 0.2);
}

.online-user-compact.is-me {
    background: rgba(99, 102, 241, 0.1);
    cursor: default;
}

.online-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse-dot 2s infinite;
}

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

.online-name {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-user-compact.is-me .online-name {
    color: #a5b4fc;
}

.device-icon {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.device-icon svg {
    width: 12px;
    height: 12px;
}

/* Header del chat */
.messenger-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    flex-shrink: 0;
}

.messenger-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.messenger-header-title {
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.messenger-online-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.messenger-header-actions {
    display: flex;
    gap: 8px;
}

.messenger-header-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* Botón de zumbido */
#btnBuzz {
    background: rgba(236, 72, 153, 0.3);
}

#btnBuzz:hover {
    background: rgba(236, 72, 153, 0.5);
}

#btnBuzz.buzzing {
    animation: buzz-shake 0.5s ease-in-out;
    background: rgba(236, 72, 153, 0.7);
}

@keyframes buzz-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-3px) rotate(-5deg); }
    40% { transform: translateX(3px) rotate(5deg); }
    60% { transform: translateX(-3px) rotate(-5deg); }
    80% { transform: translateX(3px) rotate(5deg); }
}

.messenger-header-btn svg {
    width: 16px;
    height: 16px;
}

/* Tabs de navegación */
.messenger-tabs {
    display: flex;
    background: #16162a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.messenger-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.messenger-tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
}

.messenger-tab.active {
    color: white;
    background: rgba(99, 102, 241, 0.2);
}

.messenger-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #6366f1;
}

.messenger-tab .tab-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
}

/* Contenido principal */
.messenger-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.messenger-panel {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
}

.messenger-panel.active {
    display: flex;
}

/* Lista de usuarios online */
.online-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.online-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.online-user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.online-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

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

.online-user-avatar .status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid #1a1a2e;
    border-radius: 50%;
}

.online-user-info {
    flex: 1;
    min-width: 0;
}

.online-user-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-user-page {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
}

.online-user-actions {
    display: flex;
    gap: 4px;
}

.user-action-btn {
    background: rgba(99, 102, 241, 0.2);
    border: none;
    color: #a5b4fc;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.user-action-btn:hover {
    background: rgba(99, 102, 241, 0.4);
    color: white;
}

/* Chat global */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-user-select: text;
    user-select: text;
}

.chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: message-in 0.3s ease;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

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

.chat-message-content {
    background: #262640;
    padding: 8px 12px;
    border-radius: 12px;
    border-top-left-radius: 4px;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

.chat-message.own .chat-message-content {
    background: #4f46e5;
    border-radius: 12px;
    border-top-right-radius: 4px;
}

/* Mensajes de zumbido - estilo especial */
.chat-message.buzz-message .chat-message-content {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    border: 1px solid rgba(236, 72, 153, 0.4);
    animation: buzz-glow 2s ease-in-out;
}

.chat-message.buzz-message .chat-message-text {
    font-weight: 500;
}

@keyframes buzz-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(236, 72, 153, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(236, 72, 153, 0.6);
    }
}

.chat-message-sender {
    font-size: 11px;
    color: #a5b4fc;
    margin-bottom: 2px;
    font-weight: 500;
}

.chat-message.own .chat-message-sender {
    display: none;
}

.chat-message-text {
    color: white;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
    text-align: right;
}

/* Mensajes que solo contienen emojis - fondo transparente */
.chat-message.emoji-only .chat-message-content {
    background: transparent;
    padding: 4px 0;
}

.chat-message.emoji-only .chat-message-text {
    font-size: 32px;
    line-height: 1.2;
}

.chat-message.emoji-only.own .chat-message-content {
    background: transparent;
}

.chat-message.emoji-only .chat-message-time {
    color: rgba(255, 255, 255, 0.3);
}

/* Input de mensaje */
.chat-input-container {
    padding: 12px;
    background: #16162a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: #262640;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #6366f1;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-send-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Chat header privado */
.private-chat-header {
    padding: 12px;
    background: #16162a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.private-chat-back {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
}

.private-chat-back:hover {
    color: white;
}

.private-chat-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

/* Alertas flotantes */
.messenger-alerts {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
    pointer-events: none;
}

.messenger-alert {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: alert-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    border-left: 4px solid #6366f1;
}

.messenger-alert.login {
    border-left-color: #22c55e;
    width: fit-content;
    padding: 8px 14px;
}

.messenger-alert.logout {
    border-left-color: #f59e0b;
    width: fit-content;
    padding: 8px 14px;
}

.messenger-alert.broadcast {
    border-left-color: #ef4444;
}

@keyframes alert-in {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.messenger-alert.removing {
    animation: alert-out 0.3s ease forwards;
}

@keyframes alert-out {
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.alert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.alert-title {
    color: white;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 2px;
}

.alert-close:hover {
    color: white;
}

.alert-message {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    line-height: 1.4;
}

.alert-time {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    margin-top: 8px;
}

/* Enviar alerta modal */
.alert-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.alert-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.alert-modal-content {
    background: #1a1a2e;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.alert-modal.active .alert-modal-content {
    transform: scale(1);
}

.alert-modal-title {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.alert-form-group {
    margin-bottom: 16px;
}

.alert-form-label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-bottom: 6px;
}

.alert-form-input,
.alert-form-select,
.alert-form-textarea {
    width: 100%;
    background: #262640;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    color: white;
    font-size: 14px;
    outline: none;
}

.alert-form-textarea {
    min-height: 80px;
    resize: vertical;
}

.alert-form-input:focus,
.alert-form-select:focus,
.alert-form-textarea:focus {
    border-color: #6366f1;
}

.alert-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.alert-modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.alert-modal-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
}

.alert-modal-btn.send {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
}

.alert-modal-btn:hover {
    transform: translateY(-1px);
}

/* Conversaciones */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.conversation-item.unread {
    background: rgba(99, 102, 241, 0.1);
}

.conversation-preview {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.conversation-last-msg {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    text-align: right;
}

.conversation-time {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
}

.conversation-unread {
    background: #6366f1;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 4px;
    display: inline-block;
}

/* Scrollbar personalizado */
.messenger-widget ::-webkit-scrollbar {
    width: 6px;
}

.messenger-widget ::-webkit-scrollbar-track {
    background: transparent;
}

.messenger-widget ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.messenger-widget ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 20px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 13px;
}

/* Lista de usuarios online en sidebar */
.messenger-sidebar .online-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Responsive */
@media (max-width: 560px) {
    .messenger-container {
        right: 0;
    }

    .messenger-widget {
        width: 100vw;
        height: 70vh;
        border-radius: 16px 16px 0 0;
    }

    .messenger-sidebar {
        width: 100px;
    }

    .messenger-collapsed-tab {
        right: 0;
        width: 100%;
        border-radius: 0;
    }

    .messenger-alerts {
        right: 10px;
        left: 10px;
        width: auto;
    }
}

@media (max-width: 400px) {
    .messenger-sidebar {
        width: 80px;
    }

    .online-name {
        font-size: 10px;
    }
}

/* Sistema de tipeo */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

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

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

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

/* ============================================
   MODAL DE CONFIGURACIÓN
   ============================================ */

.settings-modal-content {
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-modal-content .alert-modal-title {
    display: flex;
    align-items: center;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 4px;
    background: #16162a;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.settings-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.settings-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.settings-tab.active {
    color: white;
    background: #6366f1;
}

/* Settings Panels */
.settings-panel {
    display: none;
    min-height: 200px;
}

.settings-panel.active {
    display: block;
}

.settings-group {
    margin-bottom: 16px;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 0;
}

.settings-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6366f1;
    cursor: pointer;
}

.settings-label-block {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-bottom: 8px;
}

/* Settings List (blocked/muted users) */
.settings-list {
    max-height: 200px;
    overflow-y: auto;
}

.settings-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    padding: 30px;
}

.settings-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
}

.settings-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-user-info .online-user-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.settings-user-info span {
    color: white;
    font-size: 13px;
}

.settings-user-action {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.settings-user-action.unblock {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.settings-user-action.unblock:hover {
    background: rgba(34, 197, 94, 0.3);
}

.settings-user-action.unmute {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.settings-user-action.unmute:hover {
    background: rgba(99, 102, 241, 0.3);
}

/* Danger Zone */
.danger-zone {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 16px;
}

.danger-title {
    color: #ef4444;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.danger-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.danger-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: white;
}

/* ============================================
   HISTORIAL - Pestaña de borrar conversaciones
   ============================================ */

.history-section {
    margin-bottom: 20px;
}

.history-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-section-title svg {
    opacity: 0.7;
}

.history-delete-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: white;
}

.history-delete-btn.admin-btn {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.history-delete-btn.admin-btn:hover {
    background: rgba(245, 158, 11, 0.25);
    color: white;
}

.history-conversations-list {
    max-height: 180px;
    overflow-y: auto;
}

.history-conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.history-conversation-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.history-conv-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.history-conv-info .online-user-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
    flex-shrink: 0;
}

.history-conv-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.history-conv-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
}

.history-conv-preview {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-conv-delete {
    padding: 6px;
    background: rgba(239, 68, 68, 0.2);
    border: none;
    border-radius: 6px;
    color: #f87171;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.history-conv-delete:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

/* ============================================
   BOTÓN ELIMINAR MENSAJE
   ============================================ */

.chat-message {
    position: relative;
}

.message-delete-btn {
    position: absolute;
    top: 50%;
    right: -24px;
    transform: translateY(-50%);
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: #fca5a5;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.chat-message.own .message-delete-btn {
    right: auto;
    left: -24px;
}

.chat-message:hover .message-delete-btn {
    opacity: 1;
}

.message-delete-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

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

@keyframes message-out {
    to {
        opacity: 0;
        transform: translateX(20px);
        height: 0;
        padding: 0;
        margin: 0;
    }
}

/* ============================================
   DROPDOWN DE USUARIO
   ============================================ */

.user-action-dropdown {
    position: relative;
}

.user-action-dropdown .more-btn {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    min-width: 140px;
    padding: 4px;
    display: none;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.user-action-dropdown.open .dropdown-menu {
    display: block;
    animation: dropdown-in 0.2s ease;
}

@keyframes dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.dropdown-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-menu button.danger {
    color: #fca5a5;
}

.dropdown-menu button.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================
   BOTÓN ELIMINAR CONVERSACIÓN
   ============================================ */

.conversation-item {
    position: relative;
}

.conversation-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.conversation-delete-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: #fca5a5;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.conversation-item:hover .conversation-delete-btn {
    opacity: 1;
}

.conversation-delete-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

/* ============================================
   MENÚ CONTEXTUAL
   ============================================ */

.message-context-menu {
    position: fixed;
    display: none;
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    min-width: 150px;
    z-index: 10002;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    color: #fca5a5;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.messenger-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a2e;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(99, 102, 241, 0.3);
    z-index: 10003;
    opacity: 0;
    transition: all 0.3s ease;
}

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

/* ============================================
   ANIMACIÓN DE VIBRACIÓN
   ============================================ */

@keyframes messenger-vibrate {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-4px) rotate(-1deg); }
    20% { transform: translateX(4px) rotate(1deg); }
    30% { transform: translateX(-4px) rotate(-1deg); }
    40% { transform: translateX(4px) rotate(1deg); }
    50% { transform: translateX(-3px) rotate(-0.5deg); }
    60% { transform: translateX(3px) rotate(0.5deg); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

.messenger-widget.vibrating {
    animation: messenger-vibrate 0.6s ease-in-out;
    box-shadow: 0 -5px 40px rgba(239, 68, 68, 0.5);
}

/* Vibración del tab colapsado */
.messenger-collapsed-tab.vibrating {
    animation: messenger-vibrate 0.6s ease-in-out;
    background: linear-gradient(90deg, #ef4444, #f97316);
    height: 30px;
}

/* Vibración del botón navbar */
.nav-messenger-btn.vibrating svg {
    animation: messenger-vibrate 0.6s ease-in-out;
    color: #ef4444;
}

/* ============================================
   SELECCIÓN DE USUARIO ONLINE
   ============================================ */

.online-user-compact.selected {
    background: rgba(99, 102, 241, 0.4);
    border-left: 3px solid #6366f1;
}

.online-user-compact.selected .online-name {
    color: white;
    font-weight: 600;
}

/* Indicador de usuario seleccionado en header */
.selected-user-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    color: white;
    max-width: 120px;
}

.selected-user-indicator.active {
    display: flex;
}

.selected-user-indicator .selected-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-user-indicator .clear-selection {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    opacity: 0.7;
}

.selected-user-indicator .clear-selection:hover {
    opacity: 1;
}

/* Botón de alerta activo (usuario seleccionado) */
#btnSendAlert.has-target {
    background: rgba(34, 197, 94, 0.3);
    animation: pulse-alert-btn 1.5s infinite;
}

@keyframes pulse-alert-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* ============================================
   INDICADOR DE MENSAJES GLOBALES - Punto azul pulsante
   ============================================ */

.global-new-indicator {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 10px;
    height: 10px;
    background: #3b82f6;
    border-radius: 50%;
    border: 2px solid #0f172a;
    animation: global-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

.global-new-indicator.hidden {
    display: none;
}

@keyframes global-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 15px rgba(59, 130, 246, 0.9), 0 0 30px rgba(59, 130, 246, 0.4);
    }
}

/* ============================================
   TOAST PARA MENSAJES GLOBALES - Aparece abajo
   ============================================ */

.messenger-toast-global {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(59, 130, 246, 0.4);
    z-index: 10003;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
}

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

.messenger-toast-global .toast-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.messenger-toast-global .toast-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.messenger-toast-global .toast-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.messenger-toast-global .toast-title {
    font-weight: 600;
    font-size: 12px;
    color: #93c5fd;
}

.messenger-toast-global .toast-message {
    font-size: 13px;
    color: white;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messenger-toast-global .toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    transition: color 0.2s;
}

.messenger-toast-global .toast-close:hover {
    color: white;
}

/* Animación de entrada desde abajo */
@keyframes toast-slide-up {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.messenger-toast-global.appearing {
    animation: toast-slide-up 0.3s ease forwards;
}
