/*
 * Tickets del area de clientes (tickets, PR 5 de 5): listado (mistickets.php), ticket con su hilo de
 * mensajes (misticketseditardetalle.php) y ticket nuevo (misticketseditar.php). Se carga solo en esas
 * paginas (cargarjscss.php). Colores y tipografia de digival2025.css; los tonos oscuros de cada color son
 * para que el texto tenga contraste suficiente (WCAG AA). Todas las clases empiezan por "tk-".
 * Archivo en ASCII puro.
 */

.tk-pagina {
  color: #333;
}

.tk-oculto {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tk-icono {
  flex: none;
  vertical-align: middle;
}

/* Botones */
.tk-boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color .2s, border-color .2s, color .2s;
}
.tk-boton-principal {
  background: #ffcc00;
  border-color: #f0bd00;
  color: #1f3b52;
}
.tk-boton-principal:hover,
.tk-boton-principal:focus {
  background: #f2b900;
  color: #1f3b52;
}
.tk-boton-sec {
  background: #fff;
  border-color: #b5c8d8;
  color: #2b5f8a;
}
.tk-boton-sec:hover,
.tk-boton-sec:focus {
  background: #eef5fb;
  border-color: #67a0ce;
  color: #1f3b52;
}
.tk-pagina a:focus-visible,
.tk-pagina button:focus-visible,
.tk-pagina summary:focus-visible,
.tk-pagina .tk-control:focus,
.tk-adjuntar-input:focus-visible + .tk-adjuntar-boton {
  outline: 3px solid #2b5f8a;
  outline-offset: 2px;
}

