/* ──────────────────────────────────────────────────────────────────────
   ubiHilo (static/js/ubi-hilo.js): hilo de conversación de soporte en el
   widget, la página del ticket, el chat sin cuenta y la ficha del admin.
   Colores como variables del marco; modo oscuro con html.dark (paleta de
   STYLEGUIDE §3: sin negro puro, sin blanco puro como texto, sin glows).
   ────────────────────────────────────────────────────────────────────── */
.uh-hilo-marco {
  position: relative;
  --uhh-bg: #f8fafc;
  --uhh-otro: #ffffff;
  --uhh-otro-borde: #e2e8f0;
  --uhh-t1: #0f172a;
  --uhh-t2: #475569;
  --uhh-t3: #94a3b8;
  --uhh-mio: #0072cb;
  --uhh-mio-t: #ffffff;
  --uhh-nota: #fef9c3;
  --uhh-nota-borde: #fde68a;
  --uhh-nota-t: #713f12;
  --uhh-acento: #0072cb;
  --uhh-av: #e0f2fe;
  --uhh-av-t: #0369a1;
  --uhh-linea: #e2e8f0;
}
html.dark .uh-hilo-marco {
  --uhh-bg: #131925;
  --uhh-otro: #1e2533;
  --uhh-otro-borde: #2c3340;
  --uhh-t1: #c4cbd6;
  --uhh-t2: #b2bac8;
  --uhh-t3: #8590a1;
  --uhh-mio: #0b72c4;
  --uhh-mio-t: #ffffff;
  --uhh-nota: rgba(234, 179, 8, .13);
  --uhh-nota-borde: rgba(234, 179, 8, .34);
  --uhh-nota-t: #fde68a;
  --uhh-acento: #7cc5fd;
  --uhh-av: #1c2941;
  --uhh-av-t: #7cc5fd;
  --uhh-linea: #2c3340;
}

.uh-hilo-scroll {
  overflow-y: auto; overscroll-behavior: contain; background: var(--uhh-bg);
  overflow-wrap: anywhere; min-width: 0;
}
.uh-hilo { display: flex; flex-direction: column; padding: 12px 14px 6px; min-width: 0; }
.uh-hilo-vacio { margin: 0; padding: 32px 0; text-align: center; color: var(--uhh-t3); font-size: 13px; }

