/* ChatGPT-Style Chat Interface */

.chat-container {
    display: flex;
    height: calc(100vh - 60px - 60px);
    background: #fff;
    color: #000;
    position: relative;
}

/* Chat List Sidebar */
.chat-list-sidebar {
    width: 360px;
    background: #f7f7f8;
    border-right: 1px solid #e5e5ea;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.chat-list-sidebar.hidden-mobile {
    transform: translateX(-100%);
}

.chat-list-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5ea;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.chat-list-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #000;
}

.refresh-btn {
    background: rgba(90, 200, 250, 0.1);
    border: 1px solid rgba(90, 200, 250, 0.3);
    color: #5AC8FA;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: rgba(90, 200, 250, 0.2);
    transform: rotate(180deg);
}

.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
}

.chat-room-item {
    display: flex;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #e5e5ea;
}

.chat-room-item:hover {
    background: #e5e5ea;
}

.chat-room-item.active {
    background: #e8f5fe;
    border-left: 3px solid #5AC8FA;
}

.room-avatar-container {
    position: relative;
    margin-right: 15px;
    flex-shrink: 0;
}

.room-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.online-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #34c759;
    border-radius: 50%;
    border: 3px solid #f7f7f8;
    opacity: 0;
    transition: opacity 0.3s;
}

.online-dot.online {
    opacity: 1;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.room-name {
    font-weight: 600;
    font-size: 16px;
    color: #000;
}

.room-time {
    font-size: 12px;
    color: #8e8e93;
}

.room-last-message-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-last-message {
    font-size: 14px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.unread-badge {
    background: #5AC8FA;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    padding: 0 6px;
    margin-left: 8px;
}

.no-chats,
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
    color: #8e8e93;
}

.no-chats i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Chat Window */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
}

.no-chat-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
}

.no-chat-selected i {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.no-chat-selected h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
}

.no-chat-selected p {
    margin: 0;
    font-size: 14px;
}

/* Active Chat */
.active-chat {
    flex: 1;
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px 20px;
    background: #f7f7f8;
    border-bottom: 1px solid #e5e5ea;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 100px;
}

.back-to-list-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: #000;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    display: none;
}

.chat-participants {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.participant-avatar-container {
    position: relative;
}

.participant-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.participant-avatar-container .online-dot {
    bottom: 0;
    right: 0;
}

.participant-info {
    text-align: center;
}

.participant-name {
    font-weight: 600;
    font-size: 18px;
    color: #000;
    display: block;
    margin-bottom: 4px;
}

.participant-status {
    font-size: 13px;
    color: #8e8e93;
    display: block;
}

.participant-status.online {
    color: #34c759;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
}

.message-group {
    display: flex;
    gap: 10px;
    max-width: 70%;
}

.message-group.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    align-self: flex-end;
}

.message-group.sent .message-avatar {
    display: none;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 100%;
}

.message-group.received .message-bubble {
    background: #E5E5EA;
    color: #000;
    border-bottom-left-radius: 4px;
}

.message-group.sent .message-bubble {
    background: #5AC8FA;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-sender-name {
    font-weight: 600;
    font-size: 13px;
    color: #8e8e93;
    margin-bottom: 4px;
}

.message-group.sent .message-sender-name {
    display: none;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

.message-status i {
    font-size: 14px;
}

.message-status.read {
    color: #60a5fa;
}

.system-message {
    text-align: center;
    margin: 20px 0;
}

.system-message-bubble {
    display: inline-block;
    background: rgba(90, 200, 250, 0.1);
    color: #5AC8FA;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
}

/* Typing Indicator */
.typing-indicator-container {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #E5E5EA;
    border-radius: 16px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #8e8e93;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 13px;
    color: #34c759;
    font-style: italic;
}

/* Message Input */
.message-input-container {
    padding: 20px 20px 24px 20px;
    background: #fff;
    border-top: 1px solid #e5e5ea;
}

.message-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #f7f7f8;
    border-radius: 26px;
    padding: 6px 6px 6px 18px;
    border: 1px solid #e5e5ea;
    transition: all 0.3s ease;
}

.message-input-wrapper:focus-within {
    border-color: #5AC8FA;
    background: #fff;
    box-shadow: 0 2px 8px rgba(90, 200, 250, 0.15);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 0;
    color: #000;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

#messageInput::placeholder {
    color: #8e8e93;
}

.send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: #5AC8FA;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: #4AB8EA;
    transform: scale(1.08);
}

.send-btn:active {
    transform: scale(0.92);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #c7c7cc;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-list-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        width: 100%;
    }

    .back-to-list-btn {
        display: block;
    }

    .message-group {
        max-width: 85%;
    }
}