/* =========================================================
   Chat — Plugin ticketview
   ========================================================= */

/* ---------- Variáveis locais (mapeadas do plugin layout + GLPI/Tabler) ---------- */
:root {
    --tt-primary:       var(--main-primary-color,       #3a266b);
    --tt-primary-hover: var(--main-primary-color-hover, #744896);
    --tt-primary-text:  var(--main-primary-color-text,  #ffffff);
    --tt-bg:            var(--tblr-body-bg,             #f1f5f9);
    --tt-surface:       var(--main-detach-color,        #ffffff);
    --tt-surface-soft:  var(--sp-light-color,           #f3f6f4);
    --tt-border:        var(--tblr-border-color,        #e2e8f0);
    --tt-text:          var(--tblr-body-color,          #334155);
    --tt-text-muted:    var(--tblr-muted,               #94a3b8);
}

/* Host do plugin */
.tt-page-host {
    width: 100%;
}

/* ---------- Layout geral ---------- */
.tt-wrap {
    display: flex;
    height: calc(100vh - 110px);
    min-height: 500px;
    background: var(--tt-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
    margin: 0 12px 12px;
}

/* ---------- SIDEBAR ---------- */
.tt-sidebar {
    width: 300px;
    min-width: 260px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    background: var(--tt-surface);
    border-right: 1px solid var(--tt-border);
    flex-shrink: 0;
}

.tt-sidebar-top {
    padding: 16px 14px 10px;
    border-bottom: 1px solid var(--tt-border);
    background: var(--tt-surface);
}

.tt-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--tt-text);
    margin-bottom: 10px;
}

.tt-sidebar-title i {
    font-size: 1.2rem;
    color: var(--tt-primary);
}

/* ---------- Botão de filtro ---------- */
.tt-filter-btn {
    margin-left: auto;
    position: relative;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--tt-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .12s, color .12s;
    flex-shrink: 0;
}

.tt-filter-btn:hover,
.tt-filter-btn--active {
    background: var(--tt-surface-soft);
    color: var(--tt-primary);
}

.tt-filter-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--tt-primary);
    color: var(--tt-primary-text);
    border-radius: 50%;
    font-size: .6rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------- Painel de filtros ---------- */
.tt-filter-panel {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--tt-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#tt-filter-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

#tt-filter-modal .tt-filter-panel {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    gap: 14px;
}

.tt-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tt-filter-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--tt-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tt-filter-label small {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.tt-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tt-chip {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 500;
    border: 1px solid var(--tt-border);
    background: var(--tt-surface-soft);
    color: var(--tt-text-muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
    line-height: 1.4;
}

.tt-chip:hover {
    border-color: var(--tt-primary);
    color: var(--tt-primary);
}

.tt-chip--on {
    background: var(--tt-primary);
    border-color: var(--tt-primary);
    color: var(--tt-primary-text);
}

.tt-chip--on:hover {
    background: var(--tt-primary-hover);
    border-color: var(--tt-primary-hover);
    color: var(--tt-primary-text);
}

.tt-filter-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--tt-border);
    border-radius: 6px;
    font-size: .8rem;
    background: var(--tt-surface-soft);
    color: var(--tt-text);
    outline: none;
    cursor: pointer;
}

.tt-filter-select:focus {
    border-color: var(--tt-primary);
}

.tt-filter-actions {
    display: flex;
    gap: 6px;
    padding-top: 2px;
}

#tt-filter-modal .tt-filter-actions {
    padding-top: 12px;
}

.tt-filter-apply,
.tt-filter-clear {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background .12s;
}

.tt-filter-apply {
    background: var(--tt-primary);
    color: var(--tt-primary-text);
}

.tt-filter-apply:hover {
    background: var(--tt-primary-hover);
}

.tt-filter-clear {
    background: var(--tt-surface-soft);
    color: var(--tt-text-muted);
    border: 1px solid var(--tt-border);
}

.tt-filter-clear:hover {
    color: var(--tt-text);
    border-color: var(--tt-text-muted);
}

.tt-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--tt-text-muted);
    text-decoration: none;
    transition: background .12s, color .12s;
    flex-shrink: 0;
}

.tt-back-btn:hover {
    background: var(--tt-surface-soft);
    color: var(--tt-primary);
}

.tt-back-btn i {
    font-size: 1rem;
    color: inherit;
}

.tt-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--tt-border);
    border-radius: 8px;
    background: var(--tt-surface-soft);
    padding: 6px 10px;
    transition: border-color .15s, background .15s;
}

.tt-search-wrap:focus-within {
    border-color: var(--tt-primary);
    background: var(--tt-surface);
}

.tt-search-icon {
    color: var(--tt-text-muted);
    font-size: .9rem;
    pointer-events: none;
    flex-shrink: 0;
    line-height: 1;
}

.tt-search {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    font-size: .82rem;
    color: var(--tt-text);
    padding: 0;
}

/* ---------- Lista de chamados ---------- */
.tt-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tt-pagination {
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--tt-border);
    background: var(--tt-surface);
}

.tt-page-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--tt-border);
    border-radius: 50%;
    background: var(--tt-surface-soft);
    color: var(--tt-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tt-page-btn:hover,
.tt-page-btn:focus {
    border-color: var(--tt-primary);
    color: var(--tt-primary);
}

.tt-page-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    border-color: var(--tt-border);
    color: var(--tt-text-muted);
}

