
/* STUDENT HUB MESSAGES SIDEBAR */

#messagesToggle {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    background: #ffffff;
    color: #000000;
    border: none;
    border-radius: 50px;
    padding: 14px 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(255,255,255,0.3);
}

#messagesSidebar {
    position: fixed;
    top: 0;
    right: -370px;
    width: 350px;
    max-width: 90vw;
    height: 100vh;
    background: #101010;
    color: white;
    z-index: 9998;
    border-left: 1px solid #333;
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
}

#messagesSidebar.open {
    right: 0;
}

.messages-header {
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333;
}

.messages-header h2 {
    margin: 0;
}

.messages-close {
    background: none;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.messages-search {
    margin: 12px;
    padding: 11px;
    border-radius: 8px;
    border: 1px solid #444;
    background: #1d1d1d;
    color: white;
}

.messages-section-title {
    padding: 10px 15px 5px;
    color: #999;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
}

.messages-list {
    overflow-y: auto;
    flex: 1;
}

.message-conversation {
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid #222;
}

.message-conversation:hover {
    background: #252525;
}

.message-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.message-conversation-info {
    flex: 1;
    min-width: 0;
}

.message-conversation-info strong {
    display: block;
    margin-bottom: 4px;
}

.message-preview {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-unread {
    background: white;
    color: black;
    border-radius: 20px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: bold;
}

#messagesChat {
    position: fixed;
    right: 370px;
    bottom: 20px;
    width: 350px;
    max-width: calc(100vw - 30px);
    height: 480px;
    max-height: 75vh;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 12px;
    z-index: 9997;
    display: none;
    flex-direction: column;
    box-shadow: 0 0 25px rgba(0,0,0,0.5);
}

#messagesChat.open {
    display: flex;
}

.messages-chat-header {
    padding: 13px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#messagesChatHistory {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    background: #292929;
    overflow-wrap: anywhere;
}

.message-bubble.mine {
    align-self: flex-end;
    background: #eeeeee;
    color: #111;
}

.message-sender {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 4px;
}

.message-bubble.mine .message-sender {
    color: #555;
}

.message-time {
    font-size: 10px;
    opacity: 0.65;
    margin-top: 5px;
}

.messages-compose {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #333;
}

#messagesInput {
    flex: 1;
    min-width: 0;
    padding: 11px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #222;
    color: white;
}

#messagesSend {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: white;
    color: black;
    font-weight: bold;
    cursor: pointer;
}

.messages-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

@media (max-width: 600px) {
    #messagesChat {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        height: 65vh;
    }

    #messagesSidebar {
        width: 100%;
        max-width: 100%;
        right: -100%;
    }

    #messagesSidebar.open {
        right: 0;
    }
}

#messagesSidebar .messages-new-message:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.messages-group-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.messages-group-overlay[hidden] {
    display: none;
}

.messages-group-popup {
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    background: #101010;
    color: white;
    border: 1px solid #444;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 0 25px rgba(255,255,255,0.12);
}

.messages-group-popup label {
    display: block;
    margin-bottom: 12px;
}

.messages-group-popup label input:not([type="checkbox"]) {
    display: block;
    width: 100%;
    margin-top: 8px;
}

.messages-group-popup .messages-friends-list {
    max-height: 220px;
    overflow-y: auto;
    margin: 12px 0;
}

.messages-group-popup .messages-friend {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.messages-group-popup .messages-friend input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: white;
}

.messages-group-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.messages-group-actions button {
    flex: 1;
}

.messages-group-popup .messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

/* Group management */
.messages-member-remove {
    margin-left: auto;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 6px 10px;
    background: #222;
    color: #fff;
    cursor: pointer;
}

.messages-member-remove:hover {
    background: #444;
}

#messagesChat .messages-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

#messagesChat .messages-chat-header strong {
    flex: 1;
}

#messagesChat .messages-chat-header button {
    flex-shrink: 0;
}

.messages-group-popup h3 {
    margin: 16px 0 8px;
    font-size: 15px;
}

.messages-group-popup label {
    display: block;
    margin-bottom: 6px;
}

.messages-group-popup input:disabled {
    opacity: 0.6;
}

.messages-group-popup .messages-friends-list {
    max-height: 180px;
    overflow-y: auto;
}

.messages-group-popup button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.messages-group-popup [hidden] {
    display: none !important;
}

@media (max-width: 600px) {
    #messagesChat .messages-chat-header {
        flex-wrap: wrap;
    }

    #messagesChat .messages-chat-header button {
        font-size: 12px;
    }
}
