/*
    Subtickets y comentarios internos.

    Un solo archivo para las dos UIs porque los mismos tres elementos (la pastilla violeta del subticket,
    la franja de la tarjeta y la pestaña de comentarios) aparecen en agentes y en supervision. Todo va
    prefijado con st- para no chocar con nada de theme.css ni de inspinia.
*/

:root {
    /* Violeta: el color del trabajo que se fue a otra area. No es el color de ninguna empresa. */
    --st-ext: #6A46A8;
    --st-ext-dark: #553487;
    --st-ext-soft: rgba(106, 70, 168, .13);
    --st-queue: #b18700;
    --st-assigned: #007286;
    --st-closed: #00863c;
}

/* ---------- pastillas de estado ---------- */

.st-pill {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding: 2px 6px;
    line-height: 1.3;
    white-space: nowrap;
    font-size: 13px;
    color: var(--st-pill-color, #919191);
}

.st-pill::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: var(--st-pill-color, #919191);
    opacity: .15;
}

.st-pill > span {
    position: relative;
}

.st-pill-queue { --st-pill-color: var(--st-queue); }
.st-pill-assigned { --st-pill-color: var(--st-assigned); }
.st-pill-closed { --st-pill-color: var(--st-closed); }

/* ---------- badge del encabezado del panel ---------- */

.st-badge {
    font-size: 11.7px;
    line-height: 1;
    margin: 0 5px;
    padding: 3px 5px;
    border-radius: 4px;
    font-weight: 700;
    display: inline-block;
    background: var(--st-ext-soft);
    color: var(--st-ext-dark);
}

.st-badge.st-done {
    background: rgba(60, 180, 184, .15);
    color: #309195;
}

/* ---------- panel de subtickets ---------- */

.st-panel-icon { color: var(--st-ext); }
.st-panel-icon.st-done { color: #309195; }

.st-table {
    width: 100%;
}

.st-th-row,
.st-tr-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 132px 78px 62px;
    gap: 10px;
    align-items: center;
}

.st-th-row {
    padding: 6px 0;
    border-bottom: 2px solid #dee2e6;
}

.st-th-row h6 {
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    margin: 0;
}

.st-tr-row {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.st-tr-row.st-root { border-bottom: 1px solid #dee2e6; }
.st-tr-row:last-child { border-bottom: none; }

/* Un ticket resuelto se apaga: sigue estando, pero ya no compite por la atencion del agente */
.st-tr-row.st-muted { opacity: .6; }

/* Anulado no es lo mismo que cerrado: ese trabajo no cuenta, y tachar el codigo es lo que lo dice */
.st-tr-row.st-void .st-code {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

/* La fila del ticket que se esta viendo, para no perderse dentro de la cadena. La barra va colgada en un
   pseudo elemento y el tinte se extiende con la sombra, para no mover la rejilla ni una columna. */
.st-tr-row.st-current {
    position: relative;
    background: var(--st-ext-soft);
    box-shadow: -8px 0 0 0 var(--st-ext-soft), 8px 0 0 0 var(--st-ext-soft);
}

.st-tr-row.st-current::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--st-ext);
}

.st-tr-row.st-current .st-code {
    color: var(--st-ext-dark);
    font-weight: 700;
}

.st-tr-row.st-current .st-kid::before,
.st-tr-row.st-current .st-kid::after { background: var(--st-ext); }

.st-node {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

/* El conector en L que cuelga al hijo de la fila de arriba */
.st-kid {
    flex: 0 0 18px;
    height: 20px;
    position: relative;
    margin-left: 5px;
}

.st-kid::before {
    content: "";
    position: absolute;
    left: 0;
    top: -16px;
    bottom: 10px;
    width: 1px;
    background: #ced4da;
}

.st-kid::after {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    width: 12px;
    height: 1px;
    background: #ced4da;
}

.st-code {
    font-weight: 500;
    color: #309195;
    white-space: nowrap;
}

.st-who {
    font-size: 11px;
    color: #6c757d;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-cell-area,
.st-cell-time {
    font-size: 13px;
    color: #495057;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- migas del titulo del ticket ---------- */

/* Hereda el alto de linea del titulo: la miga no puede empujar nada hacia abajo */
.st-crumb {
    display: inline;
    font-size: .68em;
    font-weight: 500;
    letter-spacing: .01em;
    white-space: nowrap;
}

.st-crumb-link {
    color: var(--st-ext-dark);
    text-decoration: none;
    cursor: pointer;
}

.st-crumb-link:hover {
    color: var(--st-ext);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.st-crumb-link.st-muted { opacity: .6; }

.st-crumb-sep {
    margin: 0 4px;
    color: #ced4da;
    font-weight: 400;
}

/* ---------- franja de la tarjeta del ticket ---------- */

.st-card-sub,
.st-card-comment {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    line-height: 1.3;
    margin-top: 4px;
}

.st-card-sub {
    color: var(--st-ext-dark);
    font-weight: 500;
}

.st-card-sub.st-done {
    color: #6c757d;
    font-weight: 400;
}

.st-card-sub .st-closed-count {
    color: #6c757d;
    font-weight: 400;
}

.st-card-comment {
    color: #8a6100;
    font-weight: 500;
}

.st-card-parent {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    line-height: 1.3;
    margin-top: 4px;
    color: var(--st-ext-dark);
}

/* ---------- pestañas de mensajes y comentarios ---------- */

.st-tabs {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
    flex: 0 0 auto;
}

.st-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.st-tab:hover { color: #495057; }

.st-tab.st-on {
    color: #309195;
    border-bottom-color: #3CB4B8;
}

.st-tab .st-n {
    display: inline-block;
    min-width: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--st-ext);
    color: #fff;
    font-size: 10.5px;
    line-height: 17px;
    text-align: center;
    font-weight: 700;
}

/* ---------- hilo de comentarios ---------- */

.st-comments {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.st-comments-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.st-cmt {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
}

.st-cmt.st-pend {
    border-left: 3px solid #ffc107;
    background: #fffdf7;
}

.st-cmt-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.st-avat {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e9ecef;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.st-avat.st-ext {
    background: var(--st-ext-soft);
    color: var(--st-ext-dark);
}

.st-cmt-who {
    line-height: 1.2;
    min-width: 0;
}

.st-cmt-who b {
    font-weight: 500;
    display: block;
    font-size: 13px;
}

.st-cmt-who span {
    font-size: 11px;
    color: #6c757d;
}

.st-flag {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 7px;
    border-radius: 10px;
    background: #fff3cd;
    color: #8a6100;
    white-space: nowrap;
}

.st-flag.st-ok {
    background: rgba(60, 180, 184, .15);
    color: #309195;
}

.st-cmt-body {
    font-size: 13px;
    line-height: 1.5;
    color: #212529;
    /* theme.css sangra la primera linea de los parrafos del chat; aqui no aplica */
    text-indent: 0;
}

/* ---------- de donde vino el comentario ---------- */

/*
    El origen es metadato de quien habla, no contenido: va en la linea del autor y con menos peso que el
    nombre. Solo aparece cuando el comentario salio de otro ticket; decirlo en el hilo propio seria ruido.
*/
.st-cmt-from {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--st-ext-dark);
    text-decoration: none;
}

a.st-cmt-from:hover { text-decoration: underline; }

.st-cmt-from-sep {
    margin: 0 4px;
    color: #adb5bd;
}

/* ---------- avisos que escribe Bitdesk ---------- */

/* apagado y con borde punteado: dice que paso algo, no que alguien hablo */
.st-cmt.st-cmt-system {
    background: #fbfbfd;
    border-style: dashed;
}

/* mientras espera acuse manda la franja de pendiente, que es la que el agente busca */
.st-cmt.st-cmt-system.st-pend {
    background: #fffdf7;
    border-style: solid;
}

.st-cmt-system .st-cmt-body { color: #495057; }

.st-avat.st-sys {
    background: #eef0f4;
    color: #6c757d;
}

/* ---------- codigos de ticket dentro del texto ---------- */

.st-code-link {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--st-ext-dark);
    background: var(--st-ext-soft);
    border-radius: 3px;
    padding: 0 3px;
    text-decoration: none;
}

.st-code-link:hover {
    color: var(--st-ext-dark);
    text-decoration: underline;
}

.st-cmt-acts {
    display: flex;
    gap: 6px;
    margin-top: 9px;
}

/* ---------- caja de escribir comentario ---------- */

.st-compose {
    flex: 0 0 auto;
    border-top: 1px solid #e9ecef;
    padding: 10px 16px 14px;
    background: #fff;
}

.st-compose-box {
    border: 1px solid #ced4da;
    border-radius: 6px;
    overflow: hidden;
}

.st-compose-box textarea {
    width: 100%;
    border: none;
    resize: none;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    outline: none;
    min-height: 62px;
}

.st-compose-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.st-compose-tools .st-switch-label {
    font-size: 12px;
    color: #495057;
    margin: 0;
}

.st-compose-tools .st-send {
    margin-left: auto;
}

.st-compose-hint {
    font-size: 11px;
    color: #6c757d;
    line-height: 1.35;
    margin-top: 7px;
}

/* ---------- barra de contexto cuando se comenta desde un subticket ---------- */

.st-ctx {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    background: var(--st-ext-soft);
    color: var(--st-ext-dark);
    font-size: 12.5px;
    line-height: 1.35;
}

/* ---------- eventos de subticket en la conversacion ---------- */

.st-chat-event {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.st-chat-event > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11.5px;
    background: var(--st-ext-soft);
    color: var(--st-ext-dark);
}

.st-chat-event.st-close > span {
    background: rgba(60, 180, 184, .15);
    color: #309195;
}

/* ---------- supervision ---------- */

.st-sup-count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--st-ext-dark);
    white-space: nowrap;
}

.st-sup-count.st-done {
    color: #6c757d;
}

.st-sup-count.st-none {
    color: #adb5bd;
}

.st-sup-parent {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--st-ext-dark);
    white-space: nowrap;
}

.st-sup-parent b {
    font-weight: 500;
}

/* ---------- grupos del dropdown de crear ticket ---------- */

.st-dd-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 3px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #adb5bd;
    border-top: 1px solid #e9ecef;
    margin-top: 4px;
}

.st-dd-group:first-child {
    border-top: none;
    margin-top: 0;
}

.st-dd-group.st-sub {
    color: var(--st-ext-dark);
}

.st-dd-group .st-dd-ctx {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: #6c757d;
}

.st-dd-area {
    margin-left: auto;
    padding-left: 12px;
    font-size: 11px;
    color: #6c757d;
}

/* ==========================================================================
   Tiempo de espera de la lista de supervision
   ========================================================================== */

.st-wait {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.25;
}

.st-wait-top {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #495057;
}

.st-wait-time {
    font-size: 13px;
    font-weight: 500;
    /* Las duraciones se leen en columna: las cifras tienen que alinearse */
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.st-wait-from {
    font-size: 11px;
    color: #6c757d;
    white-space: nowrap;
}

/* La espera interna es la unica que el supervisor no puede deducir mirando la conversacion */
.st-wait-internal .st-wait-top { color: #8a6100; }
.st-wait-internal .st-wait-from { color: #8a6100; opacity: .8; }

.st-wait-none {
    color: #ced4da;
    font-size: 15px;
}

/* Enlace al ticket padre desde la fila del subticket */
.st-sup-link {
    font-weight: 500;
    color: var(--st-ext-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.st-sup-link:hover {
    color: var(--st-ext);
    text-decoration: underline;
}

/* ==========================================================================
   El contador de la pestaña late cuando hay algo sin atender
   ========================================================================== */

.st-n.st-pulse {
    animation: st-pulse 1.1s ease-out 4;
}

@keyframes st-pulse {
    0% { box-shadow: 0 0 0 0 rgba(106, 70, 168, .55); }
    70% { box-shadow: 0 0 0 7px rgba(106, 70, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(106, 70, 168, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .st-n.st-pulse { animation: none; }
}

/* ==========================================================================
   Selector de destino: en que ticket cae el comentario
   ========================================================================== */

/* --- Opcion A: la lista del arbol inmediato --- */

.st-dest {
    flex: 0 0 auto;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 7px 0 6px;
    max-height: 132px;
    overflow-y: auto;
}

.st-dest-hd {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #adb5bd;
    padding: 0 14px 5px;
}

.st-dest-row {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 5px 14px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    color: #495057;
    border-left: 3px solid transparent;
}

.st-dest-row:hover { background: #f1f3f5; }

.st-dest-row.st-on {
    background: var(--st-ext-soft);
    border-left-color: var(--st-ext);
    color: var(--st-ext-dark);
}

.st-dest-code {
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.st-dest-rel {
    font-size: 11px;
    color: #6c757d;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-dest-row.st-on .st-dest-rel { color: var(--st-ext-dark); opacity: .75; }

/* La cuenta de pendientes de cada destino, alineada a la derecha */
.st-dest-dot {
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ffc107;
    color: #4a3800;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}


/* ==========================================================================
   El cuerpo de la pestaña, que hereda el alto del panel de conversacion
   ========================================================================== */

.st-tab-body {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.st-tab-body-comments { justify-content: stretch; }

/* ==========================================================================
   Texto largo y adjuntos del comentario
   ========================================================================== */

.st-cmt-more {
    margin-left: 6px;
    font-size: 11.5px;
    color: var(--st-ext-dark);
    white-space: nowrap;
}

.st-cmt-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* ==========================================================================
   Adjuntar desde la caja de escribir
   ========================================================================== */

.st-compose-attach {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 0 2px 0 0;
    padding: 2px;
    color: #6c757d;
    cursor: pointer;
}

.st-compose-attach input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.st-compose-files {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 0;
}

.st-compose-file {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 180px;
    padding: 2px 7px;
    border-radius: 10px;
    background: #f1f3f5;
    font-size: 11px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-compose-file-clear {
    font-size: 11px;
    color: #c0392b;
}

/* En movil el panel del detalle pasa a height:auto y el cuerpo de la pestaña se quedaria en cero */
@media (max-width: 767.98px) {
    .chat-panel-detalle .st-tab-body { min-height: 420px; }
}

/* ==========================================================================
   Recargar el panel de subtickets a mano
   ========================================================================== */

.st-panel-reload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding: 2px;
    border: none;
    border-radius: 4px;
    background: none;
    color: #adb5bd;
    cursor: pointer;
    line-height: 1;
}

.st-panel-reload:hover { background: #f1f3f5; color: var(--st-ext-dark); }
.st-panel-reload:disabled { cursor: default; }

.st-panel-reload.st-spin { animation: st-reload-spin .9s linear infinite; }

@keyframes st-reload-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .st-panel-reload.st-spin { animation: none; }
}