.tt-page-info {
    min-width: 48px;
    text-align: center;
    color: var(--tt-text-muted);
    font-size: .78rem;
    font-weight: 600;
}

.tt-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--tt-text-muted);
    font-size: 1.5rem;
}

.tt-ticket-item {
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--tt-bg);
    transition: background .12s;
    position: relative;
}

.tt-ticket-item:hover {
    background: var(--tt-surface-soft);
}

.tt-ticket-item.active {
    background: rgba(var(--tblr-primary-rgb, 58, 38, 107), .08);
    border-left: 3px solid var(--tt-primary);
}

.tt-ticket-item.tt-unread .tt-ticket-title {
    font-weight: 700;
    color: var(--tt-text);
}

.tt-ticket-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.tt-status-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    line-height: 1;
    flex-shrink: 0;
}

.tt-ticket-id {
    font-size: .75rem;
    color: var(--tt-text-muted);
    font-weight: 600;
}

.tt-ticket-priority {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    color: var(--tt-text-muted);
    font-size: .72rem;
    font-weight: 600;
}

.tt-ticket-priority::before {
    content: "-";
    color: var(--tt-text-muted);
    font-weight: 400;
}

.tt-ticket-priority i {
    font-size: .45rem;
    line-height: 1;
    flex-shrink: 0;
}

.tt-ticket-time {
    margin-left: auto;
    font-size: .72rem;
    color: var(--tt-text-muted);
    white-space: nowrap;
}

.tt-ticket-title {
    font-size: .85rem;
    color: var(--tt-text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.tt-ticket-sub {
    font-size: .75rem;
    color: var(--tt-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-unread-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--tt-primary);
    border-radius: 50%;
}

.tt-empty-list {
    padding: 32px 16px;
    text-align: center;
    color: var(--tt-text-muted);
    font-size: .85rem;
}

/* ---------- PAINEL DE CHAT ---------- */
.tt-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-width: 0;
    background: var(--tt-bg);
    position: relative;
}

/* Estado vazio */
.tt-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--tt-text-muted);
    gap: 12px;
}

.tt-empty i {
    font-size: 3rem;
    opacity: .4;
}

.tt-empty p {
    font-size: .9rem;
}

/* Conversa */
.tt-convo {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    min-width: 0;
}

/* Header do chamado */
.tt-convo-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--tt-surface);
    border-bottom: 1px solid var(--tt-border);
    flex-shrink: 0;
}

