/* Ticket chat — messenger-style conversation (PRJ-0017-T-0003) */

.ticket-chat-scroll {
    display: flex;
    flex-direction: column-reverse; /* newest-first in DOM -> oldest top, newest bottom, sticks to bottom */
    overflow-y: auto;
    max-height: 55vh;
    min-height: 200px;
    gap: 8px;
    padding: 8px 4px;
}

.ticket-chat-row {
    display: flex;
    width: 100%;
}

.ticket-chat-row--own {
    justify-content: flex-end;
}

.ticket-chat-row--other {
    justify-content: flex-start;
}

.ticket-chat-bubble {
    max-width: 78%;
    padding: 6px 12px 4px;
    border-radius: 14px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .10);
    word-break: break-word;
}

.ticket-chat-bubble--own {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 4px;
}

.ticket-chat-bubble--other {
    background: var(--mud-palette-background-grey);
    color: var(--mud-palette-text-primary);
    border-bottom-left-radius: 4px;
}

/* Internal notes are staff-only — distinct amber tint regardless of side */
.ticket-chat-bubble--internal {
    background: rgba(255, 167, 38, .16);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-warning);
}

.ticket-chat-author {
    font-size: .72rem;
    font-weight: 600;
    opacity: .85;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ticket-chat-meta {
    font-size: .66rem;
    opacity: .75;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.ticket-chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.ticket-chat-att-img {
    max-width: 180px;
    max-height: 180px;
    border-radius: 8px;
    display: block;
    object-fit: cover;
}

/* File attachment chips: a slightly darker tone of the primary colour with white
   text, so they read as distinct, tappable files on the message bubble. */
.ticket-chat-attachments .mud-chip.mud-chip-text {
    background-color: var(--mud-palette-primary-darken);
    color: var(--mud-palette-primary-text);
}
.ticket-chat-attachments .mud-chip.mud-chip-text .mud-icon-root {
    color: var(--mud-palette-primary-text);
}

/* tidy spacing for rendered rich-text inside a bubble */
.ticket-chat-body p:first-child { margin-top: 0; }
.ticket-chat-body p:last-child { margin-bottom: 0; }
.ticket-chat-body img { max-width: 100%; height: auto; }

/* Composer: one rounded box around the Quill toolbar + editor.
   Quill's snow theme borders each child (.ql-toolbar / .ql-container); strip those
   and put a single border + radius on the wrapper. overflow:hidden clips the
   children's square corners to the rounded wrapper. */
.ticket-chat-composer {
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 18px;
    overflow: hidden;
}
.ticket-chat-composer .ql-toolbar.ql-snow {
    border: 0;
    border-bottom: 1px solid var(--mud-palette-lines-default); /* keep a divider under the toolbar */
}
.ticket-chat-composer .ql-container.ql-snow {
    border: 0;
}
.ticket-chat-composer .ql-container { min-height: 90px; }
.ticket-chat-composer .ql-editor { min-height: 90px; }

/* Attach paperclip lives in the Quill toolbar, right after the formatting controls. */
.ticket-chat-composer .ql-toolbar .ticket-chat-attach-group {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
/* Undo Quill's snow-theme button styling (float/fixed-size/no-pointer) so the
   MudIconButton renders and clicks at its natural size inside the toolbar. */
.ticket-chat-composer .ql-toolbar .ticket-chat-attach-group button {
    pointer-events: auto;
    float: none;
    width: auto;
    height: auto;
    padding: 4px;
}

/* keep Quill's link tooltip above MudBlazor surfaces */
.ql-tooltip { z-index: 2000; }

/* MudBlazor positions tab badges outside the content box. Reserve enough room
   so the intervention counter does not overlap the following tab. */
.ticket-tabs .mud-tab .mud-badge-root {
    margin-right: 24px;
}

/* Ticket detail — on phones (< MudBlazor Md / 960px) hide the native tab strip
   (MudBlazor's header bar is .mud-tabs-tabbar); the mobile section selector
   (MudMenu) drives navigation instead. */
@media (max-width: 959.98px) {
    .ticket-tabs .mud-tabs-tabbar {
        display: none;
    }
}
