/* Customer Service ticket detail — shared by the agent desk (/ap) and the customer side (/dsm).
   Global rather than scoped so both pages render the same thread without duplicating the rules. */

/* ---------- Detail page layout ----------
   The page shell (.workspace-dashboard) is a fixed-height flex column with no scrollbar of its own, so the
   thread has to own the scrolling: the message list scrolls and the compose box stays parked at the bottom
   of the card, the way a chat client behaves. */

/* Match the ticket queue: .workspace-dashboard is calc(100vh - 100px). Detail was height:100%
   of .card-content (100vh - 170px), which left a ~70px empty band at the bottom of the window. */
.page-content .content-withTopTab:has(.cs-detail-page),
.page-content .content-withTopTab:has(.cs-detail-page) .card-content,
.page-content .content-withTopTab:has(.dsm-docs-page),
.page-content .content-withTopTab:has(.dsm-docs-page) .card-content,
.page-content .content-withTopTab:has(.ap-docs-page),
.page-content .content-withTopTab:has(.ap-docs-page) .card-content {
    height: calc(100vh - 100px);
    overflow: hidden;
}

.ap-docs-prose img,
.ap-docs-prose video,
.dsm-docs-prose img,
.dsm-docs-prose video {
    max-width: 100%;
    height: auto;
}

.docs-media-center,
.docs-media-center img,
.docs-media-center video {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.docs-media-right,
.docs-media-right img,
.docs-media-right video {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

.docs-media-left,
.docs-media-left img,
.docs-media-left video {
    display: block;
    margin-left: 0;
    margin-right: auto;
}

.docs-media-center,
.docs-media-right,
.docs-media-left {
    width: 100%;
}

.workspace-dashboard.cs-detail-page {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    gap: 8px !important;
}

.cs-detail {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.cs-detail__side,
.cs-detail__main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    align-self: stretch;
}

.cs-detail__side {
    overflow-y: auto;
}

.cs-preferred-lang-hint {
    line-height: 1.45;
}

.cs-detail__main {
    display: flex;
    flex-direction: column;
}

.cs-thread-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Thread ---------- */

.cs-thread__header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(120, 130, 150, 0.16);
}

.cs-thread__header-left {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}

.cs-thread__header-left > h5 {
    flex: 0 0 auto;
    line-height: 1.2;
}

.cs-presence-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px 0 8px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.14);
    color: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    max-width: 100%;
}

.cs-presence-chip .material-icons-outlined {
    font-size: 16px;
    color: #3b82f6;
    flex: 0 0 auto;
}

.cs-thread__header-right {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: 0 1 auto;
    justify-content: flex-end;
    min-width: 0;
}

/* Compact language pill + light dropdown */
.cs-thread__view-lang-wrap {
    position: relative;
    flex: 0 0 auto;
    z-index: 5;
}

.cs-thread__view-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 8px 0 10px;
    border-radius: 999px;
    max-width: 100%;
    cursor: pointer;
    color: inherit;
    font: inherit;
    line-height: 1;
}

.cs-thread__view-lang:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.cs-thread__view-lang-icon {
    font-size: 16px !important;
    opacity: 0.7;
    flex: 0 0 auto;
}

.cs-thread__view-lang-label {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0.8;
    flex: 0 0 auto;
}

.cs-thread__view-lang-control {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.cs-thread__view-lang-value {
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
}

.cs-thread__view-lang-caret {
    font-size: 18px !important;
    opacity: 0.7;
    flex: 0 0 auto;
}

.cs-thread__view-lang-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: transparent;
}

.cs-thread__view-lang-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 21;
    width: min(220px, 70vw);
    padding: 4px;
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.cs-thread__view-lang-search-input {
    display: block;
    width: 100%;
    height: 30px;
    margin: 0 0 2px;
    padding: 0 8px;
    border: 0;
    border-bottom: 1px solid rgba(120, 130, 150, 0.18);
    border-radius: 6px 6px 0 0;
    outline: none;
    background: transparent;
    font-size: 0.8rem;
}

