/* ---------------------------------------------------------------
   Portal de Soporte TI — Sawa
   Paleta fría y sobria: quien reporta un problema no necesita ruido.
   --------------------------------------------------------------- */

:root {
  --canvas: #e6eaee;
  --surface: #ffffff;
  --ink: #131c26;
  --ink-soft: #55636f;
  --ink-faint: #7d8993;
  --line: #d2d9df;
  --line-strong: #a7b3bd;
  --signal: #14624f;
  --signal-deep: #0e4a3b;
  --signal-tint: #e4efeb;
  --danger: #9e1f16;
  --danger-tint: #fbebe9;
  --warn: #8a5a00;
  --warn-tint: #fdf3e0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(19, 28, 38, 0.06),
    0 10px 30px -22px rgba(19, 28, 38, 0.4);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

a {
  color: var(--signal-deep);
}

/* --- Barra superior ------------------------------------------------ */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  display: block;
  height: 1.625rem;
  width: auto;
}

.session {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  min-width: 0;
}

.session-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

/* --- Estructura de página ------------------------------------------ */

.shell {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 1.25rem;
}

.back-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.page-title {
  font-size: 1.875rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 650;
  margin: 0 0 0.5rem;
}

.page-lede {
  margin: 0 0 2rem;
  color: var(--ink-soft);
  max-width: 34rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.hidden {
  display: none !important;
}

/* --- Menú ---------------------------------------------------------- */

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
}

.menu-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
}

.menu-tile:hover {
  border-color: var(--signal);
}

.menu-tile h2 {
  margin: 0.75rem 0 0.375rem;
  font-size: 1.0625rem;
}

.menu-tile p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.menu-tile svg {
  color: var(--signal);
}

/* --- Campos -------------------------------------------------------- */

.field + .field {
  margin-top: 1.5rem;
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.field-hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.input,
.textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
}

.textarea {
  min-height: 11rem;
  resize: vertical;
  line-height: 1.55;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
}

.input:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: -1px;
  border-color: var(--signal);
}

.input:disabled,
.textarea:disabled {
  background: #f5f7f8;
  color: var(--ink-soft);
}

.counter {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* --- Continuacion de un ticket anterior ------------------------------- */

.origin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--signal-tint);
  border: 1px solid var(--signal);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--signal-deep);
}

.detail-origin {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* --- Lista desplegable ----------------------------------------------- */

.select {
  /* appearance: none quita la flecha nativa; la dibujamos nosotros para que
     el campo se vea igual que los inputs de texto en todos los navegadores. */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2355636f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.select:disabled {
  cursor: default;
}

/* --- Zona de adjuntos ---------------------------------------------- */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 1.75rem 1rem;
  text-align: center;
  background: none;
  width: 100%;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}

.dropzone:hover:not(:disabled),
.dropzone.dragging {
  border-color: var(--signal);
  background: var(--signal-tint);
  color: var(--signal-deep);
}

.dropzone:disabled {
  cursor: default;
  opacity: 0.6;
}

.dropzone strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.dropzone.dragging strong {
  color: var(--signal-deep);
}

.dropzone small {
  font-size: 0.8125rem;
}

.thumbs {
  list-style: none;
  margin: 0.875rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.75rem;
}

.thumbs:empty {
  display: none;
}

.thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f2f4f6;
}

.thumb img,
.thumb video {
  display: block;
  width: 100%;
  height: 4.5rem;
  object-fit: cover;
  background: #131c26;
}

/* Los documentos no tienen vista previa: mostramos la extension. */
.thumb-file {
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef1f3;
  border-bottom: 1px solid var(--line);
}

