/* Responsive layout for conversation pages: a list of conversations on the left and the
   opened conversation on the right (email today; chat and social share the structure).
   Desktop keeps each module's existing sizes; narrower screens get new behaviour.
   Below 992px (where resizable-split.js turns off) the panels stack: the list first,
   the opened conversation under it.

   Adopting it in a module (every hook is opt-in; leave out what the module lacks):

   Page
     .conv-page                  page container (scope); data-conv-open-event="<Livewire
                                 event the list emits on select>" + conversation-responsive.js
                                 scrolls to the opened conversation on small screens
     .conv-layout                the split row; add data-conv-view="list|detail" from
                                 $resourceOpen (only when the list is rendered)
     .conv-fit                   on that row: the panels fill the screen on desktop
     .conv-empty-panel           the "nothing selected" placeholder column
     .conv-detail-panel          the opened-conversation column (scroll target)
     .conv-loader                the loading overlay (full screen when stacked)
   Ticket header
     .conv-age-text / .conv-age-actions / .conv-age-counter
                                 the same for headers that keep their own layout (tickets):
                                 title column, actions column, ticket-age counter
     .rac                        the age counter component (<x-resource-age-counter />);
                                 no opt-in, its phone layout applies wherever it is used
   List panel
     .conv-search-field / .conv-search-actions   search input column / refresh+filter column
     .conv-list-scroll           the scrolling list; style="--conv-list-height: <px>"
     .conv-card-row / .conv-card-avatar / .conv-card-text   a list card's row and columns
     .conv-card-date             the card's date (floated right on desktop)
     .conv-card-subject / .conv-card-name   one-line texts in a card, cut with "..."
     .conv-card-preview          message preview, one line cut with "..."
     .conv-card-meta             the date + ticket id line (kept on one line)
     .conv-filter-icons          the row of filter icons
     .conv-filter-icons--compose / .conv-compose / .conv-compose-btn
                                 one row of icons with a Compose button at its end
   Conversation panel
     .conv-detail-body           card body; style="--conv-detail-height: <px>", optional
                                 --conv-detail-mobile-height (default: auto). Chat and social
                                 give it a mobile height: their messages fill the body.
     .conv-detail-scroll         inner scroll area; style="--conv-detail-scroll-height: <px>",
                                 optional --conv-detail-scroll-mobile-height
     .conv-detail-head / .conv-detail-avatar / .conv-detail-info / .conv-detail-action /
     .conv-detail-indent         conversation header row, its avatar, name and button
                                 columns, and the 26px text indent
     .conv-reply-head / .conv-reply-fields / .conv-reply-btn
                                 reply form header row, label/input rows, and action buttons */

/* ---------- Desktop ---------- */

/* The split's default 30% drops below the markup's data-min-start on small laptops;
   a dragged size (set inline by resizable-split.js) still wins. */
.conv-page .conv-layout {
    --split-start-size: max(320px, 30%);
}

.conv-page .conv-list-scroll {
    height: var(--conv-list-height, auto);
    overflow-x: hidden;
    overflow-y: auto;
}

.conv-page .conv-detail-body {
    height: var(--conv-panel-height, var(--conv-detail-height, auto));
}

.conv-page .conv-detail-scroll {
    position: relative;
    height: var(--conv-detail-scroll-height, auto);
    overflow: auto;
}

.conv-page .conv-detail-indent {
    margin-left: 26px;
}

/* Reply / Reply All / Forward. Keeps 9vw on desktop but never narrower than the button
   label. In a narrow panel the buttons share each line evenly instead of wrapping
   ragged; the gap replaces the buttons' old 18px right margin. */
.conv-page .conv-reply-actions {
    container-type: inline-size;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.conv-page .conv-reply-btn {
    width: 9vw;
    min-width: max-content;
}

@container (max-width: 419.98px) {
    .conv-page .conv-reply-btn {
        flex: 1 1 0;
        width: auto;
    }
}

/* ---------- List panel: search row ---------- */

/* The actions column keeps its Bootstrap width on desktop but never gets narrower than
   its icons; the search input takes whatever is left. The 50% basis keeps it from
   squeezing onto the line of a preceding full-width item (chat/social put an <hr> in the
   same row). */
.conv-page .conv-search-field {
    flex: 1 1 50%;
    width: auto;
    min-width: 0;
}

.conv-page .conv-search-actions {
    min-width: max-content;
}

.conv-page .conv-search-actions > .row {
    flex-wrap: nowrap;
}

.conv-page .conv-search-actions > .row > * {
    min-width: max-content;
}

/* Social channel/type controls must fit the resizable panel, independently of
   the viewport width. Keep the modal and channel popup outside overflow clips. */
.conv-page .social-resource-filter {
    min-width: 0;
    white-space: normal;
    overflow: visible;
}

.conv-page .social-resource-filter__types {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.conv-page .social-resource-filter__channel {
    min-width: 0;
    overflow-wrap: anywhere;
}

.conv-page .social-resource-filter__types > button {
    flex: 0 0 auto;
    max-width: 100%;
    white-space: nowrap;
}

.conv-page .social-resource-filter__search {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
}

.conv-page .social-resource-filter__search .conv-search-field {
    flex: 1 1 0;
    padding: 0;
}

.conv-page .social-resource-filter__search .search-bar,
.conv-page .social-resource-filter__search input {
    min-width: 0;
    max-width: 100%;
}

.conv-page .social-resource-filter__search .conv-search-actions {
    flex: 0 0 auto;
    width: auto;
    padding: 0 0 0 10px;
    border-left: 1px solid #b5b5b5;
}

.conv-page .social-resource-filter__search .conv-search-actions > .row {
    margin: 0;
    gap: 8px;
}

.conv-page .social-resource-filter__search .conv-search-actions > .row > * {
    width: auto;
}

/* The border replaces the old divider image and its Bootstrap column. */
.conv-page .social-resource-filter__search .conv-search-actions > .row > :first-child {
    display: none;
}

.conv-page .social-resource-filter__search .icons-2 {
    margin: 0 !important;
}

/* ---------- List panel: cards ---------- */

/* Columns keep their percentages on desktop. When the panel is narrow the avatar
   column holds the 40px picture and the text column shrinks instead of wrapping
   under it. Subject and customer stay on one line and end with "..."; other text
   wraps at spaces and only breaks a word that cannot fit on its own. */
.conv-page .conv-card-row {
    flex-wrap: nowrap;
}

.conv-page .conv-card-avatar {
    min-width: 47px;
}

.conv-page .conv-card-text {
    flex-shrink: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

/* One-line texts cut with "...": card subject, customer name, message preview and date,
   and the conversation header's name lines. */
.conv-page .conv-card-subject,
.conv-page .conv-card-name,
.conv-page .conv-card-preview,
.conv-page .conv-card-meta > span:first-child,
.conv-page .conv-detail-info h5,
.conv-page .conv-detail-info h6,
.conv-page .conv-detail-info .d-block {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* inline-block keeps the <br> after the customer name working as before. */
.conv-page .conv-card-subject,
.conv-page .conv-card-name {
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
}

/* Message preview (chat/social): its own line. */
.conv-page .conv-card-preview {
    display: block;
}

/* Date and ticket id share one line however narrow the card: the id keeps its width (its
   float and top padding are inline styles, ignored as a flex item) and the date gives
   way with "...". */
.conv-page .conv-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.conv-page .conv-card-meta > span:first-child {
    min-width: 0;
}

.conv-page .conv-card-meta > span:last-child {
    flex-shrink: 0;
}

/* Filter icons wrap onto a second line instead of running past a narrow panel.
   The gap stands in for the space characters between the inline icons. */
.conv-page .conv-filter-icons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 4px;
    row-gap: 8px;
    height: auto;
    min-height: 48px;
}

/* ---------- Chat/social reply form ---------- */

/* The reply form (.reply-form-shared, style.css) puts the message box and the mic/send
   buttons side by side. In a narrow conversation panel (a phone, or the split dragged
   left) the buttons left the box too little room even for its placeholder, so there they
   stay beside it but compact: smaller, stacked, a small gap instead of the mic's inline
   margins, and lined up with the box rather than centred on the box plus its hints. The reply's
   root is the size container (it holds no fixed-position elements). */
.conv-page [data-reply-focus-resource] {
    container-type: inline-size;
}

/* "Press Enter to send..." stays on one line (white-space: nowrap in the reply view),
   which pushed its toggle past the edge of a narrow panel; it wraps here instead. */
@container (max-width: 560px) {
    .conv-page .reply-form-shared .enter-send-toggle {
        white-space: normal;
    }
}

@container (max-width: 420px) {
    /* Side padding trimmed from px-3 (an !important utility). */
    .conv-page .reply-form-shared {
        gap: 8px;
        padding-right: 8px !important;
        padding-left: 8px !important;
    }

    .conv-page .reply-form-shared > .col-2 {
        align-self: start;
        padding-left: 0;
    }

    /* Mic and send stack (when both show) so the box keeps the width. */
    .conv-page .reply-form-shared > .col-2 > .btn-group {
        flex-direction: column;
        gap: 6px;
    }

    /* Their margins and round shape are inline styles, hence !important. */
    .conv-page .reply-form-shared > .col-2 .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 6px 0 0 !important;
        border-radius: 50% !important;
    }
}

/* Emoji picker (the emoji-picker web component, chat and social): about 345px wide (its
   8-column grid and category tabs) and opening leftwards from 14px inside the reply
   form's right edge, so in a narrow form it ran off the left of the screen. There it
   spans the form with the same 14px on each side, with fewer columns (the component's
   --num-columns) and smaller category tabs so the grid and all 9 tabs fit that width. */
@container (max-width: 357.98px) {
    .conv-page #reply-emoji-picker {
        --num-columns: 7;
        --category-emoji-size: 1.125rem;
        --category-emoji-padding: .3rem;
        width: calc(100% - 28px);
    }
}

@container (max-width: 317.98px) {
    .conv-page #reply-emoji-picker {
        --num-columns: 6;
    }
}

@container (max-width: 277.98px) {
    .conv-page #reply-emoji-picker {
        --num-columns: 5;
        --category-emoji-size: 1rem;
        --category-emoji-padding: .25rem;
    }
}

/* With the age counter showing, the actions column takes the width it needs and the
   title/description column gets the rest (it wraps the description instead). The fixed
   col-6 / col-7 split was too narrow at 100% zoom, so the counter's date wrapped under
   the time. If even the full row is too narrow, the actions move to a line of their own.
   Tablet and phone layouts below (grid) are unaffected. */
@media (min-width: 768px) {
    .conv-page .row:has(> .conv-age-actions .rac) > .conv-age-text {
        flex: 1 1 0;
        width: auto;
        min-width: 240px;
    }

    .conv-page .row > .conv-age-actions:has(.rac) {
        flex: 0 0 auto;
        width: auto;
        max-width: 100%;
    }
}

/* ---------- Age counter component (<x-resource-age-counter />), any page ---------- */

/* Phones: two lines instead of one long row. The mode icon(s) and the date go on the
   first line, the running time stays alone on the second ("Not assigned" takes its
   place). Keyed on the component's own classes, so every header that uses it gets
   this without opting in. */
@media (max-width: 575.98px) {
    /* [data-rac]: the component's own styles load after this file and set .rac's display. */
    .rac[data-rac]:not(.rac--compact) {
        display: grid;
        grid-template-columns: auto auto;
        justify-content: start;
        align-items: center;
        gap: 8px;
    }

    .rac > .rac-modes {
        grid-area: 1 / 1;
    }

    .rac > .rac-box--date {
        grid-area: 1 / 2;
        justify-self: start;
    }

    .rac > .rac-time,
    .rac > .rac-empty {
        grid-area: 2 / 1 / 3 / -1;
        justify-self: start;
    }
}

/* ---------- Conversation panel ---------- */

/* Conversation header. The columns keep their percentages while there is room; in a
   narrow panel (small screen, or the split dragged left) the button columns keep their
   buttons inside the card and the name column gives way, cutting long text with "...". */
.conv-page .conv-detail-head {
    flex-wrap: nowrap;
}

.conv-page .conv-detail-head > .conv-detail-info {
    flex: 1 1 0;
    min-width: 0;
}

.conv-page .conv-detail-head > .conv-detail-action {
    min-width: max-content;
    /* Matches the distance from the three dots to the tagging button. */
    column-gap: 36px;
}

.conv-page .canned-panel {
    max-width: calc(100% - 4px);
}

/* Chat/social canned responses panel: 23rem wide and 17px inside the reply form's right
   edge (inline styles), so in a narrow form it ran off the left; capped to keep 17px on
   both sides. */
.conv-page .canned-panel.canned-panel-popup {
    max-width: calc(100% - 34px);
}

/* Canned search row: the input (flex: 1) never shrank below a text input's default
   width, so in a narrow panel it pushed the search button out; it gives way instead. */
.conv-page .canned-search-input {
    min-width: 0;
}

.conv-page .canned-search-btn {
    flex-shrink: 0;
}

/* Conversation 3-dots menu (chat, social, email): absolutely placed with an inline
   left: -180px !important, it only got the room between that offset and its toggle, so
   "Timeline history" and the Zoom row ran out of it. It takes its content's width
   instead, and never more than the screen. */
.conv-page .header-dotes.dropdown-menu {
    width: max-content;
    max-width: calc(100vw - 1rem);
}

/* Message date groups (Yesterday, Last Week, Last Month, Older): buttons 30% wide and
   centred by 36% side margins (inline), which split their label over two lines on a
   phone. Never narrower than the label, centred with auto margins: the same place on
   desktop. */
.conv-page button.btn[aria-controls^="collapse-"][data-bs-target^="#collapse-"] {
    display: block;
    min-width: max-content;
    margin-right: auto !important;
    margin-left: auto !important;
    white-space: nowrap;
}

/* ---------- Small laptops ---------- */

/* The layout shell pads every page with px-5 (an !important utility); below 992px
   mobile-nav.css narrows it for all pages. */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .content:has(.conv-page) {
        padding-right: 1.5rem !important;
        padding-left: 1.5rem !important;
    }
}

@media (max-width: 1199.98px) {
    /* Filter icons: drop their fixed side margins (set with !important by the page
       styles and the me-1 utility). */
    .conv-page .conv-filter-icons {
        gap: 8px;
    }

    .conv-page .conv-filter-icons > * {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* Keep the ticket age and date together; the whole counter can still move below
       the action button. Applies to both flat and nested counter markup. */
    .conv-age-counter {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px 4px;
        min-width: 0;
    }

    .conv-age-counter > span {
        flex-shrink: 0;
        white-space: nowrap;
        margin-top: 0 !important;
        line-height: 1.2;
    }

    /* The counter sits under the action button here, so the divider has nothing to divide. */
    .conv-age-counter > span:last-child {
        display: none;
    }
}

/* ---------- Tablet and mobile: stacked list and conversation ---------- */

@media (max-width: 991.98px) {
    /* Nothing opened yet: skip the placeholder under the list. */
    .conv-page .conv-layout[data-conv-view="list"] > .conv-empty-panel {
        display: none;
    }

    /* Loading overlay: on desktop it sits over the conversation panel with fixed side
       offsets (inline styles, hence !important); stacked, those offsets leave a strip over
       the list, so it covers the screen with the spinner centred. */
    .conv-page .conv-loader {
        position: fixed !important;
        inset: 0 !important;
        z-index: 1040 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto !important;
        margin: 0 !important;
        padding: 0;
        background: rgba(255, 255, 255, .6);
    }

    .conv-page .conv-loader > .row {
        margin: 0 !important;
    }

    .conv-page .conv-loader .card,
    .conv-page .conv-loader .card-body {
        background: transparent !important;
        box-shadow: none !important;
    }

    .conv-page .conv-loader .card-body {
        height: auto !important;
    }

    /* Social "Channels" popup (#iconBox): on desktop it sits at fixed page coordinates
       (the page styles' top/left and the translate-middle-x utility, hence !important on
       the transform); here it opens under the Channels toggle and stays within the screen,
       wrapping its icons when they do not fit on one line. */
    .conv-page .conv-filter-icons > div:has(> #iconBox) {
        position: relative;
    }

    /* The social pages make .list-filter scroll sideways (overflow-x: auto), which would
       clip the popup now that it opens inside the row; the icons wrap here instead. */
    .conv-page .list-filter:has(#iconBox) {
        overflow: visible;
    }

    .conv-page .conv-filter-icons #iconBox {
        top: calc(100% + 8px);
        left: 0;
        transform: none !important;
        flex-wrap: wrap;
        row-gap: 18px;
        width: max-content;
        max-width: calc(100vw - 3rem);
    }

    /* Leave a little room above the opened conversation when it is scrolled into view. */
    .conv-page .conv-detail-panel {
        scroll-margin-top: 12px;
    }

    .conv-page .conv-list-scroll {
        height: 70vh;
        height: 70dvh;
        min-height: 320px;
    }

    .conv-page .conv-detail-body {
        height: var(--conv-detail-mobile-height, auto);
    }

    .conv-page .conv-detail-scroll {
        height: 75vh;
        height: var(--conv-detail-scroll-mobile-height, calc(100dvh - 200px));
        min-height: 420px;
        overflow-x: hidden;
        overflow-y: auto;
    }
}