.tt-header-status {
    font-size: .8rem;
    flex-shrink: 0;
}

.tt-header-name {
    font-size: .95rem;
    font-weight: 700;
    color: var(--tt-text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-header-link {
    color: var(--tt-text-muted);
    font-size: 1rem;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 6px;
    border: 0;
    background: transparent;
    transition: background .12s, color .12s;
    flex-shrink: 0;
    cursor: pointer;
}

.tt-header-link:hover {
    background: var(--tt-surface-soft);
    color: var(--tt-primary);
}

.tt-ticket-info {
    display: none;
    width: 370px;
    max-width: 36%;
    height: 100%;
    min-height: 0;
    flex-shrink: 0;
    flex-direction: column;
    background: var(--tt-surface);
    border-left: 1px solid var(--tt-border);
    position: relative;
}

.tt-chat-panel.tt-info-open .tt-ticket-info {
    display: flex;
}

.tt-ticket-info-close {
    position: absolute;
    top: 11px;
    right: 8px;
    z-index: 20;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tt-text-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.tt-ticket-info-close:hover,
.tt-ticket-info-close:focus {
    background: var(--tt-surface-soft);
    color: var(--tt-primary);
}

.tt-ticket-info-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.tt-ticket-info-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 18px;
    background: var(--tt-surface);
    border-top: 1px solid var(--tt-border);
    flex-shrink: 0;
}

.tt-ticket-info-actions .btn-group .btn {
    min-width: 58px;
}

.tt-ticket-info-actions .btn-primary {
    background: var(--tt-primary);
    border-color: var(--tt-primary);
    color: var(--tt-primary-text);
}

.tt-ticket-info #itil-data {
    min-height: 100%;
}

.tt-ticket-info #itil-data > .accordion-item:first-child .accordion-button {
    padding-right: 46px;
}

.tt-ticket-info #itil-data .switch-panel-width {
    display: none;
}

.tt-ticket-info .accordion-body.row > .field-container {
    width: 100%;
}

.tt-ticket-info .field-container {
    margin-bottom: .75rem;
}

.tt-ticket-info .select2-container {
    width: 100% !important;
    min-width: 0;
}

.tt-ticket-info .select2-selection__choice {
    max-width: calc(100% - 8px);
}

.tt-ticket-info .select2-selection__choice__display,
.tt-ticket-info .actor_entry .actor_text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-ticket-info .actor_entry {
    max-width: 100%;
    display: inline-flex;
    align-items: center;
}

/* ---------- Mensagens ---------- */
.tt-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    overflow-anchor: none;
}

.tt-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tt-msg {
    display: flex;
    gap: 10px;
    max-width: 75%;
}

.tt-msg.tt-msg-mine {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.tt-msg.tt-msg-other {
    align-self: flex-start;
}

/* Avatar */
.tt-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 4px;
    letter-spacing: .5px;
    overflow: hidden;
}

.tt-avatar-image {
    position: relative;
    background: var(--tt-text-muted);
}

