.dm-button {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #222;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    margin-left: 0.5rem;
}

.dm-button:hover {
    background: #444;
}

/* Chat Layout */

.messages-page {
    display: flex;
    gap: 1rem;
    width: 90%;
    margin: 2rem auto;
}

.messages-sidebar {
    width: 25%;
    max-width: 260px;
    background: #111;
    border-radius: 8px;
    padding: 1rem;
}

.messages-sidebar h2 {
    margin-top: 0;
}

.contact-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.contact-list li {
    margin-bottom: 0.5rem;
}

.contact-list li a {
    color: #fff;
    text-decoration: none;
    display: block;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
}

.contact-list li.active a,
.contact-list li a:hover {
    background: #222;
}

.messages-main {
    flex: 1;
    background: #111;
    border-radius: 8px;
    padding: 1rem;
}

.messages-thread {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.message-row {
    margin-bottom: 0.5rem;
    display: flex;
}

.message-row.from-me {
    justify-content: flex-end;
}

.message-row.from-them {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    background: #222;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-size: 14px;
    word-wrap: break-word;
    word-break: break-word;
}

.message-row.from-me .message-bubble {
    background: #345;
    border-bottom-right-radius: 2px;
}

.message-row.from-them .message-bubble {
    border-bottom-left-radius: 2px;
}

.message-meta {
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
}

.message-form textarea {
    width: 100%;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.message-form button {
    padding: 0.4rem 0.8rem;
}

/* Grundsätzlich: Chat-Container nie breiter als der Screen */
.messages-page,
.messages-sidebar,
.messages-main {
    max-width: 100%;
    box-sizing: border-box;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #222;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-weight: 600;
    font-size: 15px;
}

.chat-header-sub {
    font-size: 12px;
    opacity: 0.7;
}

/* Tablet / bis 768px */
@media (max-width: 768px) {

    .messages-page {
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        padding: 0 10px;
        overflow-x: hidden;
    }

    .messages-sidebar {
        width: 100%;
        max-width: 100%;
        margin-bottom: 15px;
    }

    .messages-main {
        width: 100%;
        max-width: 100%;
    }

    .messages-thread {
        max-height: 350px;
    }

    /* Chat-Bubbles flexibler machen */
    .message-bubble {
        max-width: 90%;
    }
}

/* Very small phones / bis 480px */
@media (max-width: 480px) {

    .messages-page {
        padding: 0 5px;
        overflow-x: hidden;
    }

    .messages-thread {
        max-height: 300px;
        padding: 0 2px;
    }

    .message-bubble {
        max-width: 100%;
        font-size: 13px;
        padding: 0.4rem 0.5rem;
    }

    .message-meta {
        font-size: 10px;
    }

    .chat-header-avatar {
        width: 32px;
        height: 32px;
    }

    .chat-header-name {
        font-size: 14px;
    }

    .chat-header-sub {
        font-size: 11px;
    }
}
