/* ========================================
   Inbox / Chat Page
   angepasst an Portfolio / Objekte Design
   ======================================== */

.inbox-page {
    height: calc(100dvh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 24px;
}

.inbox-page-stack {
    flex: 1;
    min-height: 0;
}

.inbox-header {
    align-items: flex-start;
    gap: 16px;
}

.inbox-title {
    font-weight: 800;
    letter-spacing: 0.4px;
    color: var(--rr-text-strong);
    margin-bottom: 2px;
}

.inbox-header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inbox-chip {
    border-radius: var(--rr-radius-pill);
    font-weight: 700;
}

.obj-muted,
.muted {
    color: var(--rr-text-secondary);
    line-height: 1.4;
}

/* ---------- Layout ---------- */

.inbox-shell {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    height: auto;
}

/* ---------- Chat List ---------- */

.chat-list {
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: var(--rr-radius-lg);
    background: var(--rr-surface);
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.10);
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-list-header {
    padding: 14px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient( 135deg, rgba(250, 250, 250, 0.98), rgba(245, 245, 245, 0.78), rgba(255, 255, 255, 0.95) );
}

.chat-search .mud-input-root {
    border-radius: var(--rr-radius-md);
}

.chat-header-action {
    border-radius: 12px;
}

.chat-list-loading,
.chat-list-empty {
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.chat-list-body {
    padding: 10px;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 76px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    padding: 10px;
    cursor: pointer;
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    text-align: left;
}

    .chat-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
        border-color: rgba(0, 0, 0, 0.16);
    }

    .chat-item.active {
        background: linear-gradient( 135deg, rgba(250, 250, 250, 0.98), rgba(245, 245, 245, 0.86), rgba(255, 255, 255, 0.95) );
        border-color: rgba(0, 0, 0, 0.34);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    }

        .chat-item.active::before {
            content: "";
            position: absolute;
            left: 0;
            top: 12px;
            bottom: 12px;
            width: 5px;
            border-radius: 999px;
            background: linear-gradient(180deg, #111111, #cbd5e1);
        }

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--rr-radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    background: linear-gradient(135deg, #111111, #111111);
    color: var(--rr-on-primary);
    flex: 0 0 auto;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

    .avatar.big {
        width: 46px;
        height: 46px;
        font-size: 1.05rem;
    }

.chat-meta {
    min-width: 0;
    flex: 1;
}

.chat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-name,
.chat-header-name {
    font-weight: 900;
    color: var(--rr-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview,
.chat-header-sub {
    margin-top: 2px;
    color: var(--rr-text-secondary);
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Chat Window ---------- */

.chat-window {
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: var(--rr-radius-lg);
    background: var(--rr-surface);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.10);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.chat-empty {
    padding: 26px;
    display: grid;
    place-content: center;
    text-align: center;
    gap: 8px;
    flex: 1;
}

.chat-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient( 135deg, rgba(250, 250, 250, 0.98), rgba(245, 245, 245, 0.78), rgba(255, 255, 255, 0.95) );
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-header-meta {
    min-width: 0;
}

/* ---------- Messages ---------- */

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(0, 0, 0, 0.03));
    min-height: 0;
}

.msg-row {
    display: flex;
    margin: 10px 0;
}

    .msg-row.mine {
        justify-content: flex-end;
    }

    .msg-row.theirs {
        justify-content: flex-start;
    }

.msg-bubble {
    max-width: 70%;
    border-radius: var(--rr-radius-lg);
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.msg-row.theirs .msg-bubble {
    background: #ffffff;
    color: var(--rr-text-strong);
    border-top-left-radius: 6px;
}

.msg-row.mine .msg-bubble {
    background: linear-gradient( 135deg, rgba(245, 245, 245, 0.95), rgba(245, 245, 245, 0.72) );
    color: #111827;
    border-color: rgba(0, 0, 0, 0.18);
    border-top-right-radius: 6px;
}

.msg-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.98rem;
    line-height: 1.4;
    margin-top: 4px;
}

.msg-system {
    color: var(--rr-text-secondary);
    font-weight: 700;
}

.msg-files {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-chip {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.72);
    color: inherit;
    border-radius: var(--rr-radius-pill);
    padding: 6px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

    .file-chip:hover {
        transform: translateY(-1px);
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.10);
    }

/* ---------- Pending files / Composer ---------- */

.pending-files-bar,
.send-disabled-reason {
    padding: 10px 12px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.send-disabled-reason {
    padding: 0 12px 10px;
    border-top: none;
}

.chat-composer {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.78);
    align-items: center;
}

.composer-input .mud-input-root {
    border-radius: var(--rr-radius-md);
}

.composer-send,
.composer-attach {
    border-radius: var(--rr-radius-pill);
}

.rr-hidden-file {
    display: none;
}

/* ---------- Unread state ---------- */

.inbox-chip-unread {
    border-color: rgba(245, 158, 11, 0.65) !important;
    background: rgba(245, 158, 11, 0.10) !important;
    color: #92400e !important;
    font-weight: 900;
}

.chat-item.unread {
    border-color: rgba(245, 158, 11, 0.55);
    background: linear-gradient(135deg, rgba(255, 251, 235, 0.98), rgba(254, 243, 199, 0.72), rgba(255, 255, 255, 0.95));
    box-shadow: 0 10px 24px rgba(245, 158, 11, 0.18);
}

    .chat-item.unread:hover {
        border-color: rgba(245, 158, 11, 0.82);
        box-shadow: 0 14px 30px rgba(245, 158, 11, 0.24);
    }

    .chat-item.unread::after {
        content: "";
        position: absolute;
        right: 10px;
        top: 10px;
        width: 9px;
        height: 9px;
        border-radius: 999px;
        background: #f59e0b;
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
    }

    .chat-item.unread .chat-name {
        font-weight: 950;
        color: #111827;
    }

    .chat-item.unread .chat-preview {
        font-weight: 800;
        color: #374151;
    }

.chat-top-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-unread-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #f59e0b;
    color: #111827;
    font-size: 0.75rem;
    font-weight: 950;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.28);
}

.msg-unread-icon {
    color: #f59e0b;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .inbox-page {
        height: auto;
        min-height: calc(100dvh - 120px);
        overflow: visible;
    }

    .inbox-header,
    .chat-header {
        flex-direction: column;
        align-items: stretch;
    }

    .inbox-shell {
        grid-template-columns: 1fr;
    }

    .chat-list {
        min-height: 320px;
        max-height: 420px;
    }

    .chat-window {
        min-height: 60vh;
    }

    .msg-bubble {
        max-width: 88%;
    }
}



@media (max-width: 600px) {
    .chat-list-header {
        grid-template-columns: 1fr auto auto;
        padding: 10px;
    }

    .chat-header {
        padding: 12px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-composer {
        grid-template-columns: auto 1fr auto;
        padding: 10px;
    }

    .msg-bubble {
        max-width: 92%;
    }
}