.tt-avatar-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tt-avatar-image span {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.tt-avatar-image img:not([src]),
.tt-avatar-image img[src=""] {
    display: none;
}

.tt-avatar-image img:not([src]) + span,
.tt-avatar-image img[src=""] + span {
    display: flex;
}

/* Bolha */
.tt-bubble {
    background: var(--tt-surface);
    border-radius: 12px 12px 12px 3px;
    padding: 10px 13px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    min-width: 120px;
    word-wrap: break-word;
}

.tt-msg-mine .tt-bubble {
    background: var(--tt-primary);
    border-radius: 12px 12px 3px 12px;
    color: var(--tt-primary-text);
}

.tt-bubble-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.tt-bubble-author {
    font-size: .75rem;
    font-weight: 700;
    color: var(--tt-primary);
}

.tt-msg-mine .tt-bubble-author {
    color: rgba(255, 255, 255, .75);
}

.tt-bubble-time {
    font-size: .7rem;
    color: var(--tt-text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.tt-msg-mine .tt-bubble-time {
    color: rgba(255, 255, 255, .6);
}

.tt-bubble-content {
    font-size: .85rem;
    line-height: 1.5;
    color: var(--tt-text);
    white-space: normal;
    word-break: break-word;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 1.2em;
    padding: 4px 0;
}

.tt-bubble-content-empty {
    display: none;
}

.tt-bubble-content p {
    margin: 8px 0;
    line-height: 1.6;
}

.tt-bubble-content p:first-child {
    margin-top: 0;
}

.tt-bubble-content p:last-child {
    margin-bottom: 0;
}

.tt-bubble-content br {
    display: block;
    content: '';
    margin: 4px 0;
}

.tt-bubble-content strong,
.tt-bubble-content b {
    font-weight: 700;
}

.tt-bubble-content em,
.tt-bubble-content i {
    font-style: italic;
}

.tt-bubble-content u {
    text-decoration: underline;
}

.tt-bubble-content a {
    color: var(--tt-primary);
    text-decoration: none;
    cursor: pointer;
}

.tt-bubble-content a:hover {
    text-decoration: underline;
}

.tt-bubble-content ul,
.tt-bubble-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.tt-bubble-content li {
    margin: 4px 0;
}

.tt-bubble-content blockquote {
    border-left: 3px solid var(--tt-border);
    margin: 8px 0;
    padding-left: 12px;
    color: var(--tt-text-muted);
    font-style: italic;
}

.tt-bubble-content code {
    background: var(--tt-surface-soft);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: .8rem;
}

.tt-bubble-content pre {
    background: var(--tt-surface-soft);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.tt-bubble-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: .8rem;
}

.tt-bubble-content table td,
.tt-bubble-content table th {
    border: 1px solid var(--tt-border);
    padding: 6px 8px;
    text-align: left;
}

.tt-bubble-content table th {
    background: var(--tt-surface-soft);
    font-weight: 700;
}

.tt-shared-contact {
    display: grid;
    gap: 8px;
    min-width: min(260px, 100%);
}

.tt-shared-contact-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
}

.tt-shared-contact-row span {
    color: var(--tt-text-muted);
    font-size: .78rem;
    font-weight: 700;
}

.tt-shared-contact-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.tt-shared-contact-action {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    background: #128c7e;
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.tt-shared-contact-action:hover,
.tt-shared-contact-action:focus {
    background: #075e54;
    color: #fff;
}

.tt-bubble-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.tt-msg-mine .tt-bubble-content {
    color: var(--tt-primary-text);
}

.tt-msg-mine .tt-bubble-content a {
    color: rgba(255, 255, 255, .9);
}

.tt-msg-mine .tt-bubble-content blockquote {
    border-left-color: rgba(255, 255, 255, .3);
    color: rgba(255, 255, 255, .8);
}

.tt-msg-mine .tt-bubble-content code {
    background: rgba(0, 0, 0, .2);
}

.tt-msg-mine .tt-bubble-content pre {
    background: rgba(0, 0, 0, .2);
}

.tt-bubble-attachments:empty {
    display: none;
}

.tt-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.tt-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    color: var(--tt-text);
    text-decoration: none;
    overflow: hidden;
}

.tt-attachment:hover {
    text-decoration: none;
}

.tt-attachment-icon,
.tt-attachment-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tt-attachment-title-wrap {
    min-width: 0;
    flex: 1;
}

.tt-attachment-title {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-attachment-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: .7rem;
    color: var(--tt-text-muted);
}

.tt-attachment-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-attachment-meta span + span::before {
    content: "-";
    margin-right: 6px;
}

.tt-attachment-document,
.tt-attachment-audio {
    background: rgba(var(--tblr-primary-rgb, 58, 38, 107), .07);
    border: 1px solid var(--tt-border);
    padding: 9px 10px;
}

.tt-attachment-document:hover,
.tt-attachment-document:focus {
    border-color: var(--tt-primary);
    color: var(--tt-primary);
}

.tt-attachment-document .tt-attachment-icon,
.tt-attachment-audio .tt-attachment-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tt-surface);
    color: var(--tt-primary);
    font-size: 1.1rem;
}