@media (max-width: 767.98px) {
    /* Ticket headers share the age styling without adopting the conversation layout:
       title and description on their own line, the actions on the line below. */
    /* .row > keeps these above Bootstrap's .col-* even where Bootstrap loads after this
       file (the agent layout). */
    .row > .conv-age-text,
    .row > .conv-age-actions {
        flex-basis: 100%;
        width: 100%;
    }

    /* Actions start under the description's first letter, in markup order (Create Ticket,
       table view, ticket age) for both roles: supervisor floats them right, which reversed
       the order, agent is a right-aligned flex row. Their inline floats and side margins
       are replaced by one gap. */
    .row > .conv-age-actions {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        align-items: center;
        gap: 10px !important;
        margin-top: 14px;
    }

    .row > .conv-age-actions > * {
        float: none !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* Conversation header: avatar and buttons at natural size, name takes the rest. */
    .conv-page .conv-detail-head > .col-1 {
        flex: 0 0 auto;
        width: auto;
    }

    .conv-page .conv-detail-avatar img {
        max-width: 40px;
    }

    .conv-page .conv-detail-indent {
        margin-left: 10px;
    }

    /* Reply/forward header: sender select and tool buttons stack. */
    .conv-page .conv-reply-head > [class*="col-"] {
        flex: 0 0 100%;
        width: 100%;
    }

    .conv-page .conv-reply-head > [class*="col-"] + [class*="col-"] {
        margin-top: .5rem;
    }

    /* Reply fields: fixed label column so "Subject:" never runs into its input. */
    .conv-page .conv-reply-fields .row > .col-2,
    .conv-page .conv-reply-fields .row > .col {
        flex: 0 0 auto;
        width: 4.75rem;
    }

    .conv-page .conv-reply-fields .row > .col-10 {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }
}

@media (max-width: 575.98px) {
    /* Ticket header card: its px-4 utility (!important) is too wide for phones, and pe-0
       left the actions touching its edge. */
    .card:has(.conv-age-actions) {
        padding-right: .75rem !important;
        padding-left: .75rem !important;
    }

    /* Compact the inline-sized boxes so even a long age and its full date fit
       together on phones. Override the boxes' inline font sizes and padding. */
    .conv-age-counter {
        gap: 6px 2px;
    }

    .conv-age-counter > span {
        font-size: 14px !important;
    }

    .conv-age-counter > .hours,
    .conv-age-counter > .minutes,
    .conv-age-counter > .seconds,
    .conv-age-counter > .mt-4 {
        padding: 6px !important;
    }

    .conv-age-counter > .mt-4 {
        margin-left: 0 !important;
    }

    /* Filter icons: grouped from the left as finger-sized targets with an even gap (room
       for their count badges), instead of spread across the panel. */
    .conv-page .conv-filter-icons {
        justify-content: flex-start;
        gap: 14px;
    }

    .conv-page .conv-filter-icons > * {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }

    /* Search row: input and the refresh/filter buttons share one 40px line. */
    .conv-page .conv-search-field,
    .conv-page .conv-search-actions,
    .conv-page .conv-search-actions > .row {
        align-self: center;
        align-items: center;
    }

    .conv-page .conv-search-field .search-bar {
        height: 40px;
    }

    .conv-page .conv-search-actions .icons-2 {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
    }

    /* Cards: the date leads the text column instead of floating right. Its float and
       alignment come from an inline style and the text-center utility, hence !important. */
    .conv-page .conv-card-date {
        display: block;
        float: none !important;
        padding-top: 0 !important;
        margin-bottom: 2px;
        text-align: left !important;
    }

    /* Phones: the generic avatar gives way to the customer name. */
    .conv-page .conv-detail-avatar {
        display: none;
    }

    .conv-page .conv-detail-head > [class*="col-"] {
        padding-right: 6px;
        padding-left: 6px;
    }

    .conv-page .conv-detail-head > .conv-detail-action {
        column-gap: 14px;
    }
}


/* ---------- Conversation pages that fill the screen ---------- */

/* Desktop only (.conv-fit on the .conv-layout row): the panels take the height under the
   navbar, so the page itself never scrolls and the conversation header, with its age
   counter, stays visible. 98px = navbar 70 + gap above 12 + gap below 16. Below 992px the
   variable isn't set, so every height falls back to the stacked layout's own. */
@media (min-width: 992px) {
    .content:has(.conv-fit) {
        padding: 12px 16px 0 !important;
    }

    .conv-page:has(.conv-fit) {
        padding-right: 0 !important;
        padding-left: 0 !important;
    }

    /* .conv-page prefix: Bootstrap's !important spacing utilities (py-2, mb-2, mt-3) load
       later with the same specificity, so a bare .conv-fit loses and the page scrolls. */
    .conv-page .conv-fit {
        --conv-panel-height: max(460px, calc(100vh - 98px));
        --conv-panel-height: max(460px, calc(100dvh - 98px));
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .conv-page .conv-fit > *,
    .conv-page .conv-fit .conv-empty-panel > .row,
    .conv-page .conv-fit .taggable-chat-panel,
    .conv-page .conv-fit .taggable-chat-panel > .card,
    .conv-page .conv-fit [data-split-panel="start"] > .card {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .conv-fit [data-split-panel="start"] > .card {
        height: var(--conv-panel-height);
    }

    .conv-fit [data-split-panel="start"] > .card > .card-body {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .conv-page .conv-fit .conv-list-scroll {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
    }

    .conv-fit .conv-detail-body {
        display: flex;
        flex-direction: column;
    }

    .conv-page .conv-fit .conv-detail-scroll {
        flex: 1 1 0;
        height: auto;
        min-height: 0;
    }

    /* A pinned tagging panel otherwise keeps its 684px default, or the height the script
       measured from a column that panel had already stretched. */
    .conv-fit [data-taggable-pinned="true"] [data-tagging-panel] > .offcanvas {
        height: var(--conv-panel-height);
        margin-top: 0;
    }
}

/* Compose: a compact button at the end of the channel filters. */
.conv-page .conv-filter-icons--compose {
    width: 100%;
}

/* Same even gap the narrower widths already get, so five icons and Compose fit. */
@media (min-width: 1200px) {
    .conv-page .conv-filter-icons--compose {
        gap: 8px;
    }

    .conv-page .conv-filter-icons--compose > * {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

.conv-page .conv-filter-icons > .conv-compose {
    margin-left: auto !important;
}

.conv-compose-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #00a34e;
    color: #fff;
    font-size: 14px;
    transition: background .15s;
}

.conv-compose-btn:hover {
    background: #008a42;
}


/* =====================================================================================
   Supervisor dashboard pages: Reports, Analytics (both tabs) and Chat Bot.
   Desktop is unchanged; only the breakpoints below adapt them. Each page's markup has a
   scope hook (.rp-*, .an-page, .na-page, .ib-page). This file loads before the pages'
   own styles, so every rule is scoped to win over them; !important only where the value
   to override is an inline style or a Bootstrap utility.
   ===================================================================================== */

/* ---------- Shared: pagination ---------- */

/* Page links (Livewire/Bootstrap pagination) sit on one line and ran past a narrow screen,
   making the whole page scroll sideways; they wrap onto a second line instead. */
@media (max-width: 991.98px) {
    .pagination {
        flex-wrap: wrap;
        row-gap: 4px;
    }
}

/* ---------- Reports ---------- */

/* Custom Date modal: the two dates stack on phones (col-md-6); keep a gap between them. */
.rp-date-range {
    row-gap: .75rem;
}

/* Report output and the Type / Sub Type panel side by side (the widths were inline). */
.row > .rp-main {
    width: 69%;
}

.row > .rp-side {
    width: 31%;
}

@media (max-width: 991.98px) {
    /* Type / Sub Type first, sized to its content, then the report under it; both full
       width. The panel's 60vh height is an inline style. */
    .row > .rp-main,
    .row > .rp-side {
        width: 100%;
    }

    .row > .rp-side {
        order: -1;
        margin-bottom: 1rem;
    }

    .rp-side-card {
        height: auto !important;
    }

    /* Empty state: centre the illustration instead of its desktop offset. */
    .rp-empty {
        height: 40vh !important;
        justify-content: center;
    }

    .rp-empty > div {
        margin: 0 auto !important;
    }

    /* A report table placed straight in its card (Tagging) scrolls inside it like the
       others, instead of running past the card. */
    .rp-table-card {
        overflow: auto;
    }

    /* Report filters (quarter-width columns and narrower): two per row. */
    .rp-main .row > .col-2,
    .rp-main .row > .col-3,
    .rp-main .row > .col-4 {
        flex: 0 0 50%;
        width: 50%;
    }
}

@media (max-width: 575.98px) {
    /* Header: the description is already truncated to nothing here; the refresh and date
       controls move under the title when they do not fit beside it. */
    .rp-header {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .rp-header > :last-child {
        margin-left: auto;
    }

    .rp-header .text-truncate {
        display: none;
    }

    /* Date filter: after a custom range is chosen it shows that range and grows; it may
       shrink to the line (ending with "...") instead of pushing past the screen. Its
       group carries flex-shrink-0 and the select an inline min-width, hence !important. */
    .rp-header > :last-child {
        max-width: 100%;
        min-width: 0;
    }

    .rp-date-select {
        flex: 0 1 auto;
        min-width: 0 !important;
        max-width: 100%;
        text-overflow: ellipsis;
    }

    /* Report filters: one per row. */
    .rp-main .row > .col-2,
    .rp-main .row > .col-3,
    .rp-main .row > .col-4 {
        flex: 0 0 100%;
        width: 100%;
    }
}

/* ---------- Analytics (first tab) ---------- */

@media (max-width: 991.98px) {
    /* Header: title on its own line, the refresh/filter buttons and the date dropdown on
       the line below, aligned right (the dropdown wraps under the buttons if needed). */
    .an-page .an-header-row {
        justify-content: flex-end;
        row-gap: 12px;
    }

    .an-page .an-header-text {
        flex: 0 0 100%;
        width: 100%;
    }

    .an-page .an-header-actions {
        flex: 0 0 auto;
        width: auto;
    }

    /* Its inline width (10% !important) cannot be overridden; a min-width wins over
       width, so the dropdown keeps its natural size. */
    .an-page .an-header-date {
        flex: 0 0 auto;
        min-width: max-content;
    }

    /* Charts stack one per row: drop the gap kept beside the first card (inline). */
    .an-page .an-chart-card {
        margin-right: 0 !important;
    }
}

@media (max-width: 767.98px) {
    /* Filter popup: under the header, as wide as the card, instead of a 350px box offset
       from the right edge (inline styles), which ran off the screen. */
    .an-page .an-filter-popup {
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        width: auto !important;
        max-width: 100%;
    }
}

@media (max-width: 575.98px) {
    /* Header card: even side padding instead of none on the right (px-4 pe-0 utilities),
       and the buttons' inline 18px side margins trimmed. */
    .an-page .card:has(> .card-body > .an-header-row) {
        padding-right: .75rem !important;
        padding-left: .75rem !important;
    }

    .an-page .an-header-actions .btn {
        margin: 0 0 0 8px !important;
    }

    /* Ticket counts: one per row here, so the card grows with them (inline height). */
    .an-page .an-stats-body {
        height: auto !important;
    }
}

/* ---------- Analytics (second tab) ---------- */

@media (max-width: 1199.98px) {
    /* The three columns are too narrow for their labels: Received Trend takes its own
       row and the two side cards share the row below (stacked on phones). */
    .na-page .na-col-trend {
        flex: 0 0 100%;
        width: 100%;
    }

    .na-page .na-col-side {
        flex: 0 0 50%;
        width: 50%;
    }

    /* Received Trend: on desktop the chart fills the height its row neighbours give the
       card; on its own row there is no neighbour, so it gets a height of its own. */
    .na-page .na-trend-area {
        min-height: 280px;
    }

    /* Date button: 10vw is too narrow here; keep the label on one line. */
    .na-page .analytics-date-btn {
        width: auto;
        min-width: max-content;
        white-space: nowrap;
    }
}

@media (max-width: 991.98px) {
    /* Filter popup: the overlay keeps it 254px from the right, which squeezed it on
       narrow screens; centred with an even margin instead. */
    .na-page .analytics-filter-overlay {
        justify-content: center;
        padding: 80px 1rem 1rem;
    }
}

@media (max-width: 575.98px) {
    .na-page .na-col-side {
        flex: 0 0 100%;
        width: 100%;
    }

    /* Header: the buttons wrap under the title when they do not fit beside it. */
    .na-page .na-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .na-page .na-header .header-actions {
        margin-left: auto;
    }

    .na-page .na-trend-area {
        min-height: 220px;
    }

    .na-page .sla-item {
        padding: 0 .75rem;
    }

    /* Filter popup: two options per row, dates one per row. */
    .na-page .analytics-filter-options,
    .na-page .analytics-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .na-page .analytics-date-range {
        grid-template-columns: 1fr;
    }

    .na-page .analytics-date-field {
        min-width: 0;
        width: 100%;
    }
}

/* ---------- Chat Bot ---------- */

@media (max-width: 1199.98px) {
    /* Engagements: on desktop the card shares a row and its list scrolls inside a 10vh
       body (inline style); stacked, it shows the whole list. */
    .ib-page .ibot-span-2-rows > .card:first-child > .card-body {
        height: auto !important;
    }
}

@media (max-width: 991.98px) {
    /* Filter panel: its overlay keeps it 80px from the right (inline styles), which
       squeezed it on narrow screens; centred with an even margin. */
    .ib-page .ibot-filter-overlay {
        justify-content: center !important;
        padding: 80px 1rem 1rem !important;
    }
}

@media (max-width: 575.98px) {
    /* Filter dates: one per row so each field has room. */
    .ib-page .ibot-date-range {
        flex-direction: column;
    }

    /* Average Handling Time rows: label and value on the first line, the sparkline full
       width under them, instead of squeezing the label beside a half-width chart (w-50
       is an !important utility). */
    .ib-page .sla-card .sla-item {
        flex-wrap: wrap;
        gap: 4px 12px;
    }

    .ib-page .sla-card .sla-item > p {
        flex: 1 1 0;
        min-width: 0;
    }

    .ib-page .sla-card .sla-item > .chart-container {
        order: 1;
        width: 100% !important;
    }
}

/* =====================================================================================
   Tickets table (agent and supervisor). Hooks: .tk-header (header row) and .tk-content
   (table component root). The filter and search popups are positioned for desktop by
   the page styles and inline styles; below 768px they open under the header instead,
   as wide as the page.
   ===================================================================================== */

@media (max-width: 1199.98px) {
    /* Header: the icons and Create ticket wrap to a second line instead of running past
       the card. */
    .tk-header .filters-block {
        flex-wrap: wrap;
    }

    /* Table: cells keep to one line and the table scrolls sideways in its card, instead
       of squeezing each column to a word per line. */
    .tk-content .table td {
        white-space: nowrap;
    }
}

@media (max-width: 767.98px) {
    /* Header: title and description on their own line (its 43% width is inline), the
       actions on the line below, right-aligned. */
    .card-body:has(> .tk-header) {
        padding-right: .25rem;
        padding-left: .25rem;
    }

    .tk-header > :first-child,
    .tk-header .filters-block {
        width: 100% !important;
    }

    .tk-header .filters-block {
        column-gap: 6px;
    }

    .tk-header .filters-block > .mx-2 {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    /* Popups anchor to the table component, right under the header. */
    .tk-content {
        position: relative;
    }

    .tk-content > #filter {
        top: 0;
        right: 0 !important;
        left: 0;
        width: auto !important;
        max-width: 420px;
        height: auto;
        margin: 0 auto;
        padding: 0 12px 20px;
        transform: none;
    }

    /* Its option rows are 360px wide (inline !important); max-width still wins. */
    .tk-content > #filter > .row > .row {
        max-width: 100% !important;
    }

    /* Search: its inline top (240px !important) cannot be overridden, so a matching
       negative margin brings it back to the top of the table. */
    .tk-content > #search {
        right: 0;
        left: 0 !important;
        width: auto !important;
        margin-top: -240px;
        transform: none !important;
    }

    .tk-content > #search > .row {
        flex-wrap: nowrap;
        align-items: center;
    }

    .tk-content > #search > .row > .col-1,
    .tk-content > #search > .row > .col-3 {
        flex: 0 0 auto;
        width: auto;
    }

    .tk-content > #search > .row > .col-8 {
        flex: 1 1 0;
        min-width: 0;
    }

    .tk-content > #search input {
        width: 100% !important;
        margin: 0 !important;
    }
}

