/* =========================================================
   Estilos para Chat Flotante estilo Facebook
   ========================================================= */

/* 1. BARRA LATERAL DERECHA (Sidebar Right) */
.sidebar-chat-right {
    position: fixed;
    right: 0;
    top: 70px;
    /* Ajuste para no tapar header si existe */
    bottom: 0px;
    width: 80px;
    /* Ancho para mostrar solo iconos/avatars */
    background-color: transparent;
    border-left: 1px solid transparent;
    display: none;
    /* Se activa con JS o media query en Desktop */
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    /* Align to bottom */
    padding-top: 10px;
    padding-bottom: 20px;
    z-index: 900;
    transition: width 0.3s ease;
    /* Ocultar scrollbar pero permitir scroll */
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar-chat-right::-webkit-scrollbar {
    display: none;
}

@media (min-width: 969px) {
    .sidebar-chat-right {
        display: flex;
    }
}

/* Items de conversación en la barra lateral */
.chat-sidebar-item {
    position: relative;
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s;
}

.chat-sidebar-item:hover {
    transform: scale(1.05);
}

.chat-sidebar-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 2px solid white;
}

/* Badge de mensajes no leídos en sidebar */
.chat-sidebar-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ff4757;
    color: white;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1px solid white;
    font-weight: bold;
}

/* Botón flotante eliminar item */
.chat-sidebar-remove {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 20px;
    height: 20px;
    background: rgba(100, 100, 100, 0.8);
    color: white;
    border-radius: 50%;
    font-size: 16px;
    display: none;
    /* Show on hover */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    font-family: Arial, sans-serif;
}

.chat-sidebar-item:hover .chat-sidebar-remove {
    display: flex;
}

.chat-sidebar-remove:hover {
    background: #ff4757;
}

/* Botón flotante inferior de mensajes (El icono principal) */
.chat-sidebar-main-btn {
    margin-top: 10px;
    width: 50px;
    height: 50px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    /* Reset padding to prevent icon squishing */
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    /* Sombra más fuerte */
    position: relative;
    border: 1px solid #e0e0e0;
    /* Borde sutil */
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: visible;
}

.chat-sidebar-main-btn:hover {
    transform: scale(1.05);
    background-color: #f0f2f5;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.chat-sidebar-main-btn svg {
    width: 40px !important;
    height: 40px !important;
}

/* Forzar color del icono por si acaso */
.chat-sidebar-main-btn svg path,
.chat-sidebar-main-btn svg circle {
    stroke: #65676b !important;
    /* Color gris oscuro Facebook */
    fill: none;
}

.chat-sidebar-main-btn svg circle {
    fill: #65676b !important;
    stroke: none !important;
}

/* 2. DOCK INFERIOR PARA VENTANAS DE CHAT */
.chat-dock-container {
    position: fixed;
    bottom: 0;
    right: 90px;
    /* Offset para no tapar la sidebar */
    height: 0;
    /* Altura 0 para no bloquear clicks, los hijos tendrán altura */
    display: flex;
    flex-direction: row-reverse;
    /* Alineados a la derecha */
    align-items: flex-end;
    /* Alineados abajo */
    gap: 10px;
    /* Espacio entre ventanas */
    z-index: 2147483647;
    pointer-events: none;
    /* Permitir clicks a través del contenedor vacío */
}

/* Ventana de chat individual */
.chat-window {
    width: 320px;
    height: 400px;
    background: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    /* Habilitar clicks */
    transition: height 0.3s ease;
    border: 1px solid #ddd;
    border-bottom: none;
}

.chat-window.minimized {
    height: 48px;
    /* Solo cabecera */
}

/* Cabecera del chat */
.chat-window-header {
    height: 48px;
    background: #7ab320;
    /* Color Loliando principal */
    color: white;
    padding: 0 10px;
    display: flex;
    align-items: center;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    justify-content: space-between;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 auto;
    /* No expandir */
    overflow: hidden;
    max-width: 70%;
    /* Limitar ancho */
}

.chat-header-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid white;
}

.chat-header-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions {
    display: flex;
    gap: 5px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

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

/* Cuerpo de mensajes */
.chat-window-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mensajes individuales (reutilizando estilos simples por ahora) */
.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg.sent {
    align-self: flex-end;
    background: #dcf8c6;
    /* Verde tipo WhatsApp */
    color: #333;
    border-bottom-right-radius: 2px;
}

.chat-msg.received {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 2px;
    border: 1px solid #eee;
}

/* Footer (Input) */
.chat-window-footer {
    padding: 8px;
    border-top: 1px solid #ddd;
    background: white;
    display: flex;
    gap: 6px;
}

.chat-input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 18px;
    padding: 6px 12px;
    font-size: 13px;
    outline: none;
    resize: none;
    height: 32px;
    /* Altura inicial */
    line-height: 18px;
}

.chat-input:focus {
    border-color: #7ab320;
}

.chat-options-btn {
    background: none;
    border: none;
    color: #7ab320;
    cursor: pointer;
    font-size: 16px;
}

/* Placeholder para cuando no hay avatar */
.chat-avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #999;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}