.tt-attachment-download {
    color: var(--tt-text-muted);
    font-size: 1rem;
}

.tt-attachment-image {
    display: block;
    max-width: min(320px, 100%);
    background: rgba(0, 0, 0, .06);
    border: 1px solid var(--tt-border);
}

.tt-attachment-video {
    display: block;
    max-width: min(380px, 100%);
    background: rgba(0, 0, 0, .06);
    border: 1px solid var(--tt-border);
}

.tt-attachment-image img {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: cover;
}

.tt-attachment-video video {
    display: block;
    width: 100%;
    max-height: 300px;
    background: #000;
}

.tt-attachment-image-caption,
.tt-attachment-video-caption {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    background: rgba(var(--tblr-primary-rgb, 58, 38, 107), .07);
    color: var(--tt-text);
    font-size: .72rem;
    font-weight: 600;
}

.tt-attachment-image-caption span,
.tt-attachment-video-caption span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-attachment-audio {
    flex-direction: column;
    align-items: stretch;
    max-width: 360px;
}

.tt-attachment-audio-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tt-audio-player {
    margin-top: 8px;
}

.tt-audio-player audio {
    width: 100%;
    height: 34px;
}

.tt-msg-mine .tt-attachment {
    color: var(--tt-primary-text);
}

.tt-msg-mine .tt-attachment-document,
.tt-msg-mine .tt-attachment-audio {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .25);
}

.tt-msg-mine .tt-attachment-document:hover,
.tt-msg-mine .tt-attachment-document:focus {
    border-color: rgba(255, 255, 255, .7);
    color: var(--tt-primary-text);
}

.tt-msg-mine .tt-attachment-document .tt-attachment-icon,
.tt-msg-mine .tt-attachment-audio .tt-attachment-icon {
    background: rgba(255, 255, 255, .18);
    color: var(--tt-primary-text);
}

.tt-msg-mine .tt-attachment-meta,
.tt-msg-mine .tt-attachment-download {
    color: rgba(255, 255, 255, .72);
}

.tt-msg-mine .tt-attachment-image-caption {
    background: rgba(255, 255, 255, .14);
    color: var(--tt-primary-text);
}

.tt-msg-mine .tt-attachment-video-caption {
    background: rgba(255, 255, 255, .14);
    color: var(--tt-primary-text);
}

/* Tags na bolha */
.tt-bubble-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 7px;
}

.tt-tag {
    font-size: .68rem;
    padding: 1px 7px;
    border-radius: 12px;
    background: var(--tt-bg);
    color: var(--tt-text);
    border: 1px solid var(--tt-border);
}

.tt-msg-mine .tt-tag {
    background: rgba(255,255,255,.2);
    color: var(--tt-primary-text);
    border-color: rgba(255,255,255,.3);
}

/* Bolha de descrição do chamado (primeira mensagem) */
.tt-msg-ticket .tt-bubble {
    background: var(--tt-surface-soft);
    border-left: 3px solid var(--tt-primary);
    border-radius: 3px 12px 12px 12px;
}

