﻿
.chat-page {
    height: calc(100vh - 180px);
    overflow: hidden;
}

.thread-panel {
    height: 100%;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.thread-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.thread-item {
    padding: 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 0;
}

    .thread-item:hover {
        background-color: rgba(0, 0, 0, 0.06);
    }

body.mud-theme-dark .thread-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.thread-selected {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.15);
}

.attachment-preview {
    margin-left: 48px;
    margin-bottom: 8px;
}

.chat-image-preview {
    max-width: 220px;
    border-radius: 8px;
    margin-top: 6px;
    cursor: zoom-in;
}

/* ImageLightboxDialog: the whole image fits the screen, however large it is */
.image-lightbox-content {
    padding: 0 16px 16px;
}

.image-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 160px);
    margin: 0 auto;
    border-radius: 8px;
}

.chat-container {
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
}

.chat-header {
    flex-shrink: 0;
    padding: 20px;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 20px;
}

.chat-footer {
    flex-shrink: 0;
    padding: 12px;
}

.empty-chat {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    color: gray;
}

.chat-row {
    display: flex;
    margin-bottom: 10px;
}


    .chat-row.customer {
        justify-content: flex-start;
    }

    .chat-row.agent {
        justify-content: flex-end;
    }

.chat-bubble {
    max-width: 65%;
    padding: 12px 14px;
    border-radius: 18px;
    word-break: break-word;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-time {
    font-size: 11px;
    opacity: .7;
    margin-top: 4px;
}

.chat-bubble.sending {
    opacity: .7;
}

.customer .chat-bubble {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-lines-default);
    border-bottom-left-radius: 6px;
}

.agent .chat-bubble {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 6px;
}

.thread-item .mud-avatar {
    flex-shrink: 0;
}

.chat-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.85rem;
}

.chat-meta-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.badge-type {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.badge-individual {
    background: #e8f0fe;
    color: #1976d2;
}

.badge-corporate {
    background: #fff3e0;
    color: #f57c00;
}

.thread-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: gray;
    margin-top: 4px;
}

.thread-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-date-separator {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #777;
    font-size: 12px;
    font-weight: 600;
}

    .chat-date-separator::before,
    .chat-date-separator::after {
        content: "";
        flex: 1;
        border-top: 1px solid #ddd;
    }

    .chat-date-separator::before {
        margin-right: 10px;
    }

    .chat-date-separator::after {
        margin-left: 10px;
    }


.unread-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f44336;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.thread-title {
    font-weight: 500;
}

    .thread-title.unread {
        font-weight: 700;
    }

.thread-message {
    opacity: .75;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .thread-message.unread {
        opacity: 1;
        font-weight: 600;
    }


.avatar-unread {
    position: relative;
}

    .avatar-unread::after {
        content: "";
        position: absolute;
        right: 0;
        bottom: 0;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #ff3b30;
        border: 2px solid #2d2d2d;
    }

/* Chat search (Messenger-style): every occurrence is marked, the current one stands out. */
mark.chat-search-hit {
    background: #ffe58a;
    color: #1f1f1f;
    padding: 0 1px;
    border-radius: 3px;
}

    mark.chat-search-hit.current {
        background: #f5a623;
        box-shadow: 0 0 0 2px #f5a623;
    }

/* In-chat search bar: [ text ] 1/11  ^  v  options  x, with a "Match case" row under it. */
.conversation-search {
    padding: 6px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.conversation-search-bar {
    display: flex;
    align-items: center;
    gap: 2px;
}

    .conversation-search-bar .conversation-search-input {
        flex: 1 1 auto;
        margin: 0 !important;
    }

    .conversation-search-bar .search-count {
        min-width: 48px;
        text-align: center;
        font-size: 13px;
        opacity: .75;
        white-space: nowrap;
    }

    .conversation-search-bar .search-options-active {
        color: var(--mud-palette-primary);
        background: var(--mud-palette-action-default-hover);
    }

.conversation-search-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 0 4px;
    font-size: 14px;
}

/* Resolve (Maintenance chat): Open / Resolved / All tabs, the list badge, and the divider that
   stands in for a resolved issue's messages in the conversation. */
.thread-status-tabs {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

/* The type and RESOLVED badges sit together on the left of the meta row, the time on the right
   (.thread-meta spaces its direct children apart). RESOLVED reuses .badge-type's size and shape. */
.thread-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-resolved {
    color: #fff;
    background: var(--mud-palette-success);
}

.chat-resolved-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px auto;
    padding: 4px 12px;
    max-width: 90%;
    border-radius: 16px;
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-background-gray);
}

    .chat-resolved-divider .resolved-note {
        font-style: italic;
    }

/* Concerns (Maintenance chat): separate issues inside one chat. The bar under the header lists
   them, a tag on each message names its concern, and tag mode lets staff tick messages to file.
   --concern-color is set inline per concern. */
.concern-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

.concern-chip {
    --concern-color: var(--mud-palette-primary);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0 2px 0 0;
    border: 1px solid var(--concern-color);
    border-radius: 14px;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font-size: 12px;
    line-height: 1;
}

button.concern-chip {
    padding: 4px 10px;
    cursor: pointer;
}

.concern-chip.active {
    background: var(--concern-color);
    color: #fff;
}

.concern-chip-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.concern-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--concern-color);
}

.concern-chip.active .concern-dot {
    background: #fff;
}

.concern-count {
    opacity: .7;
}

.concern-chip .mud-button-root {
    color: inherit;
    padding: 2px;
}

.chat-concern-tag {
    display: inline-block;
    margin-bottom: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--concern-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

/* Tag mode: a checkbox in the gutter beside each message that can be filed. */
.chat-row.selecting {
    position: relative;
    padding-left: 36px;
}

.chat-select {
    position: absolute;
    left: 4px;
    top: 4px;
    /* Shows the state only: the click lands on the row, which does the toggling. */
    pointer-events: none;
}

.chat-row.selectable {
    cursor: pointer;
}

    /* A click ticks the message, so a drag-select of its text shouldn't start. */
    .chat-row.selectable .chat-bubble {
        user-select: none;
    }

.chat-row.selected .chat-bubble {
    outline: 2px solid var(--mud-palette-primary);
}

.chat-tag-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background-gray);
}

.chat-tag-count {
    margin-right: auto;
    font-size: 13px;
}

/* "Resolve up to here" on a message: shown on hover, always on touch screens. */
.chat-resolve-here {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

    .chat-resolve-here:hover,
    .chat-resolve-here:focus-visible {
        text-decoration: underline;
    }

.chat-row:hover .chat-resolve-here,
.chat-resolve-here:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .chat-resolve-here {
        opacity: 1;
    }
}

/* Messages of an expanded resolved issue, shown for review. */
.chat-row.resolved .chat-bubble {
    opacity: .7;
}