.cs-thread__view-lang-options {
    max-height: 168px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.cs-thread__view-lang-option {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.82rem;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.cs-thread__view-lang-option:hover,
.cs-thread__view-lang-option.is-selected {
    background: rgba(120, 130, 150, 0.14);
}

.cs-thread__view-lang-empty {
    padding: 8px;
    font-size: 0.8rem;
}

.cs-thread__header-meta {
    flex: 0 0 100%;
    width: 100%;
    margin-top: 2px;
}

.cs-thread__header-meta .cs-thread__translate-status {
    margin-top: 0;
}

@media (max-width: 720px) {
    .cs-thread__view-lang-label {
        display: none;
    }

    .cs-thread__header-right {
        flex: 1 1 100%;
        justify-content: stretch;
    }

    .cs-thread__search {
        max-width: none;
        flex: 1 1 auto;
    }
}

.cs-thread__search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 180px;
    max-width: 280px;
    min-width: 140px;
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    overflow: hidden;
}

.cs-thread__search .material-icons-outlined {
    font-size: 18px;
    opacity: 0.7;
    flex: 0 0 auto;
}

.cs-thread__search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 0.84rem;
    padding: 0;
}

.cs-thread__search-clear {
    border: 0;
    background: transparent;
    padding: 0;
    display: inline-flex;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.cs-thread__search-clear .material-icons-outlined {
    font-size: 16px;
}

.cs-thread__count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.cs-thread__count .material-icons-outlined {
    font-size: 17px;
    opacity: 0.75;
}

.cs-thread__empty-search {
    padding: 18px 4px;
    font-size: 0.88rem;
}

.cs-thread {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 8px;
}

.cs-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cs-msg__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #8794ab;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    margin-top: 2px;
}

.cs-msg__bubble {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 82%;
    border: 1px solid rgba(120, 130, 150, 0.22);
    border-left: 3px solid #8794ab;
    border-radius: 14px;
    padding: 12px 16px 14px;
    transition: box-shadow 0.15s ease;
}

.light .cs-msg__bubble,
.light-theme-dark-sidebar .cs-msg__bubble {
    background: #fff;
}

.light .cs-side-livechat__compose,
.light-theme-dark-sidebar .cs-side-livechat__compose {
    background: #fff;
}

.light textarea.cs-compose__textarea.page-bg,
.light textarea.cs-compose__textarea.page-bg:focus,
.light textarea.cs-compose__textarea.page-bg:focus-visible,
.light-theme-dark-sidebar textarea.cs-compose__textarea.page-bg,
.light-theme-dark-sidebar textarea.cs-compose__textarea.page-bg:focus,
.light-theme-dark-sidebar textarea.cs-compose__textarea.page-bg:focus-visible {
    background: #fff !important;
    color: #4a6386 !important;
    border: 1px solid #94a3b8 !important;
    outline: none !important;
    box-shadow: none !important;
}

.light .cs-livechat-input .chat-input::placeholder {
    color: #4a6386;
    opacity: 0.65;
}

.light .cs-livechat-input .card-action-btn,
.light .cs-livechat-input .card-action-btn .material-icons-outlined,
.light .cs-livechat-input .cs-thread__view-lang,
.light .cs-livechat-input .cs-thread__view-lang-value,
.light .cs-livechat-input .cs-thread__view-lang-icon,
.light .cs-livechat-input .cs-thread__view-lang-caret,
.light .cs-side-livechat__compose .card-action-btn,
.light .cs-side-livechat__compose .card-action-btn .material-icons-outlined,
.light .cs-side-livechat__compose .cs-thread__view-lang,
.light .cs-side-livechat__compose .cs-thread__view-lang-value,
.light .cs-side-livechat__compose .cs-thread__view-lang-icon,
.light .cs-side-livechat__compose .cs-thread__view-lang-caret {
    color: #4a6386 !important;
}

