@import "../theme.css";

body {
    height: 100vh;
    overflow: hidden;
    padding-top: 80px; /* Space for fixed nav */
    background: var(--bg);
}

#chat-wrapper {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    height: calc(100vh - 100px);
    padding: 0 20px 20px;
}

/* Sidebar Styling */
.sidebar {
    background: var(--panel);
    border: var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.friend-requests {
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: var(--border);
}

.friend-requests h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 12px;
}

#sidebar_friends {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-2);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

.contact:hover {
    border-color: var(--accent);
    background: var(--panel-2);
}

.contact .last-message {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* Chat Area Layout */
.chat-area {
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--panel);
    border: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-header {
    padding: 16px 24px;
    background: var(--bg-2);
    border-bottom: var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

#chatTitle {
    font-weight: 700;
    font-size: 1.2rem;
}

.message-container {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-bubble {
    max-width: 65%;
    padding: 12px 16px;
    background: var(--bg-2);
    border: var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message-bubble.self {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
    border-color: transparent;
}

/* Form Styles */
.message-input-container {
    padding: 20px 24px;
    background: var(--bg-2);
    border-top: var(--border);
}

.message-form {
    display: flex;
    gap: 12px;
}

.message-input {
    flex: 1;
}

.unread {
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 10050;
}

.modal-content {
    background: var(--panel);
    border: var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

#friendSelection {
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-2);
}

#groupMembers {
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-2);
}

.group-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    #chat-wrapper {
        grid-template-columns: 1fr;
        padding: 0 12px 12px;
    }
    .sidebar {
        display: none;
    }
    .chat-area.active .sidebar {
        display: none;
    }
    .message-bubble {
        max-width: 85%;
    }
}