@media (max-width: 575.98px) {
    /* Filter options: three per row as on desktop (col-sm-4 would stack them). */
    .tk-content > #filter .col-sm-4 {
        flex: 0 0 33.3333%;
        width: 33.3333%;
    }
}

/* Ticket open in the list view (agent and supervisor). Hooks: .tk-list (the columns row),
   .tk-list-middle (details), .tk-list-right (customer, Ticket Info, Customer History),
   .tk-categories (the details' Categories row). The page also carries the conversation
   hooks (.conv-page, .conv-layout, .conv-detail-panel), so conversation-responsive.js
   scrolls to the details when a ticket is opened on small screens, as in chat/social. */
@media (max-width: 991.98px) {
    /* Columns that wrap get space between them instead of touching. */
    .tk-list {
        row-gap: 1.5rem;
    }

    /* Right side under the others. */
    .tk-list > .tk-list-right {
        width: 100%;
    }

    /* Categories: a label that wraps no longer pushes its field below its neighbours';
       the fields line up along the bottom of the row. */
    .tk-categories > .col-4 {
        display: flex;
        flex-direction: column;
    }

    .tk-categories > .col-4 > p {
        flex: 1 0 auto;
    }
}

@media (max-width: 575.98px) {
    /* Categories: two per row, so labels and values fit instead of a few letters each. */
    .tk-categories > .col-4 {
        width: 50%;
    }
}

/* Right side cards, at any width: they sat in .row wrappers whose negative margins made
   them wider than the list and details cards (and than each other); flush with the
   column instead. */
.tk-list-right .row.source-list,
.tk-list-right .ticket-right-side > .row.rs-section {
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
}

@media (min-width: 992px) {
    /* Desktop (and zoomed-in desktop): three columns while each has room for its content;
       otherwise the right side moves to its own full-width line and the details take the
       room it leaves. On a wide screen the minimums are never reached, so nothing moves. */
    .tk-list {
        row-gap: 1.5rem;
    }

    .tk-list > :first-child {
        min-width: 260px;
    }

    .tk-list > .tk-list-middle {
        flex-grow: 1;
        min-width: 420px;
    }

    .tk-list > .tk-list-right {
        flex-grow: 1;
        min-width: 300px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Tablets: list and details side by side (a third each left the details too narrow),
       the right side full width below them. */
    .tk-list > .tk-list-middle {
        width: 66.6667%;
    }
}

/* Right side content, at any width: when its column is too narrow for a row of items,
   the items move to the next line one at a time instead of squeezing their words apart.
   With enough room nothing changes. */

/* Customer card: "Owner" drops under the name, the name is cut with "...", and a long
   phone number or email breaks instead of running past the card. The card grows with
   it (its 110px height is inline). */
.ticket-right-side .row.source-list:has(#cust) {
    height: auto !important;
    min-height: 110px;
}

.ticket-right-side #cust > .flex-column {
    flex: 1 1 auto;
    min-width: 0;
}

.ticket-right-side #cust > .flex-column > :first-child {
    flex-wrap: wrap;
    min-width: 0;
}

.ticket-right-side #cust > .flex-column > :first-child > :is(a, span) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-right-side #cust .small > div {
    word-break: break-all;
}

/* Card titles ("Ticket Info") take the room the chevron leaves. */
.ticket-right-side .collapsible-card-head > .col-6:first-child {
    flex: 1 1 0;
    width: auto;
}

.ticket-right-side .collapsible-card-head > .col-6 + .col-6 {
    flex: 0 0 auto;
    width: auto;
}

/* Source ID / Source / Status: thirds while each has room for its label, otherwise
   the last one moves to the next line. */
.ticket-right-side .rs-scroll .row.gx-2 > .col-4 {
    flex: 1 1 0;
    min-width: 7rem;
}

/* Owner: the Change button moves under the name instead of squeezing it. */
.ticket-right-side .ownership-owner-box {
    flex-wrap: wrap;
}

.ticket-right-side .ownership-owner-box > .flex-grow-1 {
    flex-basis: 7rem;
    min-width: 0;
}

/* Every column in the list view: never narrower than its content's narrowest form (its
   longest word, a button), so instead of overflowing or breaking words it moves to the
   next line (Bootstrap rows wrap). Full-width columns and those holding a table are
   left alone, so tables keep scrolling inside their card. */
.tk-list .row > [class*="col"]:not(.col-12):not(:has(table)) {
    min-width: min-content;
}

/* Ticket details, Status and the response timer: always side by side. The timer's width
   changes with its digits, so with the rule above it moved under Status for some tickets
   and not others. Its column keeps its desktop third but never gets narrower than its
   label on one line; Status takes the rest. */
.tk-list .row.tk-sla-row {
    flex-wrap: nowrap;
}

.tk-list .row.tk-sla-row > [class*="col"].col-8 {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    overflow-wrap: break-word;
}

.tk-list .row.tk-sla-row > [class*="col"].col-4 {
    flex: 0 0 auto;
    width: 33.3333%;
    min-width: max-content;
}

.tk-list .row.tk-sla-row > .col-4 h6 {
    white-space: nowrap;
}

/* Create Ticket form (agent and supervisor). Hook: .tk-create-form (the form's row). Its
   fields are a third or half of the row at every width (col-4 / col-6); on small screens
   each field takes its own row, so inputs, dropdowns and their options have room. */
@media (max-width: 767.98px) {
    .tk-create-form > .col-4,
    .tk-create-form > .col-6 {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* =====================================================================================
   Dashboard (agent and supervisor). Hooks: .db-page (component root), .db-channels and
   .db-stats (the channel and ticket-count rows), .db-trend (Today's Trend) and .db-time
   (Time Statistics). Items keep their desktop sizes while they fit and move to the next
   line when they do not, so a zoomed-in desktop adapts like a small screen.
   ===================================================================================== */

/* The channel and count rows were 110px high (inline); when their content wraps they
   grow with it instead of running over the trend chart. */
.db-page {
    container: dashboard / inline-size;
    min-width: 0;
}

.db-page .db-channels,
.db-page .db-stats {
    height: auto;
    margin-bottom: 1.5rem;
}

.db-page .db-channels > *,
.db-page .db-stats > *,
.db-page .db-charts > * {
    min-width: 0;
}

.db-page .db-channels .card-body {
    min-width: 0;
    gap: 12px;
}

/* All channels remain reachable with touch, trackpad, or keyboard scrolling. The strip
   shrinks (and scrolls) when narrow but does not grow: its page styles space the icons
   with space-between, which spread them across the whole card when it filled it. */
.db-page .db-top-scroll {
    flex: 0 1 auto;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.db-page .db-top-scroll > * {
    flex: 0 0 auto;
}

.db-page .db-stats .card {
    padding: 12px !important;
}

.db-page .db-stats #down {
    width: 100%;
    margin: 0;
    gap: 12px;
    align-items: center;
}

.db-page .db-stats #down > .text-color {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 160px;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 8px;
    overflow-wrap: anywhere;
}

.db-page .db-stats .text-color > .float-left {
    float: none;
    margin: 0;
}

.db-page .db-stats .text-color > .float-left:first-child {
    flex: 0 0 50px;
}

.db-page .db-stats .text-color img {
    width: 50px;
    height: 50px !important;
    object-fit: contain;
    margin: 0 !important;
}

.db-page .db-stats #down > .d-flex {
    flex: 0 0 auto;
    width: auto !important;
    margin-left: auto;
    padding: 8px;
}

.db-page .db-stats #down > .d-flex .btn {
    margin-top: 0 !important;
}

.db-page .db-charts {
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(280px, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.db-page .db-trend,
.db-page .db-time {
    width: 100%;
    float: none;
}

.db-page .db-charts .card {
    height: 100%;
}

.db-page .db-trend #down_3 {
    width: 100%;
    margin: 0;
    gap: 12px;
    align-items: center;
}

.db-page .db-trend-title {
    flex: 1 1 240px;
    min-width: 0;
    padding: 0;
    overflow-wrap: anywhere;
}

.db-page .db-trend-toggle {
    flex: 0 0 auto;
    width: auto;
    padding: 0;
}

/* Keep the existing checkbox appearance, but let labels participate in layout. */
.db-page .db-trend-toggle label {
    padding-left: 36px;
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-right: 4px;
}

.db-page .db-trend-toggle label span {
    position: static;
    transform: none;
}

.db-page .db-trend-toggle label::before {
    top: 7px;
}

.db-page .db-trend-toggle label::after {
    top: 19px;
}

.db-page .db-trend-toggle input:focus-visible + label {
    outline: 2px solid #00a34e;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Chart.js measures this dedicated parent instead of using its default 2:1 ratio. */
.db-page .db-chart {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    height: 300px;
    padding: 0;
}

.db-page .db-chart canvas {
    display: block;
}

.db-page .db-time #down_2 > .row {
    margin: 0;
}

.db-page .db-time #down_2 h5 {
    overflow-wrap: anywhere;
}

/* Voice statistics use the available component width, including browser zoom. */
.db-page .row > .col-3.box {
    flex: 1 1 240px;
    width: auto !important;
    min-width: 0;
    margin-left: 0 !important;
    margin-right: 12px;
}

@container dashboard (max-width: 900px) {
    .db-page .db-charts {
        grid-template-columns: minmax(0, 1fr);
    }
}

@container dashboard (max-width: 480px) {
    /* Ticket counts: two per row as compact tiles (icon above the number and label), with
       the filter button in the sixth cell, instead of one count per row and the filter
       alone under them. */
    .db-page .db-stats #down {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .db-page .db-stats #down > .text-color {
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        padding: 10px 6px;
        text-align: center;
        overflow-wrap: normal;
    }

    .db-page .db-stats .text-color > .float-left:first-child {
        flex-basis: auto;
    }

    .db-page .db-stats .text-color img {
        width: 44px;
        height: 44px !important;
    }

    .db-page .db-stats #down > .d-flex {
        justify-content: center !important;
        align-items: center;
        margin: 0;
    }

    .db-page .db-trend-title {
        flex-basis: 100%;
    }

    .db-page .db-chart {
        height: 260px;
    }
}

/* Viewport fallback also covers browsers without container query support. */
@media (max-width: 991.98px) {
    .db-page .db-charts {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Real-time dashboards (agent and supervisor): use component width so the layout
   also adapts to the navigation sidebar, browser zoom, and split windows. */
.main > .content:has(.rt-page) {
    padding: 24px clamp(16px, 3vw, 48px) !important;
}

.rt-page {
    container: realtime-dashboard / inline-size;
    min-width: 0;
}

.rt-page .rt-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: clamp(16px, 3vw, 30px);
    margin-bottom: 24px;
}

.rt-page .rt-header-text {
    flex: 1 1 240px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.rt-page .rt-header-text h5 {
    margin-bottom: 8px;
}

.rt-page .rt-header-actions {
    flex: 0 0 auto;
    margin-left: auto;
}

.rt-page .rt-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 44px;
    border-color: #e2e2e2;
}

.rt-page .rt-layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
    align-items: start;
    gap: 24px;
    margin-bottom: 24px;
}

.rt-page .rt-main,
.rt-page .rt-sidebar {
    min-width: 0;
}

.rt-page .rt-table-scroll {
    max-width: 100%;
    max-height: min(620px, 75vh);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.rt-page .rt-table-scroll > table {
    min-width: 960px;
    margin-bottom: 0;
}

.rt-agent .rt-table-scroll > table {
    min-width: 1100px;
}

.rt-page .rt-table-scroll > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
    background-color: #f8f9fa;
}

.rt-page .rt-table-scroll th:has(.dropdown-menu.show) {
    z-index: 3;
}

.rt-page .rt-table-scroll .dropdown-menu {
    max-height: min(320px, 50vh);
    max-width: calc(100vw - 48px);
    overflow-y: auto;
}

/* Popper positions the status filter against the viewport so a short, empty
   table cannot clip it. Show all statuses without an inner scrollbar. */
.rt-page .rt-table-scroll .rt-status-filter-menu {
    max-height: none;
    overflow: visible;
}

/* Time values keep one line without the old 100px of button padding. */
.rt-page .rt-table-scroll .but,
.rt-page .rt-table-scroll .but2 {
    width: 100%;
    min-width: max-content;
    padding: 5px 12px;
    white-space: nowrap;
}

.rt-page .rt-sidebar {
    container: realtime-sidebar / inline-size;
    display: grid;
    gap: 16px;
}

.rt-page .rt-queues {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.rt-page .rt-queues-title {
    grid-column: 1 / -1;
}

.rt-page .rt-sidebar h6 {
    font-weight: 600;
    text-align: center;
    margin-bottom: 0;
    overflow-wrap: anywhere;
}

.rt-page .rt-queue-card h1 {
    text-align: center;
    margin: 0;
    overflow-wrap: anywhere;
}

.rt-page .rt-status-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding-block: 8px;
}