.light .cs-saved-replies__toggle,
.light-theme-dark-sidebar .cs-saved-replies__toggle {
    color: #4a6386;
}

.light .cs-saved-replies__badge,
.light-theme-dark-sidebar .cs-saved-replies__badge {
    color: #3d5bd6;
    background: rgba(91, 124, 250, 0.14);
}

.cs-msg__bubble:hover {
    box-shadow: 0 4px 18px rgba(30, 40, 70, 0.06);
}

.cs-msg--customer .cs-msg__avatar { background: #5b7cfa; }
.cs-msg--agent .cs-msg__avatar { background: #2bb8a6; }
.cs-msg--ai .cs-msg__avatar { background: #7c5cbf; }
.cs-msg--system .cs-msg__avatar { background: #64748b; }

.cs-msg__avatar .material-icons-outlined {
    font-size: 20px;
    color: #fff;
    line-height: 1;
}

.cs-msg--customer .cs-msg__bubble { border-left-color: #5b7cfa; }
.cs-msg--agent .cs-msg__bubble { border-left-color: #2bb8a6; }
.cs-msg--ai .cs-msg__bubble { border-left-color: #7c5cbf; }
.cs-msg--system .cs-msg__bubble { border-left-color: #64748b; }

/* The viewer's own side of the conversation sits on the right, like a chat client: avatar mirrors over
   and the accent moves to the right edge so the bubble still points back at its author. */
.cs-msg--self {
    flex-direction: row-reverse;
}

.cs-msg--self .cs-msg__bubble {
    border-left-width: 1px;
    border-left-color: rgba(120, 130, 150, 0.22);
    border-right-width: 3px;
    border-right-style: solid;
}

.cs-msg--self.cs-msg--agent .cs-msg__bubble { border-right-color: #2bb8a6; }
.cs-msg--self.cs-msg--customer .cs-msg__bubble { border-right-color: #5b7cfa; }
.cs-msg--self.cs-msg--ai .cs-msg__bubble { border-right-color: #7c5cbf; }

/* Internal notes are agent-only, so they read as a distinct amber aside rather than a customer-visible reply. */
.cs-msg--internal .cs-msg__bubble {
    border-left-color: #e8a838;
    background: rgba(232, 168, 56, 0.07);
}

.cs-msg--internal.cs-msg--self .cs-msg__bubble {
    border-left-color: rgba(120, 130, 150, 0.22);
    border-right-color: #e8a838;
}

.cs-msg__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 6px;
}

.cs-msg__author {
    font-size: 0.88rem;
    font-weight: 650;
}

.cs-msg__role {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.14);
}

.cs-msg__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 650;
    padding: 2px 8px;
    border-radius: 999px;
}

.cs-msg__chip .material-icons-outlined {
    font-size: 13px;
}

.cs-msg__chip--internal {
    background: rgba(232, 168, 56, 0.18);
    color: #b57611;
}

.cs-msg__chip--email {
    /* Same muted chip treatment as .cs-msg__role — follows theme secondary text. */
    background: rgba(120, 130, 150, 0.14);
    color: var(--secondary-text-color, #9aa4b2);
}

.cs-msg__chip--translated {
    background: rgba(56, 158, 120, 0.16);
    color: #2f8f6d;
}

.cs-msg__chip--translating {
    background: rgba(70, 130, 200, 0.16);
    color: #3b78c2;
}

.cs-msg__chip--translate-pending {
    background: rgba(120, 130, 150, 0.12);
    color: var(--secondary-text-color, #9aa4b2);
}

.cs-thread__translate-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 0 0;
}

.cs-thread__translate-spin {
    font-size: 16px;
    animation: cs-translate-pulse 1.2s ease-in-out infinite;
}

@keyframes cs-translate-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.cs-msg__time {
    margin-left: auto;
    font-size: 0.76rem;
    white-space: nowrap;
}

.cs-msg__text {
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cs-msg__ticket-link {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cs-msg__ticket-link:hover {
    opacity: 0.8;
}

.cs-msg__text--pending {
    letter-spacing: 0.12em;
    font-weight: 600;
    opacity: 0.75;
    animation: cs-translate-pulse 1.2s ease-in-out infinite;
}

.cs-msg__original-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.85;
}

.cs-msg__original-toggle:hover {
    opacity: 1;
}

.cs-msg__original-toggle .material-icons-outlined {
    font-size: 16px;
}

.cs-msg__original {
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(120, 130, 150, 0.1);
    font-size: 0.84rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cs-thread__empty {
    padding: 8px 0 4px;
    font-size: 0.88rem;
}

/* ---------- Compose ---------- */

.cs-saved-replies {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.cs-saved-replies__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cs-saved-replies__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
}

.cs-saved-replies__icon {
    font-size: 18px;
    color: #5b7cfa;
}

.cs-saved-replies__toggle.is-open {
    border-color: rgba(91, 124, 250, 0.45);
}

.cs-saved-replies__count {
    font-weight: 500;
    font-size: 0.75rem;
}

.cs-saved-replies__chevron {
    margin-left: 2px;
    font-size: 18px !important;
}

.cs-saved-replies__panel {
    padding: 14px;
    border-color: rgba(91, 124, 250, 0.28) !important;
    background: linear-gradient(135deg, rgba(91, 124, 250, 0.06) 0%, transparent 100%);
}

.cs-saved-replies__search-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.cs-saved-replies__create-title {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.cs-saved-replies__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.cs-saved-replies__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.cs-saved-replies__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cs-saved-replies__title {
    font-size: 0.86rem;
    font-weight: 600;
}

.cs-saved-replies__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
}

.cs-saved-replies__badge {
    display: inline-flex;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(91, 124, 250, 0.18);
    font-weight: 600;
}

.cs-saved-replies__preview {
    font-size: 0.74rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cs-saved-replies__actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.cs-saved-replies__delete.card-action-btn .material-icons-outlined {
    color: #ef4444;
}

.cs-compose {
    flex: 0 0 auto;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(120, 130, 150, 0.16);
}

.cs-suggested-docs__search {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1 1 auto;
    margin-bottom: 12px;
}

.cs-suggested-docs__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.cs-suggested-docs__head h5 {
    margin: 0;
}

.cs-suggested-docs .cs-set-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    min-width: 40px;
    flex-shrink: 0;
    margin: 2px 0 0;
}

.cs-suggested-docs .cs-set-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.cs-suggested-docs .cs-set-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #c5cdd8;
    border-radius: 22px;
    transition: 0.2s;
}

.cs-suggested-docs .cs-set-switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.cs-suggested-docs .cs-set-switch input:checked + .cs-set-switch-slider {
    background: #5b7cfa;
}

.cs-suggested-docs .cs-set-switch input:checked + .cs-set-switch-slider:before {
    transform: translateX(18px);
}

.cs-thread__summary {
    margin: 0 0 12px;
    padding: 12px 14px;
}

.cs-thread__summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.cs-thread__summary-body {
    white-space: pre-wrap;
    font-size: 0.92rem;
    line-height: 1.45;
}

.cs-compose textarea {
    resize: none;
}

.cs-create-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.cs-create-field {
    min-width: 0;
}

.cs-create-input-shell {
    overflow: hidden;
}

.cs-create-input {
    display: block;
    width: 100%;
    min-height: 42px;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
}

.cs-create-input:focus {
    outline: none;
    box-shadow: none;
}

.cs-create-description {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border: none;
    outline: none;
    box-shadow: none;
}

@media (max-width: 991px) {
    .cs-create-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.cs-compose__ai {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 8px 0 10px;
}

.cs-livechat-input {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.cs-livechat-input .input-container {
    max-width: none;
}

.cs-livechat-input:focus-within .input-container {
    border-color: rgba(139, 92, 246, 0.5);
}

.cs-livechat-input .cs-livechat-input__row.input-container {
    border-bottom-width: 0;
}

.cs-livechat-input .cs-livechat-input__toolbar.input-container {
    border-top-width: 0;
    align-items: center;
    padding-top: 4px;
}

.cs-livechat-input .cs-compose__ai,
.cs-livechat-input .cs-compose__ai--icons {
    margin: 0;
    width: 100%;
}

.cs-livechat-input .cs-compose__ai-row {
    width: 100%;
}

.cs-livechat-input .cs-compose__ai--icons .cs-compose__ai-actions {
    flex-wrap: wrap;
}

.cs-livechat-input .cs-compose__ai-status,
.cs-livechat-input .cs-compose__ai-credit {
    margin-top: 6px;
}

.cs-livechat-input .cs-thread__view-lang-label {
    display: none;
}

.cs-compose .cs-livechat-input {
    margin-top: 4px;
}

.cs-compose__ai-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    width: 100%;
}

.cs-compose__ai-trailing {
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 0;
}

.cs-compose__textarea {
    resize: none;
    overflow-y: hidden;
    line-height: 1.35;
    min-height: calc(1.35em * 2 + 20px);
    max-height: calc(1.35em * 6 + 20px);
}

.cs-compose__ai-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cs-compose__ai--icons {
    margin: 4px 0 6px;
}

.cs-compose__ai--icons .cs-compose__ai-actions {
    flex-wrap: nowrap;
    gap: 4px;
}

.cs-thread__view-lang-wrap--end .cs-thread__view-lang-menu {
    left: auto;
    right: 0;
}

.cs-thread__view-lang-wrap--up {
    z-index: 30;
}

.cs-thread__view-lang-wrap--up .cs-thread__view-lang-menu {
    top: auto;
    bottom: calc(100% + 4px);
}

.cs-compose__ai-post {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.cs-compose__ai-post--split {
    padding-left: 16px;
}

.cs-compose__ai-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cs-compose__ai-credit {
    flex: 1 1 100%;
}

.cs-compose__ai-spin {
    font-size: 16px;
    animation: cs-compose-ai-spin 1.1s linear infinite;
}

@keyframes cs-compose-ai-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cs-compose__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.cs-compose__editor {
    position: relative;
}

.cs-mention-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    border-radius: 12px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 10px 28px rgba(30, 40, 70, 0.14);
}

.cs-mention-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.cs-mention-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #5b7cfa;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 650;
}

.cs-mention-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.cs-compose__upload-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    margin: 0;
    cursor: pointer;
    overflow: hidden;
}

.cs-compose__upload-btn .material-icons-outlined {
    font-size: 18px;
    line-height: 1;
}

.cs-compose__upload-btn.is-disabled,
.cs-compose__upload-btn.create-workspace-btn.is-disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

.cs-compose__file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(120, 130, 150, 0.12);
}

.cs-compose__file .material-icons-outlined {
    font-size: 16px;
}

.cs-compose__file-clear {
    border: 0;
    background: transparent;
    padding: 0;
    display: inline-flex;
    cursor: pointer;
}

.cs-compose__file-clear .material-icons-outlined {
    font-size: 16px;
}

/* ---------- Attachments (separate from the message text) ---------- */

.cs-attach {
    display: block;
    margin-top: 12px;
    max-width: 320px;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(120, 130, 150, 0.28);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(120, 130, 150, 0.08);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

.cs-attach:hover {
    border-color: rgba(91, 124, 250, 0.55);
    box-shadow: 0 6px 18px rgba(30, 40, 70, 0.1);
    transform: translateY(-1px);
    text-decoration: none;
    color: inherit;
}

.cs-attach--image .cs-attach__preview {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    background: rgba(120, 130, 150, 0.12);
}

.cs-attach__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.cs-attach__icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(91, 124, 250, 0.16);
    color: #5b7cfa;
}

.cs-attach__icon .material-icons-outlined {
    font-size: 20px;
}

.cs-attach__copy {
    flex: 1 1 auto;
    min-width: 0;
}

.cs-attach__name {
    display: block;
    font-size: 0.86rem;
    font-weight: 650;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-attach__hint {
    display: block;
    font-size: 0.74rem;
    margin-top: 2px;
}

.cs-attach__open {
    flex: 0 0 auto;
    font-size: 18px;
    opacity: 0.7;
}

.dsm-ticket-upload-input {
    display: none;
}

/* ---------- Requester card ---------- */

.cs-requester__identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cs-requester__avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #5b7cfa;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 650;
}

.cs-requester__who {
    min-width: 0;
    flex: 1 1 auto;
}

.cs-requester__name-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cs-requester__name {
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.3;
}

.cs-requester__email {
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.cs-requester__facts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(120, 130, 150, 0.16);
}

.cs-requester__fact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.cs-requester__fact .material-icons-outlined {
    font-size: 17px;
    opacity: 0.7;
    flex: 0 0 auto;
}

.cs-requester__fact-label {
    flex: 0 0 auto;
    min-width: 64px;
    font-size: 0.8rem;
}

.cs-requester__fact-value {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cs-requester__fact--language .cs-requester__fact-label {
    flex: 0 0 auto;
    min-width: 0;
}

.cs-agent__row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cs-agent__col {
    flex: 1 1 140px;
    min-width: 0;
}

.cs-agent__field {
    width: 100%;
    overflow: hidden;
}

.cs-agent__input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.35;
    min-height: 42px;
}

.cs-agent__input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cs-agent__lang-select {
    width: 100%;
}

.cs-agent__lang-select .combinate-component {
    border-radius: 16px !important;
}

.cs-requester__lang-select {
    flex: 1 1 auto;
    max-width: 180px;
    min-width: 0;
    font-weight: 500;
}

.cs-requester__lang-select .combinate-component {
    width: 100% !important;
    max-width: 180px;
    border-radius: 6px !important;
}

.cs-requester__lang-select .combinate-component > .d-flex > div:first-child {
    padding: 2px 6px !important;
}

.cs-requester__lang-select .combinate-component input {
    height: 22px !important;
    font-size: 0.75rem !important;
    padding: 0 4px !important;
}

.cs-requester__lang-select .selector-open-arrow {
    width: 22px !important;
    min-width: 22px !important;
}

.cs-requester__lang-select .selector-open-arrow-icon {
    font-size: 11px !important;
}

.cs-requester__rep {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    background: rgba(43, 184, 166, 0.16);
    color: #1a8578;
}

.cs-requester__rep .material-icons-outlined {
    font-size: 13px;
}

.cs-requester-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.cs-requester-history-head__copy {
    min-width: 0;
    flex: 1 1 auto;
}

.cs-requester-history-head .cs-thread__search {
    flex: 0 0 132px;
    max-width: 132px;
    min-width: 132px;
    height: 32px;
    margin-top: 0;
}

/* ---------- Requester history card ---------- */

.cs-requester-history {
    --cs-history-row: 4.85rem;
    --cs-history-gap: 8px;
    display: flex;
    flex-direction: column;
    gap: var(--cs-history-gap);
    max-height: calc(4 * var(--cs-history-row) + 3 * var(--cs-history-gap));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
}

.cs-requester-history__row {
    display: block;
    flex: 0 0 auto;
    min-height: var(--cs-history-row);
    box-sizing: border-box;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
    appearance: none;
    font: inherit;
    color: inherit;
    border: 1px solid rgba(120, 130, 150, 0.16);
}

.cs-requester-history__row:hover {
    border-color: rgba(91, 124, 250, 0.45);
}

.cs-requester-history__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.cs-requester-history__number {
    font-size: 0.72rem;
    font-weight: 650;
}

.cs-requester-history__status {
    font-size: 0.72rem;
    font-weight: 650;
}

.cs-requester-history__subject {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cs-requester-history__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.75rem;
}

/* ---------- Time card ---------- */

.cs-time__metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cs-time__metric {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(120, 130, 150, 0.08);
    border: 1px solid rgba(120, 130, 150, 0.12);
}

.cs-time__metric-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.cs-time__metric-label .material-icons-outlined {
    font-size: 15px;
    opacity: 0.75;
}

.cs-time__metric-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

.cs-time__metric-hint {
    margin-top: 2px;
    font-size: 0.72rem;
    line-height: 1.35;
}

.cs-time__badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 650;
    background: rgba(43, 184, 166, 0.16);
    color: #1a8578;
}

.cs-time__badge--done {
    background: rgba(120, 130, 150, 0.18);
    color: inherit;
    opacity: 0.85;
}

.cs-time__agents {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(120, 130, 150, 0.16);
}

.cs-time__agents-title {
    font-size: 0.78rem;
    font-weight: 650;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cs-time__agent-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.cs-time__agent-row + .cs-time__agent-row {
    border-top: 1px solid rgba(120, 130, 150, 0.1);
}

.cs-time__agent-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(91, 124, 250, 0.22);
    color: #8aa4ff;
    font-size: 0.72rem;
    font-weight: 700;
}

.cs-time__agent-body {
    min-width: 0;
    flex: 1 1 auto;
}

.cs-time__agent-name {
    font-size: 0.88rem;
    font-weight: 650;
    line-height: 1.25;
}

.cs-time__agent-summary {
    font-size: 0.72rem;
    line-height: 1.3;
}

.cs-time__agent-total {
    flex: 0 0 auto;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ---------- Audit ---------- */

.cs-audit {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cs-audit__row {
    display: flex;
    gap: 9px;
    font-size: 0.82rem;
    line-height: 1.45;
}

.cs-audit__row .material-icons-outlined {
    font-size: 16px;
    opacity: 0.7;
    flex: 0 0 auto;
    margin-top: 2px;
}

.cs-audit__summary {
    font-weight: 600;
}

.cs-csat__stars {
    display: flex;
    align-items: center;
    gap: 2px;
}

.cs-csat__star-btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: inherit;
    line-height: 1;
}

.cs-csat__star-btn:disabled {
    cursor: default;
}

.cs-csat__star {
    font-size: 28px;
    opacity: 0.35;
}

.cs-csat__star--on {
    opacity: 1;
    color: #f5c542;
}

/* Below the lg breakpoint the two columns stack, so the whole page scrolls as one instead of
   giving the thread its own viewport-height pane. */
@media (max-width: 991.98px) {
    .page-content .content-withTopTab:has(.cs-detail-page),
    .page-content .content-withTopTab:has(.cs-detail-page) .card-content,
    .page-content .content-withTopTab:has(.dsm-docs-page),
    .page-content .content-withTopTab:has(.dsm-docs-page) .card-content,
    .page-content .content-withTopTab:has(.ap-docs-page),
    .page-content .content-withTopTab:has(.ap-docs-page) .card-content,
    .workspace-dashboard.cs-detail-page {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .cs-detail {
        overflow-y: auto;
        flex: 1 1 auto;
    }

    .cs-detail__side,
    .cs-detail__main {
        height: auto;
        max-height: none;
    }

    .cs-detail__side,
    .cs-thread {
        overflow: visible;
    }
}

@media (max-width: 700px) {
    .cs-msg__avatar {
        display: none;
    }

    .cs-msg__bubble {
        max-width: 100%;
    }

    .cs-msg__time {
        margin-left: 0;
    }
}
