/* --- Message Dashboard Layout --- */
.mmd-message-dashboard {
    display: flex;
    background: #fff;
    border: 1px solid #e2e8f0; 
    border-radius: 12px; 
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    height: 650px; 
}

/* --- LINKE SPALTE: THREAD LISTE --- */
.mmd-thread-list-wrapper {
    width: 350px; 
    border-right: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    background: #fff;
    flex-shrink: 0;
}

.mmd-thread-header {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}
.mmd-thread-header h3 { 
    margin: 0; 
    font-size: 18px; 
    font-weight: 700; 
    color: #1e293b;
}

.mmd-thread-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.mmd-thread-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    position: relative;
    border-left: 3px solid transparent; 
}

.mmd-thread-item:hover { background-color: #f8fafc; }
.mmd-thread-item.active { background-color: #eff6ff; border-left-color: #2563eb; }
.mmd-thread-item.unread { background-color: #fff; }
.mmd-thread-item.unread .mmd-thread-name { font-weight: 700; color: #0f172a; }

/* AVATAR & ONLINE BADGE */
.mmd-avatar-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    margin-right: 15px;
    flex-shrink: 0;
}

.mmd-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.mmd-online-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #10b981; 
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
    z-index: 2;
    animation: mmd-pulse 2s infinite;
}

@keyframes mmd-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.mmd-thread-info { flex: 1; min-width: 0; }

.mmd-thread-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.mmd-thread-name { 
    font-size: 15px; 
    color: #334155; 
    font-weight: 600; 
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 
}

.mmd-thread-time {
    font-size: 11px; 
    color: #94a3b8; 
    margin-left: 5px; 
    white-space: nowrap;
}

.mmd-thread-listing {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-bottom: 4px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-decoration: none;
}
.mmd-thread-listing:hover { text-decoration: none; color: #2563eb; background: #e0f2fe; }

.mmd-thread-bottom { display: flex; justify-content: space-between; align-items: center; }

.mmd-thread-preview { 
    font-size: 13px; 
    color: #64748b; 
    white-space: nowrap; 
    overflow: hidden; text-overflow: ellipsis; 
    flex: 1;
}

.mmd-unread-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding: 0 5px;
}

/* --- RECHTE SPALTE: CHAT WINDOW --- */
.mmd-chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #fff;
    min-width: 0;
}

.mmd-chat-header {
    padding: 10px 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    display: flex;
    align-items: center;
    height: 70px;
    flex-shrink: 0;
    gap: 15px;
}

.mmd-mobile-back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    margin-left: -10px;
    border-radius: 50%;
    transition: background 0.2s;
}
.mmd-mobile-back-btn:hover { background: #f1f5f9; color: #1e293b; }

.mmd-chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

#mmd-chat-partner-name { 
    font-weight: 700; font-size: 16px; color: #1e293b; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#mmd-chat-listing-title {
    font-size: 12px; color: #64748b; line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Action Buttons */
.mmd-action-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}
.mmd-action-btn:hover { background: #fef2f2; }

/* Messages Area */
.mmd-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8fafc;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mmd-msg {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.mmd-msg.msg-them { 
    align-self: flex-start; 
    background: #fff; 
    color: #334155;
    border-bottom-left-radius: 4px;
}

.mmd-msg.msg-me { 
    align-self: flex-end; 
    background: #2563eb; 
    color: #fff;
    border-bottom-right-radius: 4px;
}

.mmd-msg-time { 
    display: block; font-size: 10px; margin-top: 4px; text-align: right; opacity: 0.8;
}

/* --- INPUT AREA --- */
.mmd-chat-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

#mmd-reply-form { display: flex; gap: 10px; align-items: flex-end; }

#mmd-reply-text {
    flex: 1; resize: none; padding: 12px 15px;
    border-radius: 20px; border: 1px solid #e2e8f0;
    background: #f8fafc; height: 46px; line-height: 1.4;
    font-family: inherit; transition: all 0.2s; outline: none;
}
#mmd-reply-text:focus { background: #fff; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

#mmd-send-reply-btn {
    background: #2563eb; color: white; border: none;
    width: 46px; height: 46px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; flex-shrink: 0; box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
#mmd-send-reply-btn:disabled { opacity: 0.6; cursor: not-allowed; background: #94a3b8; box-shadow: none; }
#mmd-send-reply-btn:hover:not(:disabled) { background: #1d4ed8; transform: translateY(-2px); }
#mmd-send-reply-btn i { font-size: 16px; margin-left: -2px; margin-top: 2px; }

/* Büroklammer */
.mmd-attach-btn {
    background: none; border: none; color: #94a3b8;
    font-size: 20px; cursor: pointer; width: 46px; height: 46px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.mmd-attach-btn:hover { color: #2563eb; background-color: #f1f5f9; }

/* Preview Area */
#mmd-file-preview-area {
    background: #eff6ff; padding: 10px 15px; font-size: 13px;
    border-radius: 8px; margin-bottom: 15px; display: flex; 
    justify-content: space-between; align-items: center; color: #1e40af;
    border: 1px dashed #bfdbfe;
}
.mmd-remove-file { cursor: pointer; color: #ef4444; margin-left: 10px; font-size: 18px; line-height: 1; }

/* --- ATTACHMENTS IN MESSAGES --- */
.mmd-msg-attachment { margin-bottom: 8px; }
.mmd-msg-attachment.type-image img {
    max-width: 250px; max-height: 250px; border-radius: 12px;
    cursor: pointer; display: block; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.mmd-msg-attachment.type-file a {
    display: flex; align-items: center; background: rgba(255,255,255,0.2);
    padding: 10px 14px; border-radius: 8px; text-decoration: none;
    color: inherit; font-weight: 500; font-size: 13px;
    border: 1px solid rgba(0,0,0,0.1);
}
.msg-them .mmd-msg-attachment.type-file a { background: #f1f5f9; }
.mmd-msg-attachment.type-file i { margin-right: 10px; font-size: 18px; }

/* --- MOBILE --- */
.mmd-mobile-only { display: none; }

@media (max-width: 991px) {
    .mmd-message-dashboard {
        position: relative;
        overflow: hidden;
    }

    .mmd-thread-list-wrapper {
        width: 100% !important;
        position: absolute;
        top: 0; left: 0; bottom: 0;
        z-index: 10;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateX(0);
        border-right: none;
    }

    .mmd-chat-window {
        width: 100% !important;
        position: absolute;
        top: 0; left: 0; bottom: 0;
        z-index: 20;
        background: #fff;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mmd-chat-window.mobile-active {
        transform: translateX(0);
    }
    
    .mmd-mobile-back-btn { display: block; }
}

/* Modal */
.mmd-modal {
    position: fixed; z-index: 99999; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(15, 23, 42, 0.7); display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.mmd-modal-content {
    background: #fff; padding: 30px; border-radius: 12px; width: 90%; max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: mmd-modal-in 0.3s ease-out;
}
@keyframes mmd-modal-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.mmd-modal-close { position: absolute; top: 15px; right: 15px; font-size: 24px; cursor: pointer; color: #94a3b8; }
.mmd-modal label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 14px; }
.mmd-modal input[type="text"], .mmd-modal textarea, .mmd-modal input[type="file"] { width: 100%; margin-bottom: 15px; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; box-sizing: border-box; }
.mmd-modal button[type="submit"] { width: 100%; padding: 12px; font-size: 16px; margin-top: 5px; font-weight: 600; border-radius: 6px; }