/* ========================================
   CHAT — CONFIGURATION & LAYOUT
   ======================================== */

.chat-preview {
    --chat-background: #e6eaed;
    --chat-header: #f2f4f6;
    --chat-active: var(--primary-50, #edf5ff);
    --chat-primary: var(--primary-700, #006cff);
    --chat-muted: var(--neutral-600, #748499);
    --chat-border: var(--neutral-100, #dae5f2);
}

.chat-preview__title {
    margin: 0 0 12px;

    font-size: 19px;
    font-weight: 700;

    color: var(--chat-primary);
}

.chat-preview__layout {
    display: grid;

    grid-template-columns:
        minmax(0, 0.34fr)
        minmax(0, 0.66fr);

    min-width: 0;
    min-height: 340px;

    overflow: hidden;

    border: 1px solid var(--chat-border);
    border-radius: 8px;

    background: #ffffff;
}


/* ========================================
   CHAT — SIDEBAR
   ======================================== */

.chat-preview__sidebar {
    display: flex;
    flex-direction: column;

    min-width: 0;

    gap: 5px;
    padding: 5px;

    border-right: 1px solid var(--chat-border);
}

.chat-preview__search {
    display: flex;
    align-items: center;

    min-width: 0;

    gap: 6px;
    padding: 9px 7px;

    border-radius: 5px;

    background: var(--chat-header);
    color: var(--chat-muted);

    font-size: 10px;
    font-weight: 500;
}

.chat-preview__search svg {
    width: 13px;
    height: 13px;
}

.chat-preview__search span {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-preview__contacts {
    display: flex;
    flex-direction: column;

    gap: 3px;
}


/* ========================================
   CHAT — CONTACTS
   ======================================== */

.chat-preview__contact {
    display: flex;
    align-items: center;

    min-width: 0;
    min-height: 43px;

    gap: 6px;
    padding: 6px;

    border-radius: 5px;

    transition: background-color 150ms ease;
}

.chat-preview__contact:hover {
    background: #f5f7fa;
}

.chat-preview__contact.is-active,
.chat-preview__contact.is-active:hover {
    background: var(--chat-active);
}

.chat-preview__contact-info {
    display: flex;
    flex: 1;
    flex-direction: column;

    min-width: 0;

    gap: 3px;
}

.chat-preview__contact-info > strong,
.chat-preview__contact-info > span {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-preview__contact-info strong {
    font-size: 10px;
    font-weight: 700;
}

.chat-preview__contact.is-active
.chat-preview__contact-info strong {
    color: var(--chat-primary);
}

.chat-preview__contact-info > span {
    font-size: 9px;

    color: var(--chat-muted);
}

.chat-preview__contact-time {
    align-self: flex-start;
    flex-shrink: 0;

    padding-top: 2px;

    font-size: 8px;

    color: var(--chat-muted);
}


/* ========================================
   CHAT — AVATARS
   ======================================== */

.chat-preview__avatar {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 30px;
    height: 30px;

    border-radius: 50%;

    background: var(--chat-background);
    color: var(--neutral-700, #424b57);

    font-size: 10px;
    font-weight: 600;
}

.chat-preview__avatar--active {
    background: var(--primary-100, #dcebff);
    color: var(--chat-primary);
}

.chat-preview__status {
    position: absolute;

    right: 0;
    bottom: 0;

    width: 8px;
    height: 8px;

    border: 2px solid #ffffff;
    border-radius: 50%;

    background: #95a5ba;
}

.chat-preview__avatar--active
.chat-preview__status {
    background: var(--success, #17a700);
}


/* ========================================
   CHAT — GROUPS & ADMINISTRATORS
   ======================================== */

.chat-preview__new-group {
    display: flex;
    align-items: center;

    gap: 7px;
    padding: 6px;

    color: var(--chat-muted);

    font-size: 9px;
}

.chat-preview__group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 27px;
    height: 27px;

    border-radius: 50%;

    background: var(--chat-background);
    color: var(--neutral-700, #424b57);
}

.chat-preview__group-icon svg {
    width: 13px;
    height: 13px;
}

.chat-preview__admins {
    margin-top: 4px;
}

.chat-preview__admins > strong {
    display: block;

    padding: 4px 6px;

    font-size: 10px;
    font-weight: 600;

    color: var(--chat-muted);
}


/* ========================================
   CHAT — ACTIVE CONVERSATION
   ======================================== */

.chat-preview__conversation {
    display: flex;
    flex-direction: column;

    min-width: 0;

    background: var(--chat-background);
}

.chat-preview__header {
    display: flex;
    align-items: center;

    gap: 8px;
    padding: 8px 10px;

    background: var(--chat-header);
}

.chat-preview__header-info {
    display: flex;
    flex: 1;
    flex-direction: column;

    min-width: 0;

    gap: 2px;
}

.chat-preview__header-info strong {
    font-size: 11px;
    font-weight: 700;
}

.chat-preview__header-info > span {
    font-size: 9px;

    color: var(--success-dark, #117e00);
}

.chat-preview__header-actions {
    display: flex;
    align-items: center;

    gap: 7px;

    color: var(--neutral-700, #424b57);
}

.chat-preview__header-actions > span {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 22px;
    height: 22px;

    border-radius: 4px;

    transition: background-color 150ms ease;
}

.chat-preview__header-actions > span:hover {
    background: var(--neutral-100, #dae5f2);
}

.chat-preview__header-actions svg {
    width: 14px;
    height: 14px;
}


/* ========================================
   CHAT — MESSAGES
   ======================================== */

.chat-preview__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-evenly;

    min-width: 0;

    gap: 14px;
    padding: 16px 12px;

    background: var(--chat-background);
}

.chat-preview__message {
    display: flex;
    align-items: flex-start;

    gap: 6px;
}

.chat-preview__message--received {
    justify-content: flex-start;
}

.chat-preview__message--sent {
    justify-content: flex-end;
}

.chat-preview__message .chat-preview__avatar {
    width: 22px;
    height: 22px;

    font-size: 8px;
}

.chat-preview__message .chat-preview__status {
    display: none;
}

.chat-preview__message-content {
    display: flex;
    flex-direction: column;

    min-width: 0;
    max-width: 86%;

    gap: 4px;
}

.chat-preview__message--received
.chat-preview__message-content {
    align-items: flex-start;
}

.chat-preview__message--sent
.chat-preview__message-content {
    align-items: flex-end;
}


/* ========================================
   CHAT — MESSAGE BUBBLES
   ======================================== */

.chat-preview__bubble {
    width: fit-content;
    max-width: 100%;

    padding: 8px 10px;

    border-radius: 14px;

    font-size: 10px;
    line-height: 1.5;

    overflow-wrap: anywhere;

    transition: box-shadow 150ms ease;
}

.chat-preview__bubble:hover {
    box-shadow: 0 3px 10px rgba(13, 30, 55, 0.08);
}

.chat-preview__message--received
.chat-preview__bubble {
    background: #ffffff;
    color: var(--neutral-900, #0d1014);
}

.chat-preview__message--sent
.chat-preview__bubble {
    background: var(--chat-primary);
    color: #ffffff;
}

.chat-preview__message-time {
    display: flex;
    align-items: center;

    gap: 3px;
    padding-inline: 5px;

    font-size: 8px;

    color: var(--neutral-700, #424b57);
}

.chat-preview__message-time svg {
    width: 10px;
    height: 10px;

    color: var(--chat-primary);
}


/* ========================================
   CHAT — MESSAGE COMPOSER
   ======================================== */

.chat-preview__composer {
    display: flex;
    align-items: center;

    min-height: 34px;

    gap: 8px;
    padding: 8px 10px;

    background: #ffffff;
    color: var(--neutral-700, #424b57);

    font-size: 10px;
}

.chat-preview__composer > span {
    flex: 1;

    color: var(--chat-muted);
}

.chat-preview__composer svg {
    width: 14px;
    height: 14px;
}


/* ========================================
   CHAT — RESPONSIVE CONTAINER 600 PX
   ======================================== */

@container (max-width: 600px) {

    .product-demo--chat .product-demo__window {
        padding: 10px;
    }

    .chat-preview__layout {
        grid-template-columns:
            minmax(0, 0.36fr)
            minmax(0, 0.64fr);
    }

    .chat-preview__contact-time {
        display: none;
    }

    .chat-preview__contact {
        gap: 5px;
        padding: 5px 3px;
    }

    .chat-preview__sidebar .chat-preview__avatar {
        width: 26px;
        height: 26px;

        font-size: 9px;
    }

    .chat-preview__messages {
        gap: 12px;
        padding: 12px 8px;
    }

    .chat-preview__bubble {
        padding: 7px 9px;
    }
}


/* ========================================
   CHAT — RESPONSIVE CONTAINER 420 PX
   ======================================== */

@container (max-width: 420px) {

    .chat-preview__layout {
        grid-template-columns: minmax(0, 1fr);

        min-height: 320px;
    }

    /* Show only the active conversation on mobile. */

    .chat-preview__sidebar {
        display: none;
    }

    .chat-preview__messages {
        gap: 12px;
        padding: 14px 10px;
    }

    .chat-preview__bubble {
        font-size: 11px;
    }

    .chat-preview__title {
        font-size: 17px;
    }
}