/* Mensagem privada */
.tt-msg-private .tt-bubble {
    border-left: 3px solid var(--tblr-warning, #f59e0b);
}

.tt-private-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: .68rem;
    color: var(--tblr-warning, #f59e0b);
    margin-bottom: 4px;
}

.tt-pending-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    font-weight: 500;
    color: var(--tblr-warning-text-emphasis, #92400e);
    background: var(--tblr-warning-bg, #fffbeb);
    border: 1px solid var(--tblr-warning, #f59e0b);
    border-radius: 6px;
    padding: 4px 10px;
    margin-top: 6px;
}

.tt-pending-badge i {
    font-size: .7rem;
    color: var(--tblr-warning, #f59e0b);
}

/* Spinner de carregamento de mensagens */
.tt-msgs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--tt-text-muted);
    font-size: 1.5rem;
}

/* ---------- Área de composição ---------- */
.tt-compose {
    display: flex;
    flex-direction: column;
    background: var(--tt-surface);
    border-top: 1px solid var(--tt-border);
    flex-shrink: 0;
}

.tt-pending-wrapper {
    padding: 8px 16px 0;
}

.tt-pending-wrapper > .input-group-text {
    width: 100%;
    border: none;
    border-radius: 8px;
    background: var(--tblr-warning-bg, #fffbeb);
    padding: 8px 12px;
}

.tt-pending-wrapper .row > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Respeita o Bootstrap collapse */
.tt-pending-wrapper .row > div.collapse:not(.show) {
    display: none !important;
}

.tt-pending-wrapper .row > div.collapse.show {
    display: flex !important;
}

/* Select2 compacto e levemente arredondado — apenas width, height, border-radius e cor do texto */
.tt-pending-wrapper .select2-container {
    width: 100%;
    min-width: 0;
}

.tt-pending-wrapper .select2-container .select2-selection--single {
    border-radius: 4px;
    min-height: 26px;
}

.tt-pending-wrapper .select2-container .select2-selection__rendered {
    line-height: 24px;
    color: var(--tblr-body-color);
}

.tt-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
}

.tt-attachments-input {
    display: none;
}

.tt-attach {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--tt-border);
    background: var(--tt-surface-soft);
    color: var(--tt-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s, transform .1s;
}

.tt-attach:hover,
.tt-attach:focus {
    background: var(--tt-surface);
    border-color: var(--tt-primary);
    color: var(--tt-primary);
}

.tt-attach:active {
    transform: scale(.95);
}

.tt-attach:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

.tt-selected-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 0;
}

.tt-selected-attachments:empty {
    display: none;
}

.tt-selected-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: min(100%, 320px);
    padding: 5px 7px;
    border-radius: 999px;
    background: var(--tt-surface-soft);
    border: 1px solid var(--tt-border);
    color: var(--tt-text);
    font-size: .75rem;
}

.tt-selected-attachment > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-selected-attachment small {
    color: var(--tt-text-muted);
    white-space: nowrap;
}

.tt-selected-attachment button {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--tt-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.tt-selected-attachment button:hover,
.tt-selected-attachment button:focus {
    background: rgba(var(--tblr-primary-rgb, 58, 38, 107), .1);
    color: var(--tt-primary);
}

/* Select2 dropdown sempre acima de tudo */
.select2-container--open {
    z-index: 9999 !important;
}

.select2-dropdown {
    z-index: 9999 !important;
}

.tt-input {
    flex: 1;
    border: 1px solid var(--tt-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: .875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 42px;
    overflow-y: auto;
    color: var(--tt-text);
    background: var(--tt-surface-soft);
    transition: border-color .15s, background .15s;
    font-family: inherit;
}

.tt-input:focus {
    border-color: var(--tt-primary);
    background: var(--tt-surface);
}

.tt-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--tt-primary);
    color: var(--tt-primary-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}

.tt-send:hover {
    background: var(--tt-primary-hover);
    transform: scale(1.05);
}

.tt-send:active {
    transform: scale(.95);
}

.tt-send:disabled {
    background: rgba(var(--tblr-primary-rgb, 58, 38, 107), .3);
    cursor: not-allowed;
    transform: none;
}

/* ---------- Responsivo ---------- */
@media (max-width: 768px) {
    .tt-sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--tt-border);
        height: 45vh;
    }

    .tt-wrap {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 110px);
    }

    .tt-chat-panel {
        height: 55vh;
    }

    .tt-ticket-info {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
        width: min(320px, 92vw);
        max-width: 92vw;
        box-shadow: -8px 0 20px rgba(0,0,0,.12);
    }
}