/* ── Mensajes ─────────────────────────────────────────────────────── */
.uh-m { display: flex; gap: 8px; margin-top: 14px; min-width: 0; max-width: 100%; }
.uh-m--seguido { margin-top: 3px; }
.uh-m--mio { justify-content: flex-end; }
.uh-m-av {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 999px; margin-top: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
  background: var(--uhh-av); color: var(--uhh-av-t);
}
.uh-m--user .uh-m-av { background: rgba(20, 184, 166, .14); color: #0f766e; }
html.dark .uh-m--user .uh-m-av { background: rgba(45, 212, 191, .14); color: #5eead4; }
.uh-m--seguido .uh-m-av { visibility: hidden; height: 1px; margin-top: 0; }
/* Con foto de perfil: la imagen tapa las iniciales */
.uh-m-av { position: relative; overflow: hidden; }
.uh-m-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.uh-m-col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(78%, 600px); }
.uh-m--mio .uh-m-col { align-items: flex-end; }
.uh-m-cab {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 6px 3px;
  font-size: 11px; font-weight: 700; color: var(--uhh-t2); line-height: 1.3; min-width: 0;
}
.uh-m--seguido .uh-m-cab { display: none; }
.uh-m-nom { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.uh-m-bur {
  position: relative; max-width: 100%; min-width: 0; box-sizing: border-box;
  padding: 8px 12px; border-radius: 16px; border-bottom-left-radius: 6px;
  background: var(--uhh-otro); color: var(--uhh-t1); border: 1px solid var(--uhh-otro-borde);
  font-size: 13.5px; line-height: 1.5; box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  transition: opacity .2s, box-shadow .2s;
}
.uh-m--seguido:not(.uh-m--mio) .uh-m-bur { border-top-left-radius: 6px; }
.uh-m--mio .uh-m-bur {
  background: var(--uhh-mio); color: var(--uhh-mio-t); border-color: transparent;
  border-radius: 16px; border-bottom-right-radius: 6px;
}
.uh-m--mio.uh-m--seguido .uh-m-bur { border-top-right-radius: 6px; }
.uh-m-txt { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.uh-m-link { color: var(--uhh-acento); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.uh-m--mio .uh-m-link { color: inherit; }
.uh-m-bur .ubi-att-grid { margin-top: 6px; }
.uh-m-txt + .ubi-att-grid { margin-top: 8px; }
.uh-m-bur > .ubi-att-grid:first-child { margin-top: 0; }

/* Nota interna (solo equipo): amarilla y con etiqueta */
.uh-m--note .uh-m-bur { background: var(--uhh-nota); color: var(--uhh-nota-t); border: 1px solid var(--uhh-nota-borde); border-bottom-right-radius: 6px; }
.uh-m--note .uh-m-link { color: inherit; }
.uh-m-etq {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  background: #fde68a; color: #713f12; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
html.dark .uh-m-etq { background: rgba(234, 179, 8, .22); color: #fde68a; }
.uh-m-ed { font-weight: 500; font-style: italic; color: var(--uhh-t3); }
.uh-m-acc { display: inline-flex; gap: 2px; }
.uh-m-accb {
  border: 0; background: none; padding: 2px 6px; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--uhh-t3);
}
.uh-m-accb:hover { color: var(--uhh-acento); background: rgba(55, 169, 251, .1); }
.uh-m-accb--peligro:hover { color: #dc2626; background: rgba(220, 38, 38, .08); }
.uh-m-edit { width: 100%; min-width: 220px; box-sizing: border-box; border: 1px solid var(--uhh-nota-borde); border-radius: 8px;
  padding: 6px 8px; font: inherit; color: inherit; background: rgba(255, 255, 255, .5); resize: vertical; }
html.dark .uh-m-edit { background: rgba(15, 20, 31, .4); }
.uh-m-edit-acc { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* Pie: hora (solo en el último del grupo) y estado de envío */
.uh-m-pie { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 3px 6px 0; font-size: 10.5px; color: var(--uhh-t3); line-height: 1.3; }
.uh-m--sigue .uh-m-h { display: none; }
.uh-m--sigue .uh-m-pie:has(.uh-m-est:empty) { display: none; }
.uh-m-est:empty { display: none; }
.uh-m-est[data-e=visto] { color: var(--uhh-acento); font-weight: 600; }
.uh-m-est[data-e=error] { color: #dc2626; font-weight: 600; }
html.dark .uh-m-est[data-e=error] { color: #fca5a5; }
.uh-m-retry {
  border: 0; background: none; padding: 2px 4px; margin: -2px 0; cursor: pointer; border-radius: 6px;
  font: inherit; font-size: 11px; font-weight: 700; color: var(--uhh-acento); text-decoration: underline; text-underline-offset: 2px;
}
.uh-m-retry:hover { background: rgba(55, 169, 251, .1); }
.uh-m--enviando .uh-m-bur { opacity: .62; }
.uh-m--error .uh-m-bur { opacity: .8; box-shadow: 0 0 0 2px rgba(220, 38, 38, .45); }

/* ── Avisos del sistema, días y «Nuevos» ──────────────────────────── */
.uh-ev {
  align-self: center; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px;
  max-width: 92%; margin: 12px auto 2px; text-align: center; font-size: 11.5px; line-height: 1.4; color: var(--uhh-t3);
}
.uh-ev-txt { color: var(--uhh-t2); }
.uh-ev-h { font-variant-numeric: tabular-nums; }
.uh-dia, .uh-nuevos {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 2px;
  font-size: 11px; font-weight: 700; color: var(--uhh-t3); letter-spacing: .02em;
}
.uh-dia::before, .uh-dia::after, .uh-nuevos::before, .uh-nuevos::after { content: ""; flex: 1; height: 1px; background: var(--uhh-linea); }
.uh-hilo > .uh-dia:first-child { margin-top: 4px; }
.uh-nuevos { color: #e11d48; margin: 14px 0 0; }
.uh-nuevos::before, .uh-nuevos::after { background: rgba(225, 29, 72, .35); }
html.dark .uh-nuevos { color: #fda4af; }
.uh-nuevos + .uh-m, .uh-dia + .uh-m { margin-top: 8px; }

/* Entrada de un mensaje nuevo */
.uh-in { animation: uh-in .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes uh-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── «Escribiendo…» ───────────────────────────────────────────────── */
.uh-escr { display: flex; align-items: center; gap: 8px; padding: 2px 16px 10px 52px; font-size: 12px; color: var(--uhh-t2); animation: uh-in .2s ease-out; }
.uh-escr[hidden] { display: none; }
.uh-escr-pts { display: inline-flex; gap: 3px; padding: 7px 9px; border-radius: 999px; background: var(--uhh-otro); border: 1px solid var(--uhh-otro-borde); }
.uh-escr-pts i { width: 5px; height: 5px; border-radius: 999px; background: var(--uhh-t3); animation: uh-pt 1.2s infinite ease-in-out; }
.uh-escr-pts i:nth-child(2) { animation-delay: .15s; }
.uh-escr-pts i:nth-child(3) { animation-delay: .3s; }
@keyframes uh-pt { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

.uh-hilo-final { padding: 0 14px; }
.uh-hilo-final:not(:empty) { padding-bottom: 14px; }

/* ── Píldora «N mensajes nuevos ↓» ────────────────────────────────── */
.uh-pill {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; min-height: 32px;
  border: 0; border-radius: 999px; background: #0072cb; color: #fff; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 700; line-height: 1; box-shadow: 0 8px 22px -8px rgba(15, 23, 42, .45);
  animation: uh-pill .22s cubic-bezier(.16, 1, .3, 1);
}
.uh-pill[hidden] { display: none; }
.uh-pill svg { width: 13px; height: 13px; }
.uh-pill:hover { background: #005fab; }
.uh-pill:active { transform: translateX(-50%) scale(.97); }
@keyframes uh-pill { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translateX(-50%); } }

/* ── Soltar imágenes ──────────────────────────────────────────────── */
.uh-soltar-zona { position: relative; }
.uh-soltar {
  position: absolute; inset: 6px; z-index: 7; display: flex; align-items: center; justify-content: center;
  border: 2px dashed #37a9fb; border-radius: 14px; background: rgba(55, 169, 251, .1);
  color: #0072cb; font-size: 13px; font-weight: 700; pointer-events: none; animation: uh-in .15s ease-out;
}
.uh-soltar[hidden] { display: none; }
html.dark .uh-soltar { color: #7cc5fd; background: rgba(55, 169, 251, .12); }

/* Caja de texto que crece sola (hasta ~6 líneas) */
.uh-compo-ta { resize: none !important; overflow-y: hidden; line-height: 1.45; min-height: 0; box-sizing: border-box; }

/* ── Estado del ticket (chip de color) ────────────────────────────── */
.uh-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; line-height: 1.6; white-space: nowrap; letter-spacing: .01em;
}
.uh-chip::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85; }
.uh-chip--open { background: #fef3c7; color: #92400e; }
.uh-chip--in_progress { background: #dbeafe; color: #1e40af; }
.uh-chip--resolved { background: #dcfce7; color: #15803d; }
.uh-chip--closed { background: #e2e8f0; color: #475569; }
html.dark .uh-chip--open { background: rgba(245, 158, 11, .15); color: #fcd34d; }
html.dark .uh-chip--in_progress { background: rgba(59, 130, 246, .16); color: #93c5fd; }
html.dark .uh-chip--resolved { background: rgba(34, 197, 94, .15); color: #86efac; }
html.dark .uh-chip--closed { background: rgba(148, 163, 184, .15); color: #b2bac8; }

/* ── Tarjeta del final: «¿Se ha solucionado?» y valoración ────────── */
.uh-fin {
  margin-top: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid #bbf7d0; background: #f0fdf4;
  color: var(--uhh-t1); animation: uh-in .25s cubic-bezier(.16, 1, .3, 1);
}
.uh-fin--neutro { border-color: var(--uhh-otro-borde); background: var(--uhh-otro); }
html.dark .uh-fin { background: rgba(34, 197, 94, .08); border-color: rgba(34, 197, 94, .28); }
html.dark .uh-fin--neutro { background: var(--uhh-otro); border-color: var(--uhh-otro-borde); }
.uh-fin-tit { margin: 0 0 4px; font-size: 14px; font-weight: 800; color: var(--uhh-t1); }
.uh-fin-txt { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--uhh-t2); }
.uh-fin-acc { display: flex; flex-wrap: wrap; gap: 8px; }
.uh-fin-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid #059669; background: #10b981; color: #fff; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 700; transition: background-color .15s, transform .1s;
}
.uh-fin-btn:hover { background: #059669; }
.uh-fin-btn:active { transform: scale(.97); }
.uh-fin-btn--2 { background: transparent; color: #be123c; border-color: #fecdd3; }
.uh-fin-btn--2:hover { background: #fff1f2; }
.uh-fin-btn--3 { background: transparent; color: var(--uhh-t2); border-color: var(--uhh-otro-borde); }
.uh-fin-btn--3:hover { background: rgba(148, 163, 184, .12); }
.uh-fin-btn[disabled] { opacity: .6; cursor: default; }
html.dark .uh-fin-btn--2 { color: #fda4af; border-color: rgba(244, 63, 94, .35); }
html.dark .uh-fin-btn--2:hover { background: rgba(244, 63, 94, .1); }
.uh-fin-nota { margin: 10px 0 0; font-size: 11.5px; color: var(--uhh-t3); }
.uh-estrellas { display: flex; gap: 4px; margin: 2px 0 10px; }
.uh-estrella {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer;
  color: #cbd5e1; display: inline-flex; align-items: center; justify-content: center; transition: transform .12s;
}
.uh-estrella svg { width: 28px; height: 28px; }
.uh-estrella.on { color: #f59e0b; }
.uh-estrella:hover { transform: scale(1.08); }
.uh-estrella:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(55, 169, 251, .3); }
html.dark .uh-estrella { color: #3a4352; }
html.dark .uh-estrella.on { color: #fbbf24; }
.uh-fin-com {
  display: block; width: 100%; box-sizing: border-box; min-height: 60px; margin: 0 0 10px; padding: 8px 10px;
  border: 1px solid var(--uhh-otro-borde); border-radius: 10px; background: var(--uhh-otro); color: var(--uhh-t1);
  font: inherit; font-size: 13px; line-height: 1.45; resize: vertical;
}
.uh-fin-com:focus { outline: none; border-color: #37a9fb; box-shadow: 0 0 0 3px rgba(55, 169, 251, .14); }

@media (prefers-reduced-motion: reduce) {
  .uh-in, .uh-escr, .uh-pill, .uh-fin, .uh-soltar { animation: none; }
  .uh-escr-pts i { animation: none; opacity: .8; }
}
/* Zonas táctiles de 40 px sin que crezca la fila (STYLEGUIDE §5 bis) */
@media (max-width: 1023px) {
  .uh-m-accb { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; margin: -12px 0; box-sizing: border-box; }
  .uh-m-retry { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; margin: -14px 0; box-sizing: border-box; }
}
@media (max-width: 480px) {
  .uh-m-col { max-width: 86%; }
  .uh-hilo { padding: 10px 10px 6px; }
}

/* ── oscuro: botones azules (generado) ── */
html.dark .uh-pill { background:#006bc0; color:#eef2f7; }
/* ── fin oscuro: botones azules ── */