.rt-page .rt-status-item {
    min-width: 0;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.rt-page .rt-statistics-scroll {
    max-width: 100%;
    overflow-x: auto;
    margin-top: 16px;
}

.rt-page .rt-statistics-scroll table {
    min-width: 260px;
    margin-bottom: 0;
}

.rt-page .rt-table-scroll:focus-visible,
.rt-page .rt-statistics-scroll:focus-visible {
    outline: 2px solid #00a34e;
    outline-offset: 2px;
}

@container realtime-dashboard (max-width: 1100px) {
    .rt-page .rt-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@container realtime-sidebar (max-width: 300px) {
    .rt-page .rt-status-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

@container realtime-sidebar (max-width: 240px) {
    .rt-page .rt-queues {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1199.98px) {
    .rt-page .rt-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Agent notifications: shared by the routed page and single-page dashboard. */
.agent-notifications-page {
    container: agent-notifications / inline-size;
    min-width: 0;
    padding-block: 16px;
}

.agent-notifications-page .agent-notifications-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.agent-notifications-page .agent-notification-item {
    min-width: 0;
}

.agent-notifications-page .agent-notification-link {
    cursor: pointer;
}

.agent-notifications-page .agent-notification-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    height: 100%;
    padding: 16px;
    background: white;
}

.agent-notifications-page .agent-notification-icon img {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.agent-notifications-page .agent-notification-content {
    min-width: 0;
    overflow-wrap: anywhere;
}

.agent-notifications-page .agent-notification-content > span:first-child {
    display: block;
    margin-bottom: 6px;
    line-height: 1.5;
}

.agent-notifications-page .agent-notification-content p {
    line-height: 1.6;
}

.agent-notifications-page .agent-notification-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.agent-notifications-page .agent-notification-actions .btn {
    flex: 1 1 88px;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.agent-notifications-page .agent-notification-actions .badge {
    white-space: normal;
    overflow-wrap: anywhere;
}

.agent-notifications-page .agent-notifications-empty {
    grid-column: 1 / -1;
    padding: 48px 0;
}

.agent-notifications-page .agent-notifications-empty img {
    max-width: 100%;
    height: auto;
}

/* Keep the existing jQuery filter toggle, with sizing scoped to this page. */
.agent-notifications-page .notification-filter {
    display: none;
    position: fixed;
    z-index: 1055;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(335px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 12px;
}

.agent-notifications-page .notification-filter .row {
    margin-left: 0;
    margin-right: 0;
}

.agent-notifications-page .notification-filter .form-control {
    min-width: 0;
}

@container agent-notifications (max-width: 760px) {
    .agent-notifications-page .agent-notifications-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
}

@media (max-width: 991.98px) {
    .agent-notifications-page .agent-notifications-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
}

/* Performance Scorecards (agent: ranking/dashboard, supervisor: ranking/supervisor-dashboard).
   Hooks: .scorecards-page (root), .sc-header / .sc-header-text / .sc-header-actions /
   .sc-date-filter / .sc-refresh (page header), .sc-legend (a row of legend items),
   .sc-ranking-scroll (the ranking table). */
.scorecards-page {
    container: scorecards / inline-size;
    min-width: 0;
}

.scorecards-page .container-fluid {
    padding-inline: 0;
}

.scorecards-page .sc-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.scorecards-page .sc-header-text {
    flex: 1 1 280px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.scorecards-page .sc-header-text h5 {
    line-height: 1.5;
}

.scorecards-page .sc-header-text p {
    margin-bottom: 0;
}

.scorecards-page .sc-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 270px;
    min-width: 0;
}

.scorecards-page .sc-date-filter {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 44px;
    background-color: white;
}

.scorecards-page .sc-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    height: 44px;
    border: 1px solid #bdbdbd;
    border-radius: 6px;
    padding: 8px;
}

.scorecards-page .sc-ranks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 16px;
}

.scorecards-page .sc-rank {
    min-width: 0;
    overflow-wrap: anywhere;
}

.scorecards-page .sc-rank > .card {
    height: 100%;
    padding: 16px !important;
}

.scorecards-page .sc-rank .row {
    margin: 0;
}

.scorecards-page .sc-rank .row > * {
    padding: 0;
    width: 100%;
}

.scorecards-page .sc-rank #card-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.scorecards-page .sc-summary-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 24px;
}

.scorecards-page .sc-summary-layout > * {
    min-width: 0;
    overflow-wrap: anywhere;
}

.scorecards-page .sc-summary-layout > * > .card {
    padding-inline: 0 !important;
}

.scorecards-page .sc-summary-layout .row {
    margin-inline: 0;
}

.scorecards-page .sc-summary-stat {
    flex: 1 1 130px;
    min-width: 0;
    padding: 8px;
}

.scorecards-page .sc-summary-stat .row > * {
    margin: 0 !important;
    padding: 12px;
}

.scorecards-page .sc-summary-stat h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.scorecards-page .sc-summary-stat #thisWeekCard {
    position: static;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.scorecards-page .sc-current-rank h3 {
    font-size: 20px;
}

.scorecards-page #profilePerformancedataCard {
    min-width: 0;
    overflow-wrap: anywhere;
}

.scorecards-page #profilePerformancedataCard > .m-2 {
    margin: 0 !important;
}

.scorecards-page #performanceIcon {
    max-width: 100%;
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.scorecards-page .sc-ranking-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.scorecards-page .sc-ranking-scroll table {
    min-width: 640px;
}

/* Legend rows (performance levels, ranking arrows): each item keeps its label on one
   line and moves to the next line when there is no room beside the title. */
.scorecards-page .sc-legend {
    row-gap: 8px;
}

.scorecards-page .sc-legend > [class*="col"] {
    min-width: max-content;
}

.scorecards-page #datepicker .form-control {
    min-width: 0;
}

@container scorecards (max-width: 900px) {
    .scorecards-page .sc-summary-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .scorecards-page .row > .col-lg-3 {
        flex: 0 0 50%;
        width: 50%;
    }
}

@container scorecards (max-width: 480px) {
    .scorecards-page .sc-header-actions {
        flex: 1 1 100%;
    }

    .scorecards-page .row > .col-lg-3 {
        flex-basis: 100%;
        width: 100%;
    }
}

@media (max-width: 991.98px) {
    .scorecards-page .sc-summary-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Agent Reports reuse the supervisor .rp-main / .rp-side breakpoints: filters
   come first on smaller screens, with the report output below them. */
.agent-reports-header {
    margin-inline: 0;
}

.agent-reports-header .rp-agent-header-card {
    padding: 20px;
}

.agent-reports-header .rp-agent-header-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.agent-reports-header .rp-agent-header-text p {
    margin-bottom: 0;
}

.agent-reports-page {
    min-width: 0;
}

.agent-reports-page .rp-agent-layout {
    margin-inline: 0;
    align-items: flex-start;
    row-gap: 16px;
}

.agent-reports-page .rp-agent-main {
    min-width: 0;
    padding: 0 24px 0 0;
}

.agent-reports-page .rp-agent-table {
    max-width: 100%;
    max-height: 60vh;
    overflow: auto;
    overscroll-behavior: contain;
}

.agent-reports-page .rp-agent-table table {
    min-width: 640px;
}

.agent-reports-page .rp-agent-table th,
.agent-reports-page .rp-agent-table td {
    white-space: nowrap;
}

.agent-reports-page .rp-agent-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 24px;
}

.agent-reports-page .rp-agent-empty img {
    max-width: 100%;
    height: auto;
}

.agent-reports-page .rp-agent-filters {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: 70vh;
    border-radius: 10px;
    padding: 16px;
}

.agent-reports-page .rp-agent-filter-body {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.agent-reports-page .rp-agent-filter-body .checkboxstyle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 36px;
    height: auto;
    margin: 0 6px 10px 0 !important;
    padding: 6px 10px;
    white-space: normal;
    text-align: left;
    overflow-wrap: anywhere;
}

.agent-reports-page .checkboxstyle .form-check-input {
    flex: 0 0 auto;
    margin-top: 0;
}

.agent-reports-page .rp-agent-filter-body .row {
    margin-inline: 0 !important;
}

.agent-reports-page .rp-agent-filter-body .form-control,
.agent-reports-page .rp-agent-filter-body .form-select {
    min-width: 0;
    max-width: 100%;
}

.agent-reports-page .rp-agent-filter-footer {
    flex: 0 0 auto;
    padding-top: 16px;
}

.agent-reports-page .rp-agent-filter-footer .btnapplay {
    float: none;
    width: 100%;
    min-height: 44px;
    margin: 0;
}

@media (max-width: 991.98px) {
    .agent-reports-page .rp-agent-main {
        padding: 0;
    }

    .agent-reports-page .rp-agent-filters {
        max-height: none;
        margin-bottom: 0;
    }

    .agent-reports-page .rp-agent-filter-body {
        overflow: visible;
    }
}

/* Assignment page (supervisor). Hook: .asg-header (the header card). Its page styles
   load after this file, so each rule is scoped one level deeper than theirs. */

@media (max-width: 991.98px) {
    /* Header: the title on its own line and the actions (floated right, with inline
       margins) in one row under it, in their desktop order, wrapping as whole buttons
       instead of scattering over several lines. */
    .asg-header {
        display: flex;
        flex-direction: row-reverse;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        position: relative;
    }

    .asg-header > * {
        float: none !important;
        margin: 0 !important;
    }

    .asg-header > .form-group:first-child {
        flex: 0 0 100%;
    }

    /* Search popup: anchored to the header card instead of the search button, so it
       spans the card and stays on screen. */
    .asg-header > .assignment-search-wrapper {
        position: static !important;
    }

    .asg-header .assignment-search-popup {
        top: calc(100% + 8px);
        right: 0;
        left: 0;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 575.98px) {
    /* Reassign: its 40px side padding (inline) left no room for the other actions. */
    .asg-header > #reassignBtn {
        padding-right: 16px !important;
        padding-left: 16px !important;
    }
}

/* The popup is 520px wide, capped at 96vw, inside an overlay with 24px side padding: on
   a phone it was wider than the space it is centred in, and both edges were cut. It
   never gets wider than that space. */
.assignment-filter-overlay > .assignment-filter-modal {
    max-width: 100%;
}

/* Date range: the two date inputs never shrank below their built-in width, which pushed
   the popup's content past its edges; the columns give way instead. */
.assignment-filter-modal .assignment-date-range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.assignment-filter-modal .assignment-date-input,
.assignment-filter-modal .assignment-date-field {
    min-width: 0;
}

@media (max-width: 575.98px) {
    body .assignment-filter-overlay {
        padding-right: 12px;
        padding-left: 12px;
    }

    /* Phones: one date per row, so each shows its whole value. */
    .assignment-filter-modal .assignment-date-range {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Canned Responses table view (supervisor): the search pop-over is 380px (up to 80vw)
   and opens leftwards from the search icon, which on small screens sits mid-card, so it
   ran off the left. There it becomes part of the header card instead: its own full-width
   line under the action buttons, the card growing to hold it. The wrapper around the
   icon and the pop-over steps out of the layout (display: contents) so the pop-over can
   take that line. Its page styles use !important on #cannedSearch, hence the extra .card
   level here. */
@media (max-width: 991.98px) {
    .card .cr-search-wrap {
        display: contents;
    }

    .card #cannedSearch {
        position: static !important;
        order: 10;
        flex: 0 0 100%;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
    }

    .card #cannedSearch input {
        min-width: 0;
    }
}

/* Dashboard > Survey tab (supervisor, survey-dashboard component). Hooks: .sv-dash (root),
   .sv-header / .sv-filters (header card and its two selects), .sv-donut (Completed
   Survey) and .sv-bar (the stacked bar chart). */
@media (max-width: 991.98px) {
    /* Charts one per row at full width: the bar chart's 73% width is inline !important
       (a min-width still wins) and both were floated side by side. */
    .sv-dash .sv-donut,
    .sv-dash .sv-bar {
        float: none !important;
    }

    .sv-dash .sv-bar {
        min-width: 100%;
        margin-top: 1.5rem;
    }
}

@media (max-width: 767.98px) {
    /* Header: the two selects (37vw wide, inline) move under the title at full width. */
    .sv-dash .sv-header {
        flex-wrap: wrap;
        row-gap: 12px;
    }

    .sv-dash .sv-header > .form-group {
        margin-left: 0 !important;
    }

    .sv-dash .sv-filters {
        width: 100% !important;
        margin: 0;
    }
}

/* =====================================================================================
   Supervisor Notifications (tenant/supervisor/notification + its Livewire view).
   Hooks: .ntf-page (root), .ntf-tabbar (tabs row), .ntf-tabs (the tab list),
   .ntf-filter (Auditor Cycle filter dropdown), .ntf-table-wrap (the card around each
   tab's table: tickets, ownership, auditor, sentiment), .ntf-modal / .ntf-modal-body /
   .ntf-modal-footer (the topic and sentiment modals).
   Desktop is untouched: everything below is inside max-width queries.
   ===================================================================================== */

@media (max-width: 991.98px) {
    .ntf-page {
        min-width: 0;
    }

    /* Tables keep a readable width and scroll sideways inside their card; the 85vh
       height is inline, so it is overridden here to stop a tall empty card. */
    .ntf-page .ntf-table-wrap {
        height: auto !important;
        max-height: 75vh;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .ntf-page .ntf-table-wrap .table {
        min-width: 640px;
    }

    .ntf-page .ntf-table-wrap .table td,
    .ntf-page .ntf-table-wrap .table th {
        white-space: nowrap;
    }
}

@media (max-width: 767.98px) {
    /* Tab bar: tabs on one scrollable line, the filter dropdown full width below. */
    .ntf-page .ntf-tabbar {
        flex-wrap: wrap;
        align-items: stretch !important;
    }

    .ntf-page .ntf-tabs {
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ntf-page .ntf-tabs > li {
        flex: 0 0 auto;
    }

    .ntf-page .ntf-tabs .nav-link {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    /* Filter: full width; its inline min-width/margins are for the desktop row. */
    .ntf-page .ntf-filter {
        flex: 1 1 100%;
        margin: 8px 12px !important;
    }

    .ntf-page .ntf-filter > .btn {
        width: 100%;
        min-height: 44px;
    }

    .ntf-page .ntf-filter .dropdown-menu {
        width: 100%;
    }

    .ntf-page .ntf-filter .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        white-space: normal;
    }

    /* Tap targets for row actions (approve/reject/view/edit icons, ownership buttons). */
    .ntf-page .ntf-table-wrap .btn-sm {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Modals: fit the viewport width, tighter padding, full-width footer buttons. */
    .ntf-modal {
        margin: 8px auto;
        width: calc(100vw - 16px);
        max-width: none;
    }

    .ntf-modal .ntf-modal-body {
        padding: 16px !important;
    }

    .ntf-modal .ntf-modal-footer {
        padding: 0 16px 16px !important;
        flex-wrap: nowrap;
    }

    .ntf-modal .ntf-modal-footer .btn {
        flex: 1 1 0;
        min-height: 44px;
        margin: 0 !important;
    }

    .ntf-modal .modal-header .btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* =====================================================================================
   Agent Notifications. The page itself is already responsive (.agent-notifications-*
   sections above); what remained was the filter popup (.notification-filter), whose
   tiny labels/inputs were hard to tap and whose columns stacked one per line.
   No new hooks: scoped by the existing .agent-notifications-page.
   ===================================================================================== */

@media (max-width: 575.98px) {
    /* Dates are 10px inline; make them legible on phones. */
    .agent-notifications-page .agent-notification-content > span:first-child {
        font-size: 12px !important;
    }

    /* Filter popup: channel chips two per row instead of one per line; the empty spacer
       column is hidden so the grid does not leave a hole. */
    .agent-notifications-page .notification-filter .filter-pading {
        flex: 0 0 50%;
        max-width: 50%;
        padding-right: 10px;
    }

    .agent-notifications-page .notification-filter .filter-pading:empty {
        display: none;
    }

    .agent-notifications-page .notification-filter .box-sta-filter {
        display: flex;
        align-items: center;
        gap: 4px;
        min-height: 40px;
        font-size: 12px;
    }

    /* 16px stops iOS zooming the page when a date field gets focus. */
    .agent-notifications-page .notification-filter .form-control {
        min-height: 40px;
        font-size: 16px !important;
    }

    .agent-notifications-page .notification-filter .btn {
        min-height: 44px;
    }
}

/* =====================================================================================
   Reset Password pages (tenant/auth/passwords: email, reset, username, confirm).
   NOTE: tenant.layouts.auth loads only css/auth_style.css, NOT this file; the layout
   needs a <link> to conversation-responsive.css (or this block moved into
   auth_style.css) before these rules apply.
   Hooks: .rpw-page (the .login-section wrapper), .rpw-logo (logo image), .rpw-row (the
   row under the container), .rpw-hero / .rpw-hero-title / .rpw-hero-img (left column:
   welcome text and animation), .rpw-form-col (form column), .rpw-form (the form card),
   .rpw-title (the "Reset Password" heading with side lines); confirm page:
   .rpw-confirm / .rpw-confirm-row / .rpw-confirm-card.
   ===================================================================================== */

@media (max-width: 991.98px) {
    /* The section has an inline height: 83vh; taller content (stacked columns) used to
       overflow it, so let it grow. */
    .rpw-page {
        height: auto !important;
        min-height: 83vh;
        padding-bottom: 24px !important;
    }

    .rpw-page .rpw-logo {
        width: 64px;
        height: auto;
    }

    .rpw-page .logo-col {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .rpw-page .rpw-row {
        padding: 8px !important;
    }

    /* Hero: keep the welcome line, drop the big animation so the form is on screen. */
    .rpw-page .rpw-hero {
        margin-bottom: 16px !important;
    }

    .rpw-page .rpw-hero-img {
        max-width: 60%;
        height: auto;
    }

    .rpw-page .rpw-form-col {
        width: 100%;
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 575.98px) {
    .rpw-page {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .rpw-page .rpw-hero-title {
        font-size: 1.05rem;
        letter-spacing: normal !important;
        word-spacing: normal !important;
    }

    .rpw-page .rpw-hero-img {
        display: none;
    }

    /* Heading: smaller text and shorter side lines so they never run into it
       (the lines are percentages of the heading; username.blade has its own 17% inline). */
    .rpw-page .login-lable-h1.rpw-title {
        font-size: 1.4rem;
    }

    .rpw-page .login-lable-h1.rpw-title::before,
    .rpw-page .login-lable-h1.rpw-title::after {
        width: 8%;
    }

    .rpw-page .rpw-form .form-floating > .form-control {
        min-height: 44px;
        font-size: 16px; /* no iOS zoom on focus */
    }

    .rpw-page .rpw-form .btn {
        min-height: 48px;
        white-space: normal;
    }

    .rpw-page .rpw-form .under-button {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .rpw-page .rpw-form .alert {
        overflow-wrap: anywhere;
    }

    /* Confirm password: inline 83vh row must not clip the card on short phones. */
    .rpw-confirm .rpw-confirm-row {
        height: auto !important;
        min-height: 83vh;
        padding-top: 16px;
    }

    .rpw-confirm .rpw-confirm-card .form-control {
        min-height: 44px;
        font-size: 16px;
    }

    .rpw-confirm .rpw-confirm-card .btn {
        min-height: 44px;
    }

    /* The button sits under an offset column; stack it full width on phones. */
    .rpw-confirm .rpw-confirm-card .btn-primary {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ==========================================================================
   Evaluation (supervisor: index, create group, create/edit question, form builder,
   report, report answers, submit evaluation form, type-evaluation list;
   agent: report answers). All rules are opt-in via .ev-* hooks and only change
   anything below 992px; desktop is untouched.

   The pages' own <style> blocks load AFTER this file, so selectors start with
   .ev-page (extra specificity) and !important is used only to beat inline styles
   or the page <style> rules written with !important.

   Hooks
   Root (scope)       .ev-page  +  .ev-index / .ev-report / .ev-answers (supervisor and
                      agent report answers) / .ev-create-group / .ev-create-question /
                      .ev-edit-question / .ev-create-form-builder /
                      .ev-submit-evaluation-form / .ev-type
   Header card        .ev-header-row (row) / .ev-header-text (title column) /
                      .ev-header-actions (buttons, search, date column; was absolutely
                      positioned) / .ev-icon-btn / .ev-date-field (report date pickers)
   Tables             .ev-table-scroll (scroll wrapper) / .ev-table
   Modals             .ev-modal (.modal) / .ev-modal-content (.modal-content)
   Popovers           .ev-popover (create group: weight / name editors)
   Report             .ev-sections (row) / .ev-results / .ev-filter-panel /
                      .ev-filter-options / .ev-back
   Answers + submit   .ev-info (info card) / .ev-info-fields / .ev-info-col /
                      .ev-score (score card) / .ev-score-boxes / .ev-score-chart /
                      .ev-voice / .ev-actions
   Edit question      .ev-edit-card / .ev-edit-cols / .ev-edit-col
   Form builder       .ev-builder (row) / .ev-builder-main / .ev-builder-side
   Type evaluation    .ev-filter (filter card) / .ev-filter-btn (apply / limit / advanced)
   ========================================================================== */

/* ---------- Shared: header card (all evaluation pages) ---------- */

@media (max-width: 991.98px) {
    .ev-page {
        min-width: 0;
    }

    .ev-page .ev-header-row {
        row-gap: 12px;
    }

    /* The page <style> gives the title column 60% / 77% and absolutely positions the
       actions at the right; stack them instead. */
    .ev-page .ev-header-text {
        flex: 0 0 100%;
        width: 100% !important;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .ev-page .ev-header-actions.filters-block {
        position: relative; /* anchors the search popup below */
        right: auto;
        float: none;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
        padding-top: 0;
    }

    .ev-page .ev-header-actions .mt-10 {
        margin-right: 0;
    }

    .ev-page .ev-header-actions .btn {
        min-height: 44px;
    }

    .ev-page .ev-header-actions .btn-color {
        width: auto;
        height: auto;
        min-height: 44px;
    }

    /* Search popup: 500px wide with a -9% offset on desktop. */
    .ev-page .ev-header-actions .modal-content-search {
        top: calc(100% + 6px) !important;
        left: 0 !important;
        width: 100%;
        max-width: 500px;
    }

    /* Answers / submit: the date column (width 23% / inline) */
    .ev-page .ev-header-actions.header-field {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
    }

    .ev-page .ev-header-actions.header-field .form-control {
        width: 100% !important; /* inline width:70% */
        height: 44px !important;
        margin-top: 0 !important;
    }
}

/* ---------- Shared: tables (scroll inside their card) ---------- */

@media (max-width: 767.98px) {
    .ev-page .ev-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ev-page .ev-table {
        min-width: 560px;
    }

    .ev-page .ev-table-scroll .btn,
    .ev-page .ev-table-scroll td > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }

    .ev-page .ev-table .switche {
        min-width: 2.5em;
        min-height: 1.25em;
    }
}

/* ---------- Shared: modals (page CSS: width 115%, margin-left -10%, margin-top 30%) ---------- */

@media (max-width: 767.98px) {
    .ev-page .ev-modal .modal-dialog {
        margin: 12px auto;
        max-width: calc(100vw - 24px);
    }

    .ev-page .ev-modal .ev-modal-content {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0 !important; /* inline margin-top:30% */
        border-radius: 16px;
    }

    .ev-page .ev-modal .modal-body {
        margin: 0;
        padding-inline: 16px !important;
    }

    .ev-page .ev-modal .modal-header .btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .ev-page .ev-modal .modal-footer .btn {
        width: auto !important; /* inline width:30% / page 25% */
        min-width: 120px;
        height: 44px;
    }

    .ev-page .ev-modal .modal-footer {
        justify-content: flex-end;
    }

    /* Question modal: Fatal / NA and the fatal-type radios use inline % widths */
    .ev-page .ev-modal .checkbox-parent,
    .ev-page .ev-modal .radio-parent {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ev-page .ev-modal .checkbox-parent .form-group,
    .ev-page .ev-modal .radio-parent .form-group-raido {
        width: auto !important;
        margin-right: 0 !important;
        padding: 6px 10px;
    }

    /* Mark / weight rows */
    .ev-page .ev-modal .js-copy > [class*="col-"] {
        flex: 1 1 140px;
        width: auto;
        max-width: 100%;
    }

    .ev-page .ev-modal input.form-control[style*="width: 30%"] {
        width: 100% !important; /* group weight, inline width:30% */
    }

    .ev-page .ev-modal .form-control,
    .ev-page .ev-modal select {
        min-height: 44px;
    }

    .ev-page .ev-modal textarea.form-control {
        min-height: 88px;
    }
}

/* ---------- Evaluation index ---------- */

@media (max-width: 575.98px) {
    .ev-index .ev-header-actions .btn-color,
    .ev-index .ev-header-actions .btn-dark {
        flex: 1 1 auto;
    }
}

/* ---------- Create group (two tables + inline editors) ---------- */

@media (max-width: 991.98px) {
    .ev-create-group .row-tow-table {
        flex-direction: column;
        gap: 16px;
    }

    /* Page CSS: .table1/.table2 height 24rem !important, table2 inline width 38% */
    .ev-create-group .table1,
    .ev-create-group .table2 {
        width: 100% !important;
        height: auto !important;
        max-height: none;
    }

    .ev-create-group .table2 .table-responsive {
        height: auto !important;
    }

    /* inner scroll area has inline height:80% */
    .ev-create-group .table2 .table-responsive > div[style*="height: 80%"] {
        height: auto !important;
        max-height: 24rem;
    }

    .ev-create-group .table2 img[src*="NoHeaderSelected"] {
        display: block;
        max-width: 60%;
        height: auto;
        margin: 24px auto !important;
    }

    .ev-create-group .but {
        min-width: 40px;
        min-height: 40px;
    }

    /* Weight / name editors: JS sets position:absolute + left/top from the cell's
       viewport rect. position:fixed uses the same coordinates, so keep top and pin the
       popover to the viewport edges. Inline width is !important, min-width beats it. */
    .ev-create-group .ev-popover {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        min-width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        z-index: 1056;
    }
}

/* ---------- Create question ---------- */

@media (max-width: 991.98px) {
    .ev-create-question .table1 {
        width: 100%;
    }

    .ev-create-question .but {
        min-width: 40px;
        min-height: 40px;
    }
}

/* ---------- Edit question (3 columns in a fixed 32rem card) ---------- */

@media (max-width: 991.98px) {
    .ev-edit-question .ev-edit-card {
        height: auto;
    }

    .ev-edit-question .ev-edit-card .header-div {
        height: 48px !important; /* inline height:15% of an auto-height card */
    }

    .ev-edit-question .ev-edit-cols {
        height: auto !important; /* inline height:70% */
    }

    .ev-edit-question .ev-edit-col {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        height: auto;
        overflow: visible;
        padding: 16px;
    }

    .ev-edit-question .ev-edit-col .checkbox-parent,
    .ev-edit-question .ev-edit-col .radio-parent {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ev-edit-question .ev-edit-col .form-group,
    .ev-edit-question .ev-edit-col .form-group-raido {
        width: auto !important; /* inline % widths */
        margin-right: 0 !important;
        padding: 6px 10px;
    }

    .ev-edit-question .ev-edit-col .js-copy > [class*="col-"]:not(.delete-btn) {
        flex: 1 1 130px;
        width: auto;
        max-width: 100%;
    }

    .ev-edit-question .ev-edit-col .delete-btn {
        flex: 0 0 44px;
        width: 44px;
        padding-top: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .ev-edit-question .ev-edit-col .form-control {
        min-height: 44px;
    }

    .ev-edit-question .ev-edit-col textarea.form-control {
        min-height: 88px;
    }

    .ev-edit-question .ev-edit-card .footer-btn {
        height: auto !important; /* inline height:15% */
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .ev-edit-question .ev-edit-card .footer-btn .btn {
        width: auto;
        min-width: 120px;
        min-height: 44px;
        margin-left: 0 !important;
    }
}

/* ---------- Form builder ---------- */

@media (max-width: 991.98px) {
    /* Page CSS: row, fixed 32rem tall, side by side; widths are inline */
    .ev-create-form-builder .ev-builder {
        flex-direction: column;
        height: auto;
        margin-top: 16px;
        gap: 16px;
    }

    .ev-create-form-builder .ev-builder-main,
    .ev-create-form-builder .ev-builder-side {
        width: 100% !important;
        height: auto;
    }

    .ev-create-form-builder .ev-builder-main .section-one-header {
        height: auto;
        margin-bottom: 8px;
    }

    .ev-create-form-builder .section-one-boxes {
        height: auto;
        flex-wrap: wrap;
        gap: 12px;
        padding: 8px 0 16px;
    }

    .ev-create-form-builder .section-one-boxes-box {
        width: auto !important; /* inline width:24% on the Text box */
        flex: 1 1 140px;
        min-height: 72px;
        padding: 8px 12px;
    }

    .ev-create-form-builder .section-one-boxes .alert-warning {
        width: 100% !important; /* inline width: 64% / 100% */
        height: auto;
    }

    .ev-create-form-builder .section-one-info {
        height: auto;
        min-height: 160px;
        padding: 16px;
    }

    .ev-create-form-builder .section-one-details {
        height: auto;
        max-height: none;
    }

    .ev-create-form-builder .section-one-details-header {
        height: auto;
        padding: 12px 16px;
    }

    .ev-create-form-builder .section-one-details-content {
        height: auto;
        padding-bottom: 8px;
    }

    .ev-create-form-builder .section-one-details .label.col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Extra dropdown options: input (inline width) + delete icon (col-2) */
    .ev-create-form-builder .section-one-details .label > input.form-control[style*="width"] {
        flex: 1 1 0;
        width: auto !important;
        min-width: 0;
    }

    .ev-create-form-builder .section-one-details .label > .col-2 {
        flex: 0 0 44px;
        max-width: 44px;
        padding: 0;
        display: flex !important; /* inline display:inline */
        align-items: center;
        justify-content: center;
    }

    .ev-create-form-builder .section-one-details .form-control {
        min-height: 44px;
    }

    .ev-create-form-builder .footer-btn {
        height: auto !important; /* inline height:15% */
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .ev-create-form-builder .footer-btn .btn {
        width: auto;
        min-width: 110px;
        min-height: 44px;
        margin-left: 0 !important;
    }

    /* Side list: header uses negative-margin tricks to span the row gutter */
    .ev-create-form-builder .ev-builder-side {
        padding-inline: 0;
    }

    .ev-create-form-builder .ev-builder-side .header-section-tow {
        width: 100%;
        margin: 0;
        height: auto;
        min-height: 52px;
        padding: 14px;
        font-size: 1rem;
    }

    .ev-create-form-builder .ev-builder-side .content-section-tow {
        height: auto;
        padding: 12px;
    }

    .ev-create-form-builder .ev-builder-side .div-content,
    .ev-create-form-builder .ev-builder-side .div-content-selected {
        height: auto;
        min-height: 56px;
        flex-shrink: 0;
    }

    .ev-create-form-builder .ev-builder-side .div-content-remove {
        flex: 0 0 44px;
        width: 44px;
        align-items: center;
    }

    .ev-create-form-builder .ev-builder-side .div-content-text {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

/* ---------- Report (list + filter panel) ---------- */

@media (max-width: 991.98px) {
    .ev-report .ev-header-actions .ev-icon-btn {
        float: none !important;
        margin-right: 0 !important; /* inline margin-right:20px, float:right */
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px !important;
        padding: 0;
    }

    .ev-report .ev-date-field {
        flex: 1 1 140px;
        width: auto;
        max-width: none;
        min-height: 44px;
        margin: 0;
    }

    .ev-report .ev-date-field .from-to-date {
        min-height: 44px;
    }

    .ev-report .ev-date-field .date-field {
        min-height: 44px;
    }

    /* Page CSS: side-by-side with a fixed height per breakpoint */
    .ev-report .ev-sections {
        flex-direction: column;
        height: auto !important;
        gap: 16px;
        margin-top: 16px;
        margin-bottom: 16px;
    }

    .ev-report .ev-results {
        width: 100%;
        height: auto;
        max-height: 70vh;
        overflow: auto;
    }

    .ev-report .ev-results .table {
        min-width: 640px;
    }

    .ev-report .ev-filter-panel,
    .ev-report .ev-back {
        width: 100%;
        height: auto;
    }

    .ev-report .ev-filter-panel .filter-header {
        height: auto;
        padding: 16px;
    }

    .ev-report .ev-filter-panel .filter-body {
        height: auto;
        overflow: visible;
        padding: 16px;
    }

    .ev-report .ev-filter-panel .filter-footer {
        padding: 8px 16px 16px;
    }

    .ev-report .ev-filter-options {
        gap: 8px;
        margin-bottom: 16px;
    }

    /* Pills have fixed % widths (some !important) and margins */
    .ev-report .ev-filter-options .category {
        width: auto !important;
        flex: 1 1 40%;
        margin: 0;
        min-height: 44px;
        align-items: center;
        padding: 6px 12px;
    }

    .ev-report .ev-filter-options .category input[type="radio"] {
        width: 20px;
        height: 20px;
    }

    .ev-report .ev-filter-options .text-box {
        margin-left: 8px;
    }

    .ev-report .ev-filter-panel .sub-main-filter hr {
        margin: 8px 0 !important;
    }

    .ev-report .ev-filter-panel .field-type {
        padding: 12px 0;
    }

    .ev-report .ev-filter-panel select.form-control {
        min-height: 44px;
    }

    /* "Previous" box: plain button row instead of a white card */
    .ev-report .ev-back {
        background: transparent;
        border: 0;
        margin-bottom: 16px;
    }
}

/* ---------- Report answers (supervisor + agent) and Submit evaluation form ---------- */

@media (max-width: 991.98px) {
    /* Info card: fixed 18rem tall with 25% column widths */
    .ev-page .ev-info {
        height: auto !important;
        margin-inline: 0;
    }

    .ev-page .ev-info .section-one-head {
        height: 44px;
    }

    .ev-page .ev-info .ev-info-fields {
        height: auto;
        padding: 12px;
        overflow: visible;
    }

    .ev-page .ev-info-col {
        flex: 0 0 50%;
        width: 50%;
        max-width: 50%;
        min-width: 0;
    }

    .ev-page .ev-info .form-control {
        min-height: 44px;
    }

    .ev-page .ev-info textarea.form-control {
        min-height: 88px;
    }

    /* Score card: boxes + legend + doughnut chart side by side in 18rem */
    .ev-page .ev-score {
        flex-direction: column;
        height: auto !important;
    }

    .ev-page .ev-score-boxes,
    .ev-page .ev-score-chart {
        width: 100%;
        height: auto;
    }

    .ev-page .ev-score-boxes .row-box-one,
    .ev-page .ev-score-boxes .row-box-tow {
        height: auto;
        padding: 12px;
        gap: 12px;
    }

    .ev-page .ev-score-boxes .box {
        width: calc(50% - 6px);
        height: auto;
        min-height: 92px;
        padding: 10px;
    }

    .ev-page .ev-score-chart {
        flex-direction: column;
        padding-top: 4px;
    }

    /* The vertical divider becomes a horizontal one */
    .ev-page .ev-score-chart::before {
        top: 0;
        left: 12px;
        right: 12px;
        width: auto;
        height: 2px;
    }

    .ev-page .ev-score-chart .section-tow-colors-group {
        width: 100%;
        height: auto;
        padding: 16px 12px 8px;
        gap: 8px;
    }

    .ev-page .ev-score-chart .box-color {
        height: auto;
        align-items: center;
    }

    .ev-page .ev-score-chart .text-span {
        margin: 0 0 0 12px;
    }

    .ev-page .ev-score-chart .section-tow-circle-chart {
        width: 100%;
        height: 280px;
        margin: 8px 0 16px;
        padding: 0 12px;
        position: relative;
    }

    /* #myChart is 119% x 119% of its box on desktop; keep it inside on small screens */
    .ev-page .ev-score-chart #myChart {
        width: 100% !important;
        height: 100% !important;
    }

    /* Group / question table: 4 columns, scroll inside the card */
    .ev-page .section-three-container {
        padding: 12px;
    }

    .ev-page .container-color {
        height: auto;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 4px;
    }

    .ev-page .ev-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ev-page .section-three .ev-table {
        min-width: 640px;
    }

    .ev-page .section-three .ev-table .form-control {
        min-height: 44px;
    }

    .ev-page .section-three .ev-table textarea.text-area {
        height: 44px !important; /* page rule: 37.22px !important */
    }

    /* Voice player + "view ticket" strip use fixed rem heights */
    .ev-submit-evaluation-form .ev-voice {
        height: auto;
        padding: 16px 12px;
    }

    .ev-submit-evaluation-form .section-none-voice {
        height: auto;
        padding: 12px !important;
    }

    .ev-submit-evaluation-form .section-none-voice .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Speed picker: 8% wide at right:44% on desktop */
    .ev-submit-evaluation-form .ev-voice .modal-content3 {
        width: 96px;
        right: 12px;
        max-width: calc(100% - 24px);
    }

    .ev-submit-evaluation-form .ev-voice .parent-btn {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        position: relative;
    }

    /* Previous / Submit */
    .ev-submit-evaluation-form .ev-actions {
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 24px;
    }

    .ev-submit-evaluation-form .ev-actions > [class*="col-"] {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
    }

    .ev-submit-evaluation-form .ev-actions .btn {
        min-height: 44px;
        margin-inline: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .ev-page .ev-info-col {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }

    .ev-page .ev-score-boxes .box-number {
        font-size: 18px;
    }

    .ev-page .ev-score-boxes .box-text {
        font-size: 13px;
    }

    .ev-submit-evaluation-form .ev-actions > [class*="col-"] {
        flex: 1 1 100%;
    }

    .ev-submit-evaluation-form .ev-actions .btn {
        width: 100%;
    }
}

/* ---------- Type evaluation list (Quality Evaluation) ---------- */

@media (max-width: 991.98px) {
    .ev-type .ev-filter {
        padding: 12px;
    }

    /* Columns carry inline % widths (apply 5.3%, limit 5.3%, advanced 12.5%) */
    .ev-type .ev-filter .row-field {
        row-gap: 4px;
    }

    .ev-type .ev-filter .row-field > [class*="col-"] {
        flex: 0 0 50%;
        width: 50% !important;
        max-width: 50%;
        min-width: 0;
    }

    .ev-type .ev-filter .row-field > .ev-filter-btn {
        flex: 1 1 0;
        width: auto !important;
        max-width: none;
        margin: 0 4px !important;
        padding: 0 !important;
    }

    /* The invisible spacer labels only align buttons with inputs on desktop */
    .ev-type .ev-filter .ev-filter-btn .col-form-label {
        display: none;
    }

    .ev-type .ev-filter .ev-filter-btn .btn,
    .ev-type .ev-filter .ev-filter-btn select {
        min-height: 44px;
    }

    .ev-type .ev-filter .form-control {
        min-height: 44px;
    }

    .ev-type .ev-filter .agent-search-box .list-group {
        max-height: 180px !important;
    }
}

@media (max-width: 575.98px) {
    .ev-type .ev-filter .row-field > [class*="col-"]:not(.ev-filter-btn) {
        flex: 0 0 100%;
        width: 100% !important;
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    /* Evaluation / Action columns stick to the right (160px + 80px): too much of a
       phone screen, so let them scroll with the table. */
    .ev-type #example th.col-evaluation,
    .ev-type #example td.col-evaluation,
    .ev-type #example th.col-action,
    .ev-type #example td.col-action {
        position: static !important;
        right: auto !important;
        box-shadow: none;
        min-width: 0;
    }

    .ev-type #example {
        min-width: 900px;
    }

    .ev-type .evaluation-sort-button {
        min-height: 40px;
    }
}

/* =====================================================================
   Assignment page (supervisor) - EXTRA hooks (the .asg-header / filter / search
   popup rules already exist in conversation-responsive.css; keep them).
   Hooks: .asg-table-wrap (table-responsive), .asg-table, .asg-pager (pagination row),
   .asg-empty-img / .asg-empty-title ("No Data Selected"), .asg-modal (Reassign modal).
   ===================================================================== */

/* Table: one line per row; it scrolls sideways inside its card instead of squeezing. */
@media (max-width: 991.98px) {
    .asg-table td,
    .asg-table th {
        white-space: nowrap;
    }

    /* Row checkboxes: a larger tap area (padding on the cell, bigger box). */
    .asg-table .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0;
    }

    .asg-table th:first-child,
    .asg-table td:first-child {
        padding: 0.75rem 1rem;
    }

    .asg-table th[wire\:click] {
        min-height: 40px;
    }
}

@media (max-width: 767.98px) {
    /* "No Data Selected" placeholder: the image had a 45% left margin (inline), so it
       sat off-centre; both centre in the card. */
    .asg-empty-img {
        margin: 3rem 0 0 !important;
        text-align: center;
    }

    .asg-empty-title {
        margin-top: 1rem;
        font-size: 1.25rem;
        text-align: center !important;
    }

    /* Pagination: summary line above the links, both centred. */
    .asg-pager {
        justify-content: center !important;
        text-align: center;
    }

    .asg-pager .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Reassign modal: the root has margin-top: 8% (inline), which pushed it down the
       screen; the dialog's own margin is enough. 16px fields avoid the iOS zoom-in. */
    .asg-modal.modal {
        margin-top: 0 !important;
    }

    .asg-modal .form-select,
    .asg-modal .form-control {
        min-height: 42px;
        font-size: 16px;
    }

    .asg-modal .modal-footer .btn {
        min-height: 42px;
    }
}

/* =====================================================================
   Canned Responses (supervisor). Table view (index-2) and card view (index).
   The search pop-over rules already exist above; keep them.
   Hooks (both views): .cr-head (header card row), .cr-head-text, .cr-head-actions,
     .cr-head-btn (WhatsApp Template / New Response buttons), .cr-modal (every modal root;
     .cr-email-modal on the Email editor modal).
   Table view: .cr-table-wrap, .cr-table, .cr-row-menu (the row's 3-dots toggle), .cr-pager.
   Card view: .cr-head (the floated-button header card), .cr-cards (cards row), .cr-card.
   ===================================================================== */

/* ---- Table view ---- */
@media (max-width: 767.98px) {
    /* Header buttons fill the line rather than one wrapped orphan. */
    .cr-head-actions {
        justify-content: flex-start !important;
        width: 100%;
    }

    .cr-head-btn {
        flex: 1 1 auto;
        min-height: 44px;
    }

    /* Row 3-dots toggle: 40px tap target (its icon had an inline margin-top). */
    .cr-row-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }

    .cr-row-menu > i {
        margin-top: 0 !important;
    }

    .cr-table .dropdown-menu li {
        align-items: center;
        min-height: 40px;
    }

    /* Collapsed one-liner cut shorter so the row doesn't need a huge scroll;
       expanded text is capped to the screen's width. */
    #cannedResponsesTable td.cr-truncate .cr-collapsed {
        max-width: 220px;
    }

    #cannedResponsesTable tr.cr-row.is-expanded td.cr-truncate .cr-expanded-full {
        max-width: 280px;
    }

    /* Expand arrow: bigger hit area (it is visibility:hidden when not needed). */
    .cr-table .cr-expand-btn {
        min-width: 32px;
        min-height: 32px;
    }

    .cr-pager {
        padding: 0 12px 12px;
        overflow-x: auto;
    }

    .cr-pager .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Sort icons in the header cells: bigger tap area without moving the layout. */
@media (pointer: coarse) {
    .cr-table thead i[wire\:click],
    .fm-table thead i[wire\:click] {
        padding: 10px;
        margin: -10px;
    }
}

/* ---- Card view ---- */
@media (max-width: 991.98px) {
    /* Header card: title on its own line, floated buttons in one wrapping row
       (same technique as .asg-header). */
    .cr-head {
        display: flex;
        flex-direction: row-reverse;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }

    .cr-head > * {
        float: none !important;
        margin: 0 !important;
    }

    .cr-head > .form-group:first-child {
        flex: 0 0 100%;
    }

    /* Cards row: 108% wide (inline) overflowed the page; cards use fixed 22% widths. */
    .cr-cards {
        width: 100% !important;
        max-width: 100% !important;
        margin-right: 0;
        margin-left: 0;
    }

    .cr-cards > .cr-card {
        flex: 0 0 auto;
        width: 48% !important;
        margin-right: 2% !important;
        margin-bottom: 16px !important;
    }
}

@media (max-width: 575.98px) {
    .cr-cards > .cr-card {
        width: 100% !important;
        margin-right: 0 !important;
    }
}

@media (max-width: 991.98px) {
    /* Touch has no hover, which is what reveals the card's icons (white until then):
       show them dark, with 40px buttons. Offsets that tucked them in are reset. */
    .cr-card #icon1 {
        display: block !important;
    }

    .cr-card #icon2,
    .cr-card #icon3 {
        color: #000 !important;
    }

    .cr-card li {
        margin: 0 !important;
        list-style: none;
    }

    .cr-card .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }

    .cr-card [data-bs-title="View"] {
        margin: 0 0 0 3px !important;
    }
}

/* ---- Modals (both views) ---- */
@media (max-width: 767.98px) {
    /* Modal roots/dialogs/contents carry inline offsets built for desktop (top: -253px,
       margin-top: 10-30%, width: 579px / 130%, margin-right: 40%); on a phone the modal
       is simply the screen minus a small margin. */
    .cr-modal.modal {
        top: 0 !important;
        margin-top: 0 !important;
    }

    .cr-modal .modal-dialog {
        width: auto !important;
        max-width: calc(100% - 1rem) !important;
        margin: 0.5rem auto !important;
    }

    .cr-modal .modal-content {
        width: 100% !important;
        margin-top: 0 !important;
    }

    .cr-modal:not(.cr-email-modal) .modal-content {
        height: auto !important;
    }

    /* Email editor: its dialog is 70vh tall (inline); it takes the screen instead. */
    .cr-email-modal .modal-dialog {
        height: calc(100% - 1rem) !important;
    }

    /* 16px fields avoid the iOS zoom-in. */
    .cr-modal .form-control,
    .cr-modal .form-select {
        font-size: 16px;
    }

    .cr-modal .modal-footer .btn {
        min-height: 42px;
    }
}

/* =====================================================================
   File Management (supervisor).
   Hooks: .fm-head (header row), .fm-head-text, .fm-head-actions (filter/refresh icons),
   .fm-filter (the filter popup, toggled by jQuery fadeToggle), .fm-table-wrap, .fm-table,
   .fm-name-cell (file name td, display:flex inline), .fm-download, .fm-pager.
   ===================================================================== */
@media (max-width: 767.98px) {
    /* Header: text on top, the two icons under it (col-7 at 90% + col-1 left no room). */
    .fm-head > .fm-head-text,
    .fm-head > .fm-head-actions {
        flex: 0 0 100%;
        width: 100% !important;
        max-width: 100%;
    }

    .fm-head > .fm-head-actions {
        margin-top: 4px;
    }

    /* Filter popup: absolute, 359px wide, -16% right and a translate(-50%, -50%) (page
       styles) put it off-screen. It is fixed under the header, centred and capped. */
    .fm-filter.modal-content {
        position: fixed !important;
        top: 110px;
        right: 0 !important;
        left: 0;
        width: auto !important;
        max-width: 420px;
        height: auto;
        max-height: calc(100vh - 130px);
        margin: 0 auto;
        padding: 0 12px;
        overflow-y: auto !important;
        transform: none;
    }

    .fm-filter .form-control {
        min-height: 42px;
        font-size: 16px !important;
    }

    /* Name cell is display:flex inline (not a table cell); it becomes a normal cell so
       the table lays out in columns and scrolls inside its card. */
    .fm-table td.fm-name-cell {
        display: table-cell !important;
        vertical-align: middle;
    }

    .fm-table td.fm-name-cell > span {
        display: inline-flex !important;
        vertical-align: middle;
    }

    .fm-table th {
        width: auto !important;
    }

    .fm-download {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
    }

    .fm-pager {
        padding: 0 12px 12px;
        overflow-x: auto;
    }

    .fm-pager .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* =====================================================================================
   Group D: Campaign (newsletter), Sentiment Record, Script Configuration.
   Desktop is unchanged; only the breakpoints below adapt them. No agent-role versions of
   these pages exist (supervisor only). Every rule is scoped by a page hook so it wins over
   the pages' own <style> blocks; !important only where the value to override is inline.
   ===================================================================================== */

/* ---------- Campaign (newsletter, Mailer + Small Text) ----------
   Hooks (all in resources/views/livewire/tenant/supervisor/newsletter):
     .cmp-page            content.blade.php root (scope)
     .cmp-header-row / .cmp-header-text / .cmp-header-swap     header.blade.php
     .cmp-tabs / .cmp-tab-actions    Email/index + small-text/index: tab bar and the
                                     Uploader / Group / Activate buttons (absolute, inline)
     .cmp-filter-col      the col-4 filter fields of Groups / Emails|Numbers / Dashboard
     .cmp-circles         Dashboard status circles row
     .cmp-sender-main / .cmp-sender-side / .cmp-sender-table   Email/sender + small-text/sender
     .cmp-export-row      Reports Export button row
     .cmp-modal-col       the col-6 fields of the Group modal */

@media (max-width: 1199.98px) {
    /* The Uploader / Group buttons were absolutely placed at right:77px (inline) and ran
       over the tabs; they go on their own row under the tabs instead. */
    .cmp-page .cmp-tabs .cmp-tab-actions {
        position: static !important;
        float: none !important;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
        margin-top: .75rem;
    }

    .cmp-page .cmp-tabs .cmp-tab-actions .btn {
        float: none !important;
        margin: 0 !important;
        min-height: 40px;
    }
}

@media (max-width: 767.98px) {
    /* Tabs wrap onto a second line with comfortable tap targets. */
    .cmp-page .cmp-tabs .nav-link {
        min-height: 40px;
        padding-right: .75rem;
        padding-left: .75rem;
    }

    /* Header: smaller title block, the swap icon loses its 21px margins. */
    .cmp-page .cmp-header-row h3 {
        font-size: 1.25rem;
    }

    .cmp-page .cmp-header-swap > div {
        margin: 8px 0 !important;
    }

    /* Filter fields stack full width. */
    .cmp-page .cmp-filter-col {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: .5rem;
    }

    /* Status circles wrap two per row instead of running past the card. */
    .cmp-page .cmp-circles {
        flex-wrap: wrap;
        justify-content: center;
        padding-right: 0;
        padding-left: 0;
    }

    /* Mailer / Small Text sender: the form table and the template buttons stack; each
       table row becomes label over field (colgroup / table-layout are inline). */
    .cmp-page .cmp-sender-main,
    .cmp-page .cmp-sender-side {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* minmax(0, 1fr): plain 1fr columns grow to their buttons' text and ran past the card
       ("Select Responses" was cut off); the labels are cut with "..." instead. */
    .cmp-page .cmp-sender-side {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
        margin-top: .5rem;
    }

    .cmp-page .cmp-sender-side > .dropdown {
        min-width: 0;
    }

    .cmp-page .cmp-sender-side .btn {
        margin-top: 0 !important;
        min-height: 40px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Tighter card padding so the form gets the width. */
    .cmp-page .card-header,
    .cmp-page .card-body,
    .cmp-page .card-footer {
        padding-right: .75rem;
        padding-left: .75rem;
    }

    /* Footer actions share the line instead of one wrapped orphan. */
    .cmp-page .card-footer {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
    }

    .cmp-page .card-footer > .btn {
        flex: 1 1 auto;
        margin-bottom: 0 !important;
    }

    .cmp-page .cmp-sender-table,
    .cmp-page .cmp-sender-table thead,
    .cmp-page .cmp-sender-table tr,
    .cmp-page .cmp-sender-table th {
        display: block;
        width: 100% !important;
    }

    .cmp-page .cmp-sender-table colgroup {
        display: none;
    }

    .cmp-page .cmp-sender-table th {
        border-width: 0;
        padding: .25rem 0;
    }

    .cmp-page .cmp-sender-table tr {
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
        padding: .35rem .5rem;
    }

    /* The editor is 500px high (page style); shorter on phones. */
    .cmp-page .ck-editor__editable_inline:not(.ck-comment__input *) {
        height: 340px !important;
    }

    /* Reports: Export full width. */
    .cmp-page .cmp-export-row .btn {
        float: none !important;
        width: 100%;
        min-height: 40px;
    }

    .cmp-page .card-footer .btn {
        min-height: 40px;
    }

    /* Table action buttons: bigger tap targets. */
    .cmp-page .table .btn-group-sm > .btn {
        min-width: 36px;
        min-height: 36px;
    }
}

@media (max-width: 419.98px) {
    /* Very narrow phones: one template button per line. */
    .cmp-page .cmp-sender-side {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 575.98px) {
    /* Status circles shrink so two fit per row at 360px. */
    .cmp-page .cmp-circles .circle {
        width: 84px;
        height: 84px;
        font-size: .85rem;
    }

    /* Group modal fields stack. */
    .cmp-modal-col {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---------- Sentiment Record ----------
   Hooks (resources/views/livewire/tenant/supervisor/setiment-record):
     .sr-page             index root (scope)
     .sr-source-head      Source Info card header (title + date)
     .sr-tabs             Details / Conversation / Topics / AI Classification tabs
     .sr-details-left / .sr-details-mid / .sr-details-right   Details tab columns
     .sr-chart-box        Sentiment Comparison chart holder
     .sr-conv-search / .sr-conv-filter   Conversation search and sentiment filter columns
     .sr-msg-scroll       the messages scroller (400px inline)
     .sr-msg-card         message bubbles (max-width: 400px inline)
     .sr-trend-box        Trend chart holder
     .sr-tab-pane / .sr-tab-toolbar / .sr-kw-search   Topics and AI Classification panes */

@media (max-width: 991.98px) {
    /* Details tab stacks. The middle column's 2px left border is inline; it becomes a
       top border when stacked. */
    .sr-page .sr-details-left {
        padding-left: .75rem !important;
        padding-right: .75rem;
    }

    .sr-page .sr-details-mid {
        border-left: 0 !important;
        padding-left: calc(var(--bs-gutter-x, 1.5rem) * .5) !important;
    }

    /* Chart.js (maintainAspectRatio: false) needs a height once the column is auto. */
    .sr-page .sr-chart-box {
        min-height: 220px;
    }

    .sr-page .sr-trend-box {
        min-height: 240px;
    }

    /* Tabs: tighter padding so the four fit in two lines at most. */
    .sr-page .nav-tabs-custom {
        flex-wrap: wrap;
    }

    .sr-page .nav-tabs-custom .nav-link {
        padding: .6rem .75rem;
        min-height: 40px;
    }

    /* Topics / AI Classification panes had a fixed 455px (inline); the toolbar wraps on
       narrow screens so the pane grows with its content. */
    .sr-page .sr-tab-pane {
        height: auto !important;
        padding-bottom: 1rem;
    }
}

@media (max-width: 767.98px) {
    /* Conversation: search takes the room, filter sits beside it. */
    .sr-page .sr-conv-search {
        flex: 1 1 0;
        width: auto;
    }

    .sr-page .sr-conv-filter {
        flex: 0 0 auto;
        width: auto;
    }

    .sr-page .sr-conv-search .form-control,
    .sr-page .sr-conv-filter .btn {
        min-height: 40px;
    }

    .sr-page .sr-msg-scroll {
        height: min(400px, 60vh) !important;
    }

    /* Bubbles never wider than the screen (indicator + gutters take ~110px). */
    .sr-page .sr-msg-card {
        max-width: calc(100vw - 150px) !important;
    }

    /* Toolbars wrap; the keyword search takes a full row. */
    .sr-page .sr-tab-toolbar {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .sr-page .sr-tab-toolbar > .position-relative {
        flex: 1 1 100%;
        max-width: none !important;
        width: 100% !important;
    }

    .sr-page .sr-tab-toolbar .btn-outline-secondary {
        min-height: 40px;
    }

    /* Edit pencil buttons in the tables. */
    .sr-page .sr-tab-pane .table .btn {
        min-width: 36px;
        min-height: 36px;
    }

    /* Topic / classification modals: less side padding (px-5 utility). */
    #addTopicModal .modal-body,
    #editSentimentModal .modal-body {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }
}

@media (max-width: 575.98px) {
    .sr-page .sr-source-head {
        flex-wrap: wrap;
        gap: .25rem;
    }
}

/* ---------- Script Configuration (Scripts / Variables / Values), plus Keywords and Flags ----------
   Hooks (resources/views/livewire/tenant/supervisor/sentiment-configuration):
     .sc-cfg-page           component root (scope)
     .sc-cfg-tabs           Script / Variable / Value buttons and the Add button row
     .sc-cfg-add-row        right-aligned "Add New ..." row (Keywords, Flags)
     .sc-cfg-modal-content  modal content that has an inline margin-top: 30% */

/* The modal pushed itself down by 30% of the screen width (inline); on phones it sits
   near the top, and the dialog scrolls inside the viewport. */
@media (max-width: 767.98px) {
    .sc-cfg-page .sc-cfg-modal-content {
        margin-top: 0 !important;
    }

    .sc-cfg-page .sc-cfg-tabs {
        flex-wrap: wrap;
        gap: .5rem;
        padding: .5rem 0 !important;
    }

    .sc-cfg-page .sc-cfg-tabs > div {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
    }

    .sc-cfg-page .sc-cfg-tabs > div:last-child {
        width: 100%;
    }

    .sc-cfg-page .sc-cfg-tabs .btn {
        margin: 0 !important;
        min-height: 40px;
    }

    .sc-cfg-page .sc-cfg-tabs > div:last-child .btn {
        width: 100%;
    }

    .sc-cfg-page .sc-cfg-add-row {
        padding: .5rem 0 !important;
    }

    .sc-cfg-page .sc-cfg-add-row .btn {
        width: 100%;
        min-height: 40px;
    }

    /* Edit / delete buttons in the tables. */
    .sc-cfg-page .table td .btn {
        min-width: 36px;
        min-height: 36px;
    }

    .sc-cfg-page .card-body {
        padding-right: .5rem !important;
        padding-left: .5rem !important;
    }
}

/* ==========================================================================
   Contact Profile (supervisor + agent) - livewire/tenant/{supervisor,agent}/contacts/profile
   and the shared merge panel (livewire/tenant/shared/contact-profile-merge-panel).
   Desktop (>= 992px) is untouched. Below 992px the two columns stack, the profile
   card goes first, then search / tabs / timeline.

   Hooks (all opt-in):
     .cp-page            component root (scope for everything below)
     .cp-row             the two-column row (desktop has zoom: 90% inline)
     .cp-main            left column: search, tabs, timeline (inline width: 65%)
     .cp-side            right column: profile header, contact, insights (inline width: 34.67%)
     .cp-tabs / .cp-tabs-group   tab strip row / its radio button group (scrolls sideways)
     .cp-timeline-box    the timeline card (inline height: 70vh on desktop)
     .cp-header          green profile header (avatar, name, social icon, rate)
     .cp-cd-type / .cp-cd-value  "Add Contact Details" modal: type select / value + delete
     .cp-merge           merge panel modal overlay
     .cp-merge-steps / .cp-merge-step[data-active] / .cp-merge-step-label / .cp-merge-line
                         merge stepper
     .cp-merge-option / .cp-merge-col   a master-candidate row and its text columns
   ========================================================================== */

@media (max-width: 991.98px) {
    /* Columns stack; inline zoom/width are overridden with !important */
    .cp-page .cp-row {
        zoom: 1 !important;
        flex-direction: column;
        flex-wrap: nowrap;
        row-gap: .75rem;
    }

    .cp-page .cp-main,
    .cp-page .cp-side {
        width: 100% !important;
        max-width: 100%;
        flex: 0 0 auto !important;
        min-width: 0;
    }

    /* Identity first, then the activity feed */
    .cp-page .cp-side { order: -1; }

    /* Duplicate-profile banner stacks */
    .cp-page > .alert {
        flex-direction: column;
        align-items: stretch !important;
        gap: .5rem;
    }

    .cp-page > .alert .btn {
        min-height: 40px;
        white-space: normal;
        text-align: left;
    }

    /* ---- Profile header (inline fixed height + vw font sizes) ---- */
    .cp-page .cp-header {
        height: auto !important;
        min-height: 120px;
        flex-wrap: wrap;
        gap: .5rem;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .cp-page .cp-header > div:first-child {
        flex: 1 1 200px;
        min-width: 0;
    }

    .cp-page .cp-header > div:first-child .text-white {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .cp-page .cp-header img.rounded-circle,
    .cp-page .cp-header div.rounded-circle {
        width: 72px !important;
        height: 72px !important;
        flex: 0 0 auto;
        font-size: 30px !important;
    }

    /* font-size in vw is unreadable on phones */
    .cp-page .cp-header [style*="font-size: 1vw"] { font-size: 1rem !important; }
    .cp-page .cp-header [style*="vw"] { font-size: .85rem !important; }

    /* Right group: remove the negative-margin desktop trick */
    .cp-page .cp-header > div:last-child {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: .25rem;
    }

    .cp-page .cp-header .fw-bold {
        margin: 0 !important;
        align-items: center;
    }

    .cp-page .cp-header .fa-pen-style {
        min-width: 40px;
        min-height: 40px;
        align-items: center;
        margin: 0;
    }

    /* agent view fixes the wrapper to 30px / hidden */
    .cp-page .cp-header .scroll-wrapper {
        height: auto !important;
        overflow: visible !important;
    }

    .cp-page .cp-header .icon-container {
        width: 40px !important;
        height: 40px !important;
    }

    .cp-page .cp-header button[data-bs-target="#satisfactionModal"] {
        min-height: 40px;
        min-width: 40px;
    }

    /* tooltips are hover-only and would hang off-screen */
    .cp-page .tooltip-container .tooltip-text { display: none !important; }

    /* ---- Contact / insights lists ---- */
    .cp-page .cp-side .list-group-item {
        overflow-wrap: anywhere;
    }

    /* percentage-wide icon columns collapse to the icon width */
    .cp-page .cp-side .list-group-item .d-flex.gap-3 > span.d-flex[style*="width"] {
        width: auto !important;
        flex: 0 0 auto;
    }

    .cp-page .cp-side .list-group-item .d-flex.gap-3 > div { min-width: 0; }

    .cp-page #social-value-display { overflow-wrap: anywhere; }

    /* ---- Tabs strip scrolls sideways instead of overflowing ---- */
    .cp-page .cp-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: .25rem;
    }

    .cp-page .cp-tabs-group {
        flex: 0 0 auto;
        flex-wrap: nowrap;
    }

    .cp-page .cp-tabs-group > .btn-icon {
        flex: 0 0 auto;
        white-space: nowrap;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        gap: .35rem;
    }

    /* ---- Timeline ---- */
    .cp-page .cp-timeline-box {
        height: auto !important;
        max-height: none;
        padding: .75rem !important;
        overflow-x: hidden;
    }

    .cp-page .cp-timeline-box .mx-3 { margin-left: 1rem !important; margin-right: .25rem !important; }

    .cp-page .cp-timeline-box .step {
        padding: 0 0 0 18px;
    }

    .cp-page .cp-timeline-box .step .content {
        margin-left: 14px;
        min-width: 0;
    }

    .cp-page .cp-timeline-box .step-details {
        padding: .75rem !important;
        overflow-wrap: anywhere;
    }

    /* header / footer rows of a card wrap instead of overflowing */
    .cp-page .cp-timeline-box .step-details > .d-flex {
        flex-wrap: wrap;
        gap: .25rem .75rem;
    }

    .cp-page .cp-timeline-box .step-details .me-4 { margin-right: .5rem !important; }

    .cp-page .cp-timeline-box .step-details img,
    .cp-page .cp-timeline-box .step-details video,
    .cp-page .cp-timeline-box .step-details iframe,
    .cp-page .cp-timeline-box .step-details audio {
        max-width: 100%;
    }

    /* inline 30.33px heights on download/delete buttons */
    .cp-page .cp-timeline-box .btn {
        min-height: 40px;
        min-width: 40px;
    }

    .cp-page .cp-timeline-box .step-details .btn { height: auto !important; }

    .cp-page .cp-timeline-box .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .cp-page .cp-timeline-box nav { overflow-x: auto; }

    /* ---- Modals inside the profile ---- */
    .cp-page .modal-dialog { margin: .5rem; max-width: calc(100vw - 1rem); }

    /* inline margin-top: 10% pushes the note modal off-screen */
    .cp-page .modal-content[style*="margin-top"] { margin-top: 0 !important; }

    .cp-page .modal-body { padding-left: 1rem !important; padding-right: 1rem !important; }

    .cp-page .modal-footer { flex-wrap: wrap; gap: .5rem; }

    .cp-page .modal-footer .btn { min-height: 40px; }
}

@media (max-width: 575.98px) {
    /* Contact-detail modal: type and value stack */
    .cp-page .cp-cd-type,
    .cp-page .cp-cd-value {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }

    .cp-page .cp-cd-type .input-group { margin-bottom: .5rem !important; }

    .cp-page .cp-cd-value .btn { min-height: 40px; min-width: 40px; }

    /* inputs inside modals: 16px avoids iOS zoom on focus */
    .cp-page .modal .form-control,
    .cp-page .modal .form-select { font-size: 16px; min-height: 40px; }
}

/* ---------- Merge panel (modal opened by "Merge with #id") ---------- */

@media (max-width: 767.98px) {
    .cp-merge .modal-dialog { margin: .5rem; max-width: calc(100vw - 1rem); }

    .cp-merge .modal-body { padding-left: 1rem !important; padding-right: 1rem !important; }

    .cp-merge .modal-header { padding: 1rem 1rem .5rem; }

    /* the stepper sits in px-4 */
    .cp-merge .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }

    .cp-merge .cp-merge-steps { min-width: 0; }

    /* only the current step keeps its label */
    .cp-merge .cp-merge-step-label { display: none; }
    .cp-merge .cp-merge-step[data-active="1"] .cp-merge-step-label { display: inline; }
    .cp-merge .cp-merge-line { margin-left: .4rem !important; margin-right: .4rem !important; min-width: 8px; }

    /* candidate row: radio + avatar + name on top, phone and email below */
    .cp-merge .cp-merge-option {
        flex-wrap: wrap;
        row-gap: .15rem;
        min-height: 48px;
    }

    .cp-merge .cp-merge-option .cp-merge-col {
        min-width: 0 !important;
        overflow-wrap: anywhere;
    }

    .cp-merge .cp-merge-option .cp-merge-col:nth-of-type(1) { flex: 1 1 0; }

    .cp-merge .cp-merge-option .cp-merge-col:nth-of-type(n+2) {
        flex: 0 0 100%;
        margin-left: 66px !important; /* indent under the name (radio + avatar) */
    }

    .cp-merge .form-check-input[type="radio"],
    .cp-merge .form-check-input[type="checkbox"] { flex: 0 0 auto; }

    .cp-merge .form-check { min-height: 40px; }

    .cp-merge .form-select { min-height: 40px; font-size: 16px; }

    .cp-merge .modal-footer { flex-wrap: wrap; gap: .5rem; padding: .5rem 1rem 1rem; }
    .cp-merge .modal-footer .btn { min-height: 40px; }
}

/* =====================================================================================
   Group F: Survey Builder and Agent Group & Smart Routing (supervisor).
   Page styles in the views load after this file, so selectors are scoped one level
   deeper than theirs. Desktop (>= 992px) is untouched.
   ===================================================================================== */

/* Survey Builder: list (survey.title), form groups (survey.create-group), questions.
   Hooks: .sb-header (the header wrapper, class "header"), .sb-actions (its absolutely
   positioned .filters-block holding the Add buttons).
   The super-survey page styles also set .modal-content { width: 115%; margin-left: -10% }
   and a 500px search pop-over (.modal-content-search); both are reset on phones. */

@media (max-width: 991.98px) {
    /* The actions block was absolute (right: 60px, 36% wide) on top of the title column;
       it flows under the title instead. */
    .sb-header .card-body > .row {
        display: flex;
        flex-wrap: wrap;
        row-gap: 12px;
    }

    .sb-header .card-body > .row > :first-child {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sb-header .filters-block.sb-actions {
        position: static;
        float: none;
        width: 100%;
        padding: 0 12px;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sb-header .sb-actions > .mt-10 {
        margin-right: 0;
    }

    .sb-header .sb-actions .btn {
        min-height: 44px;
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    /* Survey modals: 115% wide and shifted left 10% pushed both edges off a phone. */
    .modal-dialog > .modal-content {
        width: 100%;
        margin-left: 0;
    }

    /* Search pop-over: viewport width minus a gutter, anchored to the left edge. */
    .modal-content-search {
        width: calc(100vw - 32px) !important;
        max-width: 500px;
        left: 0 !important;
    }

    /* Two-column fields in the survey and layout modals stack (col-6 was ~140px). */
    #evaluationModal .modal-body .row > .col-6,
    #layoutModal .modal-body .row > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Survey editor (livewire survey.edit). Hook: .sb-edit (the editor container). Its markup
   is absolutely positioned: a column of round buttons on the left, pop-ups at fixed
   left/top offsets and a template box at left: 265px. */

@media (max-width: 991.98px) {
    /* Round buttons become a row above the survey instead of floating over it. */
    .sb-edit > .side-buttons {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        margin-bottom: 12px;
    }

    .sb-edit > .side-buttons button {
        width: 44px;
        height: 44px;
    }

    /* Pop-ups (rename buttons, alignment, colours, template): centred under the row,
       never wider than the screen, scrolling inside when taller than it. */
    .sb-edit > .popup,
    .sb-edit > .popup-s,
    .sb-edit > .color-picker,
    .sb-edit > .template-description-container {
        position: absolute;
        top: 70px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(360px, calc(100vw - 32px));
        max-width: calc(100vw - 32px);
        max-height: 70vh;
        overflow-y: auto;
        box-sizing: border-box;
    }

    .sb-edit > .color-picker {
        padding: 16px;
    }

    .sb-edit > .color-picker > img {
        width: 100% !important;
        height: auto !important;
    }

    .sb-edit > .color-picker .button-group .btn {
        flex: 1 1 0;
        width: auto !important;
    }

    .sb-edit > .template-description-container {
        height: auto;
    }

    /* Logo upload had a 100px left margin; the Update button floated over the title. */
    .sb-edit .upload-image {
        margin-left: 0;
    }

    .sb-edit #update {
        float: none;
        display: block;
        margin: 16px auto 0;
    }
}

@media (max-width: 767.98px) {
    .sb-edit .feedback-text {
        max-width: 100%;
        font-size: 16px;
    }

    .sb-edit .stepper-container {
        gap: 8px;
    }

    /* The stepper was 65% wide next to the delete button. */
    .sb-edit .stepper {
        width: auto;
        flex: 1 1 auto;
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .sb-edit .stepper .line {
        width: 24px;
    }

    /* Question cards: the 500px-wide header input and fixed-width controls shrink. */
    .sb-edit .question-container {
        padding: 12px 0;
    }

    .sb-edit .question-container .header-name input,
    .sb-edit .form-control,
    .sb-edit .form-select {
        width: 100%;
        max-width: 100%;
    }

    /* Rows built by the editor script use col-md-6: room between the stacked fields. */
    .sb-edit .question-container .row > [class*="col-md-"] {
        margin-bottom: 8px;
    }

    .sb-edit .answer-group label {
        width: auto;
    }

    /* Previous / Next block had a 530px left margin. */
    .sb-edit .navigation-buttons {
        margin-left: 0;
        max-width: 100%;
    }

    .sb-edit .btn-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sb-edit .btn-actions button {
        min-height: 40px;
    }

    .sb-edit .emoji-picker-modal {
        max-width: calc(100vw - 48px);
    }
}

/* Agent Groups and Smart Routing Configuration (supervisor).
   Hooks: .sr-ag-header (header row), .sr-ag-title (title column, col-9),
   .sr-ag-actions (Create button block, absolute in the page style), .sr-ag-limit (limit
   select row), .sr-ag-table (table wrapper), .sr-ag-modal (modal dialog).
   Configuration only: .sr-df-row / .sr-df-field / .sr-df-op / .sr-df-val / .sr-df-del
   (a custom-field row in the rule modal) and .sr-newgrp-row (new customer group row). */

@media (max-width: 767.98px) {
    /* Create was absolute at right: 60px on top of the description. It goes under the
       text, full width of the card. */
    .header .sr-ag-header {
        row-gap: 12px;
    }

    .header .sr-ag-header > .sr-ag-title {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .header .sr-ag-header .filters-block.sr-ag-actions {
        position: static;
        float: none;
        width: 100%;
        justify-content: stretch;
        padding: 0 12px;
    }

    .sr-ag-actions > .mt-10 {
        margin-right: 0;
        width: 100%;
    }

    .sr-ag-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* Limit select: full width instead of right-floated. */
    .sr-ag-limit > .form-group {
        float: none !important;
        margin-left: 0 !important;
        display: block !important;
    }

    .sr-ag-limit select {
        width: 100%;
        min-height: 44px;
    }

    /* Tables scroll inside their card; columns keep a readable width. */
    .sr-ag-table > .table {
        min-width: 640px;
    }

    .sr-ag-table .btn-group-sm > .btn {
        min-width: 40px;
        min-height: 40px;
    }

    .sr-ag-modal.modal-dialog {
        margin: 8px auto;
        width: calc(100% - 16px);
        max-width: none;
    }

    .sr-ag-modal .modal-body {
        padding: 12px;
    }

    .sr-ag-modal .modal-footer {
        flex-wrap: nowrap;
        gap: 8px;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .sr-ag-modal .modal-footer .btn {
        flex: 1 1 0;
        min-height: 44px;
        height: auto;
        min-width: 0;
        margin: 0 !important;
    }

    /* Custom field row: field picker on its own line, operator + value + delete under it
       (col-5/2/4/1 were ~60px each on a phone). */
    .sr-ag-modal .sr-df-row > .sr-df-field {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sr-ag-modal .sr-df-row > .sr-df-op {
        flex: 0 0 34%;
        max-width: 34%;
    }

    .sr-ag-modal .sr-df-row > .sr-df-val {
        flex: 1 1 0;
        max-width: none;
        min-width: 0;
    }

    .sr-ag-modal .sr-df-row > .sr-df-del {
        flex: 0 0 44px;
        max-width: 44px;
    }

    .sr-ag-modal .sr-df-row > .sr-df-del .btn {
        height: 38px !important;
        min-width: 40px;
    }

    /* New customer group: name and customers stack. */
    .sr-ag-modal .sr-newgrp-row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Smart Routing dashboard (livewire smart-routing.dashboard). Hook: .sr-kpi-row (the five
   KPI cards, each a plain .col): five across left ~65px each on a phone. The tables
   already scroll inside .sr-scroll. */

@media (max-width: 767.98px) {
    .sr-wrap .sr-kpi-row > .col {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* The odd fifth card spans the row. */
    .sr-wrap .sr-kpi-row > .col:last-child:nth-child(odd) {
        flex-basis: 100%;
        max-width: 100%;
    }

    .sr-wrap .sr-card-body {
        padding: 14px;
    }

    .sr-wrap .sr-kpi-value {
        font-size: 2rem;
    }
}

/* Groups page (supervisor "Group Page"). Hooks: .grp-header-row, .grp-title, .grp-actions,
   .grp-add-btn, .grp-table, .grp-modal (both modals; the page style gives them
   --bs-modal-margin: 11.75rem, i.e. 188px of margin). */

@media (max-width: 767.98px) {
    .grp-header-row {
        row-gap: 12px;
    }

    .grp-header-row > .grp-title {
        flex: 0 0 100%;
        max-width: 100%;
        margin: 0 !important;
        padding: 0 12px;
    }

    .grp-header-row > .grp-actions {
        flex: 0 0 100%;
        max-width: 100%;
        margin-top: 0;
        padding: 0 12px;
    }

    .grp-header-row .grp-add-btn {
        float: none !important;
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        min-height: 44px;
    }

    .grp-table > .table {
        min-width: 620px;
    }

    .modal.md-top-mar.grp-modal {
        --bs-modal-margin: 0.5rem;
    }

    /* Two fields per row (col-6) stack. */
    .grp-modal .modal-body .row > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .grp-modal .modal-footer .btn {
        min-height: 44px;
    }
}

/* Group Assignment Configuration and User Group (supervisor).
   Hooks: .gac-nav (the two 200x150 tab buttons), .gac-filters, .gac-table, .gac-modal,
   .gac-modal-body, .urg-filters (user group filter row: six col-md-2), .urg-table. */

@media (max-width: 575.98px) {
    /* The two tab cards share the row instead of 200px each wrapping onto two lines. */
    .gac-nav > a {
        flex: 1 1 140px;
    }

    .gac-nav > a > .btn {
        width: 100% !important;
        height: 130px !important;
    }

    .gac-nav .btn p {
        font-size: 13px;
    }

    .gac-modal .modal-header,
    .gac-modal-body {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .gac-modal .modal-footer {
        padding-right: 16px !important;
    }

    .gac-modal .modal-footer .btn {
        min-height: 44px;
    }

    .urg-table > .table,
    .gac-table > .table {
        min-width: 560px;
    }

    .urg-filters.row > .col-md-2 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .urg-filters > .text-end .btn {
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 991.98px) {
    /* col-md-2 columns were ~120px at tablet width: three per row (two on phones, above). */
    .urg-filters > .col-md-2 {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
        margin-bottom: 12px;
    }

    .urg-filters > .text-end {
        flex: 0 0 100%;
        margin-top: 0 !important;
    }
}


/* =====================================================================================
   Contacts list (supervisor and agent, contacts/index). Hooks: .ct-head (header card),
   .ct-wrap (the table's scroll wrapper), .ct-table (the table).
   Phones and small tablets: the 7-column table becomes a list of cards, one per contact:
   checkbox beside the name, then Phone / Email / Business / Created, then the status badge
   and the row menu. The header row keeps only the select-all box and the Name cell (sort
   arrow, or the Bulk Actions menu once contacts are selected); sorting by the hidden
   columns is a desktop feature. Desktop is unchanged.
   ===================================================================================== */
@media (max-width: 767.98px) {
    /* Header card: title on its own line, Create and Duplicates sharing the line below.
       Their floats, side margins and the title's inline margin are inline styles. */
    .ct-head {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .ct-head > .form-group {
        flex: 0 0 100%;
        margin: 0 !important;
    }

    .ct-head > .dropdown,
    .ct-head > .btn {
        flex: 1 1 0;
        float: none !important;
        margin: 0 !important;
    }

    .ct-head > .dropdown > .btn {
        width: 100%;
        margin: 0 !important;
        justify-content: center;
    }

    /* Menus open inside the card instead of being clipped by the scroll wrapper. */
    .ct-wrap {
        min-height: 0 !important;
        overflow: visible;
        background: transparent;
    }

    .ct-table,
    .ct-table > thead,
    .ct-table > tbody {
        display: block;
        width: 100%;
        border: 0;
    }

    /* Header bar: select-all + Name / bulk actions. */
    .ct-table > thead > tr {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        background: #fff;
        border-radius: 8px 8px 0 0;
        border-bottom: 1px solid #eee;
    }

    .ct-table > thead > tr > th {
        border: 0;
        padding: 0;
        background: transparent;
    }

    .ct-table > thead > tr > th:nth-child(n+3) {
        display: none;
    }

    .ct-table > thead > tr > th:nth-child(2) {
        flex: 1 1 0;
        min-width: 0;
        text-align: left;
    }

    .ct-table > thead > tr > th:nth-child(2) > .d-flex {
        justify-content: flex-start !important;
        flex-wrap: wrap;
    }

    /* Cards. */
    .ct-table > tbody > tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        column-gap: 12px;
        row-gap: 2px;
        padding: 12px;
        background: #fff;
        border-bottom: 1px solid #eee;
        text-align: left;
    }

    .ct-table > tbody > tr:last-child {
        border-radius: 0 0 8px 8px;
        border-bottom: 0;
    }

    .ct-table > tbody > tr > th {
        grid-column: 1;
        grid-row: 1 / span 7;
        align-self: start;
        padding: 6px 0 0;
        border: 0;
    }

    .ct-table input.form-check-input {
        width: 20px;
        height: 20px;
        margin: 0;
    }

    .ct-table > tbody > tr > td {
        grid-column: 2;
        min-width: 0;
        padding: 2px 0;
        border: 0;
        text-align: left;
        overflow-wrap: anywhere;
        color: #555;
    }

    /* Name line leads the card; the list number is dropped (it only counts this page). */
    .ct-table > tbody > tr > td:nth-child(2) {
        padding-bottom: 6px;
        color: #212529;
        font-size: 15px;
        font-weight: 600;
    }

    .ct-table > tbody > tr > td:nth-child(2) .text-muted {
        display: none;
    }

    .ct-table > tbody > tr > td:nth-child(3)::before { content: "Phone: "; }
    .ct-table > tbody > tr > td:nth-child(4)::before { content: "Email: "; }
    .ct-table > tbody > tr > td:nth-child(5)::before { content: "Business: "; }
    .ct-table > tbody > tr > td:nth-child(6)::before { content: "Created: "; }

    .ct-table > tbody > tr > td:nth-child(n+3):nth-child(-n+6)::before {
        color: #8a8f98;
        font-weight: 600;
    }

    /* Status badge on the left, row menu on the right, with a finger-sized toggle. */
    .ct-table > tbody > tr > td:last-child {
        padding-top: 8px;
    }

    .ct-table > tbody > tr > td:last-child > .d-flex > .flex-grow-1 {
        text-align: left !important;
    }

    .ct-table > tbody > tr > td:last-child .dropdown > .btn {
        width: 40px !important;
        height: 40px !important;
    }

    /* "There is no Profile found". */
    .ct-table > tbody > tr:has(> td[colspan]) {
        display: block;
        padding: 32px 12px;
        text-align: center;
    }

    .ct-table > tbody > tr > td[colspan]::before {
        content: none;
    }
}

/* Customer Survey Builder list (survey.insight-builder.index). It reuses .sb-header /
   .sb-actions above for the header; extra hooks: .ib-body (the column under the header,
   pulled up 25px by an inline margin) and .ib-filters (the Type / Limit selects, floated
   right with inline margins). Modals: the col-6 fields stack on phones. */
@media (max-width: 767.98px) {
    .ib-body {
        margin-top: 0 !important;
    }

    .ib-filters {
        display: flex;
        gap: 10px;
    }

    .ib-filters > .form-group {
        flex: 1 1 0;
        min-width: 0;
        float: none !important;
        margin: 0 !important;
    }

    .ib-filters select {
        width: 100%;
    }

    #surveyModal .modal-body .row > .col-6,
    #c-satModal .modal-body .row > .col-6,
    #departmentModal .modal-body .row > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---------- Opening a conversation (conversation-responsive.js) ---------- */

/* The conversation's shape over its panel, from the click until its messages arrive. */
.conv-skeleton {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
    pointer-events: none;
}

.conv-skeleton-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eef6f0;
}

.conv-skeleton-lines {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
}

.conv-skeleton-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-end;
    gap: 14px;
    min-height: 0;
}

.conv-sk {
    background: #eef6f0;
    animation: conv-sk-pulse 1s ease-in-out infinite alternate;
}

.conv-sk-avatar { width: 36px; height: 36px; border-radius: 50%; }
.conv-sk-line { height: 12px; border-radius: 6px; }
.conv-sk-bubble { height: 38px; border-radius: 14px; }
.conv-sk-bubble.is-out { align-self: flex-end; background: #cfe6d8; }
.conv-sk-reply { height: 44px; border-radius: 22px; }

@keyframes conv-sk-pulse {
    to { opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
    .conv-sk { animation: none; }
}

/* The clicked row while its list answers: it looks open (as .chat-active), the previous one doesn't. */
.conv-page.conv-opening .chat-active:not([data-conv-opening] *),
.conv-page.conv-opening .chat-active-text:not([data-conv-opening] *) {
    background: transparent !important;
    color: inherit !important;
}

.conv-page.conv-opening [data-conv-opening] .conv-card-row {
    background: #02a34e;
    border-radius: 18px;
}

.conv-page.conv-opening [data-conv-opening] .conv-card-row * {
    color: #fff !important;
}

/* Ticket list: the row's card itself is green, so the previous one goes back to white. */
.conv-page.conv-opening .card.chat-active:not([data-conv-opening] *) {
    background: #fff !important;
}

.conv-page.conv-opening [data-conv-opening] > .card.resource {
    background: #02a34e !important;
    border-radius: 13px;
}

.conv-page.conv-opening [data-conv-opening] > .card.resource * {
    color: #fff !important;
}

/* The agent pill sits on its own light background: it keeps its black text, as in the open state. */
.conv-page.conv-opening [data-conv-opening] .conv-card-row .agent-name,
.conv-page.conv-opening [data-conv-opening] > .card.resource .agent-name {
    color: #000 !important;
}