.thumb-file span {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.thumb-meta {
  padding: 0.375rem 0.5rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.thumb-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.thumb-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  border-radius: 50%;
  background: rgba(19, 28, 38, 0.78);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.thumb-remove:hover {
  background: var(--danger);
}

/* --- Acciones y estado --------------------------------------------- */

.actions {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.actions p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.625rem 1.25rem;
  min-height: 2.75rem;
  cursor: pointer;
  background: var(--signal);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button:hover:not(:disabled) {
  background: var(--signal-deep);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.button-quiet {
  background: none;
  color: var(--ink-soft);
  border-color: var(--line-strong);
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  min-height: 2rem;
  font-size: 0.8125rem;
}

.button-quiet:hover:not(:disabled) {
  background: #f2f4f6;
  color: var(--ink);
}

/* Salir: rojo discreto. Es una accion destructiva menor, no una alarma. */
.button-danger {
  background: none;
  color: var(--danger);
  border-color: #dcaaa5;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  min-height: 2rem;
  font-size: 0.8125rem;
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-tint);
  border-color: var(--danger);
}

.progress {
  margin-top: 1rem;
}

.progress-track {
  height: 0.375rem;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--signal);
  transition: width 0.2s linear;
}

.progress p {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.notice {
  margin-top: 1.25rem;
  border-left: 3px solid var(--danger);
  background: var(--danger-tint);
  padding: 0.75rem 0.875rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9375rem;
}

.empty {
  color: var(--ink-soft);
  text-align: center;
  padding: 2.5rem 1rem;
}

.empty p {
  margin: 0 0 1rem;
}

/* --- Confirmación -------------------------------------------------- */

.done-number {
  font-family: var(--mono);
  font-size: clamp(2.75rem, 12vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--signal);
  margin: 0 0 0.75rem;
  font-weight: 500;
}

.done h2 {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

.done p {
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
  max-width: 32rem;
}

.done-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --- Lista de tickets ---------------------------------------------- */

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ticket-list li + li {
  border-top: 1px solid var(--line);
}

.ticket-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.ticket-row:hover .ticket-subject {
  text-decoration: underline;
}

.ticket-id {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-faint);
  flex: 0 0 4.5rem;
}

.ticket-main {
  flex: 1 1 auto;
  min-width: 0;
}

.ticket-subject {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-date {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.badge {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge.is-open {
  background: var(--signal-tint);
  border-color: var(--signal);
  color: var(--signal-deep);
}

.badge.is-waiting {
  background: var(--warn-tint);
  border-color: #d8b877;
  color: var(--warn);
}

.badge.is-closed {
  background: #f2f4f6;
}

/* --- Detalle del ticket -------------------------------------------- */

.card .empty {
  padding: 1.25rem 0;
  text-align: left;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

.detail-head h2 {
  margin: 0.25rem 0 0.25rem;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.detail-number {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.detail-date {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

/* Tarjetas apiladas: ticket, conversacion y respuesta. */
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-heading {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--ink-soft);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.thread {
  list-style: none;
  margin: 0;
  padding: 0;
}

.thread li {
  /* El borde codifica quien habla: verde el agente, gris el empleado. */
  border-left: 3px solid var(--line-strong);
  padding-left: 0.875rem;
}

.thread li.is-agent {
  border-left-color: var(--signal);
}

.thread li + li {
  margin-top: 1.25rem;
}

.reply-textarea {
  min-height: 7rem;
}

.reply-dropzone {
  margin-top: 0.875rem;
  padding: 1.25rem 1rem;
}

.reply-textarea + .notice {
  margin-top: 0.75rem;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
}

.comment-author {
  font-weight: 600;
  color: var(--ink);
}

.comment-time {
  color: var(--ink-faint);
  white-space: nowrap;
}

.comment-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-files {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.spinner {
  color: var(--ink-soft);
  text-align: center;
  padding: 2rem 1rem;
}

/* --- Ingreso ------------------------------------------------------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
  width: 100%;
  max-width: 25rem;
  /* Sin esto, un contenido ancho (el logo) fuerza la tarjeta a crecer
     mas alla de la pantalla: los items de grid no se encogen solos. */
  min-width: 0;
  text-align: center;
}

.gate-logo {
  display: block;
  height: 4.5rem;
  width: auto;
  /* Tope duro: el logo se adapta al ancho disponible en vez de desbordarlo. */
  max-width: 100%;
  margin: 0 auto 1.5rem;
}

.gate-card h1 {
  font-size: 1.375rem;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}

/* Los mensajes de error se leen mejor alineados a la izquierda, aunque
   el resto de la tarjeta este centrado. */
.gate-card .notice {
  text-align: left;
}

.gate-card > p {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  margin: 0 0 1.5rem;
}

.gate-foot {
  margin: 1.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

#google-button {
  display: flex;
  justify-content: center;
  min-height: 2.75rem;
}

/* --- Incrustacion de paneles ---------------------------------------- */

.callout {
  margin-bottom: 1.25rem;
  padding: 0.875rem 1rem;
  background: var(--warn-tint);
  border: 1px solid #e8cf9c;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--ink);
}

.callout strong {
  display: block;
  margin-bottom: 0.125rem;
}

.callout a {
  color: var(--warn);
  font-weight: 600;
}

.denied p {
  margin: 0 0 1rem;
  color: var(--ink-soft);
}

.input-short {
  max-width: 12rem;
}

.input-mono {
  font-family: var(--mono);
  font-size: 0.875rem;
}

.field-hint code {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

/* Lista desplegable con buscador: input + flecha + lista con scroll. */
.combo {
  position: relative;
}

.combo-input {
  padding-right: 2.75rem;
}

.combo-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.combo-toggle:hover:not(:disabled) {
  color: var(--ink);
  background: #f2f4f6;
}

.combo-toggle:disabled {
  cursor: default;
  opacity: 0.5;
}

.combo-toggle svg {
  transition: transform 0.15s ease;
}

.combo.is-open .combo-toggle svg {
  transform: rotate(180deg);
}

.combo-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px -12px rgba(19, 28, 38, 0.35);
}

.combo-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.625rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9375rem;
}

.combo-option.is-active,
.combo-option:hover:not(.is-disabled) {
  background: var(--signal-tint);
}

.combo-option.is-selected .combo-name {
  font-weight: 600;
  color: var(--signal-deep);
}

.combo-option.is-disabled {
  cursor: default;
  color: var(--ink-faint);
}

.combo-code {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

.combo-empty {
  padding: 0.75rem 0.625rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--signal-tint);
  border: 1px solid var(--signal);
  border-radius: var(--radius-sm);
}

.result.is-existing {
  background: var(--warn-tint);
  border-color: var(--warn);
}

.result-status {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}

.copy-row .input {
  min-width: 0;
  flex: 1;
}

.copy-row .button {
  min-height: auto;
  flex-shrink: 0;
}

.result-meta {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (max-width: 30rem) {
  .card {
    padding: 1.25rem;
  }
  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .actions .button {
    width: 100%;
  }
  .session-name {
    max-width: 8rem;
  }
  .gate {
    padding: 1rem;
  }
  .gate-card {
    padding: 1.5rem;
  }
  .gate-logo {
    height: 3.25rem;
    margin-bottom: 1.25rem;
  }
  .ticket-id {
    display: none;
  }
  .detail-head {
    flex-direction: column;
  }
}