:root {
    --msg-blue: #0b2c78;
    --msg-accent: #1669e8;
    --msg-text: #14233e;
    --msg-muted: #718096;
    --msg-line: #e1e7ef;
}

.msg-shell {
    max-width: 1180px;
    margin: 0 auto;
}

.msg-topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.msg-kicker {
    color: #1680cb;
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .12em;
}

.msg-topbar h1 {
    margin: 3px 0;
    color: var(--msg-text);
    font-weight: 850;
}

.msg-topbar p {
    margin: 0;
    color: var(--msg-muted);
}

.msg-dashboard-link {
    color: #1468df;
    font-weight: 750;
    text-decoration: none;
}

.msg-app {
    height: min(720px, calc(100vh - 190px));
    min-height: 540px;
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    overflow: hidden;
    background: white;
    border: 1px solid var(--msg-line);
    border-radius: 22px;
    box-shadow: 0 14px 42px rgba(20,40,75,.07);
}

.msg-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--msg-line);
    background: #fbfcfe;
    overflow: auto;
}

.msg-sidebar-head {
    padding: 19px;
    border-bottom: 1px solid var(--msg-line);
}

.msg-sidebar-title {
    font-weight: 850;
    color: var(--msg-text);
}

.msg-sidebar-subtitle {
    margin-top: 2px;
    color: var(--msg-muted);
    font-size: .8rem;
}

.msg-conversation-item,
.msg-representative-item {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    display: flex;
    gap: 11px;
    padding: 13px 16px;
    cursor: pointer;
    border-bottom: 1px solid #edf1f5;
}

.msg-conversation-item:hover,
.msg-representative-item:hover {
    background: #f1f6fd;
}

.msg-conversation-item.active {
    background: #eaf3ff;
}

.msg-avatar {
    width: 43px;
    height: 43px;
    flex: 0 0 43px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg,#e7f2ff,#e8fbfa);
    color: #1767c8;
    font-weight: 850;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-item-body {
    min-width: 0;
    flex: 1;
}

.msg-item-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.msg-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--msg-text);
    font-size: .9rem;
    font-weight: 800;
}

.msg-item-time {
    color: #93a0b2;
    font-size: .7rem;
    white-space: nowrap;
}

.msg-item-preview {
    margin-top: 3px;
    color: var(--msg-muted);
    font-size: .78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-unread {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 5px;
    border-radius: 50%;
    background: #1670e8;
}

.msg-representatives {
    margin-top: auto;
    border-top: 1px solid var(--msg-line);
}

.msg-section-title {
    padding: 15px 16px 7px;
    color: #65758b;
    font-size: .7rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.msg-conversation-pane {
    min-width: 0;
    min-height: 0;
    background: #fff;
}

.msg-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
    color: var(--msg-muted);
}

.msg-empty-icon {
    width: 70px;
    height: 70px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: #eef5ff;
    font-size: 2rem;
}

.msg-empty h2 {
    color: var(--msg-text);
    margin: 16px 0 6px;
}

.msg-conversation {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0,1fr) auto;
}

.msg-chat-head {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--msg-line);
}

.msg-chat-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #edf4ff;
}

.msg-chat-person {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.msg-chat-person strong {
    color: var(--msg-text);
}

.msg-chat-person span {
    color: var(--msg-muted);
    font-size: .78rem;
}

.msg-online {
    color: #16825d;
    font-size: .76rem;
    font-weight: 750;
}

.msg-back {
    display: none;
    border: 0;
    background: transparent;
    font-size: 1.25rem;
}

.msg-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    background: #f7f9fc;
}

.msg-message {
    display: flex;
    margin-bottom: 12px;
}

.msg-bubble {
    max-width: min(74%, 560px);
    padding: 10px 13px;
    border-radius: 15px 15px 15px 4px;
    background: white;
    border: 1px solid #e2e7ee;
}

.msg-message-name {
    margin-bottom: 3px;
    color: #48617e;
    font-size: .72rem;
    font-weight: 800;
}

.msg-message-text {
    color: #17253c;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-message-time {
    margin-top: 4px;
    color: #8a98aa;
    font-size: .66rem;
    text-align: right;
}

.msg-composer {
    display: grid;
    grid-template-columns: minmax(0,1fr) 46px;
    gap: 9px;
    padding: 13px;
    border-top: 1px solid var(--msg-line);
    background: white;
}

.msg-composer textarea {
    width: 100%;
    max-height: 130px;
    resize: none;
    border: 1px solid #d9e1eb;
    border-radius: 18px;
    padding: 11px 14px;
    outline: none;
    font: inherit;
}

.msg-composer button {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    color: white;
    background: linear-gradient(135deg,#1469e8,#08a9d2);
    cursor: pointer;
}

.msg-state-card {
    max-width: 520px;
    margin: 70px auto;
    padding: 30px;
    text-align: center;
    border: 1px solid var(--msg-line);
    border-radius: 20px;
    background: white;
}

.msg-state-icon {
    font-size: 2rem;
}

.msg-primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    margin-top: 10px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: #1669e8;
    color: white;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.msg-spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 12px;
    border: 3px solid #e4eaf1;
    border-top-color: #1669e8;
    border-radius: 50%;
    animation: msgspin .8s linear infinite;
}

@keyframes msgspin {
    to { transform: rotate(360deg); }
}

@media(max-width:720px) {
    .msg-shell {
        margin: -24px -12px;
    }

    .msg-topbar {
        padding: 15px 16px 10px;
        margin: 0;
        align-items: center;
    }

    .msg-topbar p,
    .msg-dashboard-link {
        display: none;
    }

    .msg-app {
        height: calc(100dvh - 105px);
        min-height: 0;
        grid-template-columns: 1fr;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .msg-sidebar {
        border-right: 0;
    }

    .msg-conversation-pane {
        display: none;
    }

    .msg-app.chat-open .msg-sidebar {
        display: none;
    }

    .msg-app.chat-open .msg-conversation-pane {
        display: block;
        height: 100%;
    }

    .msg-back {
        display: block;
    }

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

/* ===== Messages : moi / interlocuteur ===== */

.msg-message {
    display: flex;
    width: 100%;
    margin: 8px 0;
}

.msg-message--other {
    justify-content: flex-start;
}

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

.msg-message .msg-bubble {
    max-width: min(72%, 560px);
}

.msg-message--mine .msg-bubble {
    background: #0b63ce;
    color: #fff;
    border-color: #0b63ce;
    border-radius: 18px 18px 5px 18px;
}

.msg-message--other .msg-bubble {
    border-radius: 18px 18px 18px 5px;
}

.msg-message--mine .msg-message-text {
    color: #fff;
}

.msg-message--mine .msg-message-time {
    color: rgba(255, 255, 255, 0.78);
}

@media (max-width: 620px) {
    .msg-message .msg-bubble {
        max-width: 84%;
    }
}
