/* ======== CHAT WIDGET STYLES ======== */
#chat-widget-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
}

#chat-icon {
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease-in-out;
}
#chat-icon:hover {
    transform: scale(1.1);
    background-color: var(--primary-hover);
}

#notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
}

#chat-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 450px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: slideIn 0.3s ease-out;
}

.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.4;
}
.message.sent {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.message.received {
    background-color: var(--border-color);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.message .timestamp {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid var(--border-color);
}
.chat-input-area textarea {
    flex-grow: 1;
    border: none;
    resize: none;
    padding: 10px;
    font-family: var(--font-family);
    font-size: 15px;
}
.chat-input-area textarea:focus {
    outline: none;
}
.chat-input-area button {
    width: 45px;
    border-radius: 8px;
    flex-shrink: 0;
}


/* ======== ADMIN CHAT STYLES ======== */
#admin-chat-container {
    display: flex;
    height: calc(100vh - 150px);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

#user-list-panel {
    width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#user-list {
    overflow-y: auto;
    flex-grow: 1;
}
.user-entry {
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-entry:hover, .user-entry.active {
    background-color: #F7F8FA;
}
.user-entry .status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-light); /* Offline by default */
}
.user-entry .status-indicator.online {
    background-color: var(--success-color);
}
.user-entry .unread-badge {
    margin-left: auto;
    background-color: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
}

#chat-panel-admin {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#broadcast-btn {
    padding: 8px 12px;
    font-size: 14px;
}

@media (max-width: 768px) {
    #admin-chat-container {
        flex-direction: column;
        height: auto;
    }
    #user-list-panel {
        width: 100%;
        height: 250px; /* Fixed height for user list on mobile */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    #chat-popup {
        width: calc(100vw - 40px);
    }
}