/* Estado del ticket */
.tk-estado {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.tk-estado-pendiente { background: #fff1dc; border-color: #f2c98c; color: #8a4600; }
.tk-estado-asignado  { background: #e6f0f9; border-color: #a9c8e3; color: #245a85; }
.tk-estado-abierto   { background: #ebf5df; border-color: #b6d895; color: #3a6614; }
.tk-estado-resuelto  { background: #f0ebfc; border-color: #c9bbf0; color: #5b3fa8; }
.tk-estado-cerrado   { background: #fbe6e2; border-color: #eab5aa; color: #9c2f1b; }
.tk-estado-otro      { background: #f0f0f0; border-color: #cccccc; color: #444444; }

/* Avisos de la pagina (los de siempre: <p class="centro rojo">) */
.tk-pagina p.centro.rojo {
  padding: 10px 14px;
  margin: 0 0 16px;
  border: 1px solid #eab5aa;
  border-radius: 8px;
  background: #fbe6e2;
  color: #9c2f1b;
  text-align: left;
}
.tk-vacio {
  padding: 24px 12px;
  text-align: center !important;
  color: #56636e;
}

/* Cajas */
.tk-caja {
  background: #fff;
  border: 1px solid #d5e1eb;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(31, 59, 82, .06);
  box-sizing: border-box;
  min-width: 0;
}
.tk-subtitulo {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  color: #1f3b52;
}

/* ---------------- Listado ---------------- */
.tk-lista-cabecera {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.tk-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tk-filtro {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid #b5c8d8;
  border-radius: 999px;
  background: #fff;
  color: #2b5f8a;
  text-decoration: none;
}
.tk-filtro:hover {
  background: #eef5fb;
  color: #1f3b52;
}
.tk-filtro.tk-filtro-activo,
.tk-filtro.tk-filtro-activo:hover {
  background: #2b5f8a;
  border-color: #2b5f8a;
  color: #fff;
}
.tk-lista {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #d5e1eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.tk-lista th {
  padding: 10px 12px;
  background: #eef5fb;
  border-bottom: 2px solid #67a0ce;
  color: #1f3b52;
  font-weight: 700;
  text-align: left;
}
.tk-lista td {
  padding: 12px;
  border-bottom: 1px solid #e3ebf2;
  vertical-align: middle;
}
.tk-lista tbody tr:last-child td {
  border-bottom: 0;
}
.tk-lista tr.tk-fila-respondido td {
  background: #fff8e1;
}
.tk-lista tr.tk-fila-respondido td:first-child {
  box-shadow: inset 4px 0 0 #ffcc00;
}
.tk-l-ref {
  white-space: nowrap;
  font-size: 14px;
  color: #56636e;
}
.tk-l-asunto {
  overflow-wrap: anywhere;
}
.tk-l-asunto a {
  color: #1f3b52;
  font-weight: 700;
  text-decoration: none;
}
.tk-l-asunto a:hover {
  color: #2b5f8a;
  text-decoration: underline;
}
.tk-l-ultimo {
  white-space: nowrap;
}
.tk-l-ultimo time {
  color: #333;
}
.tk-quien {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: #56636e;
}
.tk-quien.tk-quien-soporte {
  display: table;
  white-space: nowrap;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #ffcc00;
  color: #1f3b52;
  font-weight: 700;
}
.tk-l-ver {
  text-align: right;
}

/* ---------------- Ticket ---------------- */
.tk-cabecera {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.tk-cabecera-texto {
  flex: 1;
  min-width: 0;
}
.tk-volver {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #d5e1eb;
  color: #1f3b52;
  box-shadow: 0 1px 3px rgba(31, 59, 82, .08);
}
.tk-volver:hover {
  background: #eef5fb;
  color: #2b5f8a;
}
.tk-pagina h2.tk-titulo {
  margin: 4px 0 6px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f3b52;
  overflow-wrap: anywhere;
}
.tk-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 0 !important;
  color: #56636e;
  text-align: left;
}
.tk-meta strong {
  color: #333;
}

.tk-ficha {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "hilo" "lateral" "responder";
  gap: 20px;
  align-items: start;
}
.tk-hilo { grid-area: hilo; padding: 0; }
.tk-responder { grid-area: responder; }
.tk-lateral { grid-area: lateral; }

.tk-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid #d5e1eb;
}
.tk-abierto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #56636e;
}
.tk-barra-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Mensajes: <details>, desplegados sin JavaScript; tickets.js pliega todos menos el ultimo */
.tk-msg {
  border-bottom: 1px solid #e3ebf2;
}
.tk-msg:last-child {
  border-bottom: 0;
  border-radius: 0 0 10px 10px;
}
.tk-msg-cliente { background: #fff; }
.tk-msg-soporte { background: #fff8e1; }
.tk-msg-cab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  list-style: none;
}
.tk-msg-cab::-webkit-details-marker {
  display: none;
}
.tk-msg-cab::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 4px 4px 2px;
  border-right: 2px solid #56636e;
  border-bottom: 2px solid #56636e;
  transform: rotate(45deg);
  transition: transform .2s;
}
.tk-msg[open] > .tk-msg-cab::after {
  margin-bottom: -4px;
  transform: rotate(-135deg);
}
.tk-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
}
.tk-msg-cliente .tk-avatar { background: #2b5f8a; color: #fff; }
.tk-msg-soporte .tk-avatar { background: #ffcc00; color: #1f3b52; box-shadow: inset 0 0 0 1px #e6b800; }
.tk-msg-quien {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.tk-msg-autor {
  flex: none;
  color: #1f3b52;
}
.tk-msg-resumen {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #56636e;
}
.tk-msg[open] .tk-msg-resumen {
  display: none;
}
.tk-msg-fecha {
  flex: none;
  font-size: 14px;
  color: #56636e;
  white-space: nowrap;
}
.tk-msg-cuerpo {
  padding: 0 20px 18px 72px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.tk-msg-cuerpo p {
  margin: 0 0 10px;
  text-align: left;
}
.tk-msg-cuerpo ul,
.tk-msg-cuerpo ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.tk-msg-cuerpo ul { list-style: disc; }
.tk-msg-cuerpo ol { list-style: decimal; }
.tk-msg-cuerpo li { margin-bottom: 4px; }
.tk-msg-cuerpo a {
  color: #2b5f8a;
  text-decoration: underline;
}

/* Responder y ticket nuevo */
.tk-aviso-estado {
  padding: 10px 14px;
  margin: 0 0 14px !important;
  border: 1px solid #f2c98c;
  border-radius: 8px;
  background: #fff1dc;
  color: #7a3e00;
  text-align: left !important;
}
.tk-form .tk-control {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid #b5c8d8;
  border-radius: 8px;
  background: #fff;
  color: #333;
  font: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}
.tk-form textarea.tk-control {
  min-height: 150px;
  resize: vertical;
}
.tk-form .tk-control::placeholder {
  color: #6b7780;
  opacity: 1;
}
.tk-campo {
  margin-bottom: 16px;
}
.tk-campo label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  color: #1f3b52;
}
.tk-obligatorio {
  color: #9c2f1b;
}
.tk-form-pie {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.tk-form-acciones {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.tk-ayuda {
  display: block;
  margin: 6px 0 0;
  font-size: 14px;
  color: #56636e;
  text-align: left;
}
.tk-nuevo .tk-cabecera {
  align-items: center;
}

/* Adjuntar imagenes: sin JavaScript, el input normal del navegador; con JavaScript, el boton */
.tk-adjuntar {
  position: relative;
  min-width: 0;
  max-width: 100%;
}
.tk-adjuntar-input {
  max-width: 100%;
  font: inherit;
}
.tk-adjuntar-input::file-selector-button {
  margin-right: 10px;
  padding: 7px 14px;
  border: 1px solid #b5c8d8;
  border-radius: 6px;
  background: #fff;
  color: #2b5f8a;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.tk-adjuntar-boton {
  display: none;
}
.tk-js .tk-adjuntar-boton {
  display: inline-flex;
}
.tk-js .tk-adjuntar-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.tk-adjuntar-boton::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.5 6.5v10a4.5 4.5 0 0 1-9 0V5a3 3 0 0 1 6 0v10.5a1.5 1.5 0 0 1-3 0V6.5' fill='none' stroke='%232b5f8a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
.tk-adjuntar-nombres {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: #1f3b52;
  overflow-wrap: anywhere;
}
.tk-adjuntar-nombres:empty {
  display: none;
}
.tk-adjuntar p.rojo {
  margin: 6px 0 0;
  color: #9c2f1b;
  text-align: left;
}

/* Datos de la consulta */
.tk-datos {
  margin: 0;
}
.tk-datos > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid #e3ebf2;
}
.tk-datos dt {
  color: #56636e;
}
.tk-datos dd {
  margin: 0;
  font-weight: 700;
  color: #1f3b52;
  text-align: right;
  overflow-wrap: anywhere;
}
.tk-volver-pie {
  margin: 20px 0 0 !important;
  text-align: left;
}

/* Escritorio: panel lateral a la derecha del hilo y del formulario */
@media (min-width: 990px) {
  .tk-ficha {
    grid-template-columns: minmax(0, 1fr) 250px;
    grid-template-areas: "hilo lateral" "responder lateral";
  }
  .tk-lateral {
    position: sticky;
    top: 16px;
  }
}

/* Movil */
@media (max-width: 767px) {
  .tk-caja {
    padding: 16px 14px;
  }
  .tk-hilo {
    padding: 0;
  }
  .tk-pagina h2.tk-titulo {
    font-size: 22px;
  }
  .tk-barra {
    padding: 12px 14px;
  }
  .tk-barra-acciones,
  .tk-barra-acciones .tk-boton {
    flex: 1 1 auto;
  }
  .tk-msg-cab {
    gap: 10px;
    padding: 12px 14px;
  }
  .tk-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .tk-msg-quien {
    flex-direction: column;
    gap: 0;
  }
  .tk-msg-resumen {
    width: 100%;
  }
  .tk-msg-cuerpo {
    padding: 0 14px 16px;
  }
  .tk-form-pie .tk-enviar,
  .tk-form-acciones .tk-boton {
    flex: 1 1 auto;
  }

  /* Listado en tarjetas */
  .tk-lista,
  .tk-lista tbody {
    display: block;
    border: 0;
    background: none;
  }
  .tk-lista thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .tk-lista tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid #d5e1eb;
    border-radius: 10px;
    background: #fff;
  }
  .tk-lista tr.tk-fila-respondido {
    background: #fff8e1;
    box-shadow: inset 4px 0 0 #ffcc00;
  }
  .tk-lista td,
  .tk-lista tr.tk-fila-respondido td,
  .tk-lista tr.tk-fila-respondido td:first-child {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .tk-l-ref { grid-column: 1 / -1; grid-row: 1; align-self: center; justify-self: start; }
  .tk-l-estado { grid-column: 1 / -1; grid-row: 1; justify-self: end; }
  .tk-l-asunto { grid-column: 1 / -1; }
  .tk-l-ultimo { grid-column: 1; align-self: center; white-space: normal; }
  .tk-l-ver { grid-column: 2; align-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  .tk-boton,
  .tk-msg-cab::after {
    transition: none;
  }
}
