/* =====================================================================
   base.css — Reset ligero y estilos base compartidos por todas las vistas
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: block;
}

/* Controles base */
input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="tel"],
input[type="number"],
input:not([type]) {
  width: 100%;
  height: var(--control-h);
  padding: 0 14px;
  font-size: 14px;
  line-height: normal;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input::placeholder { color: var(--faint); }

/* Selects: flecha personalizada, misma altura y foco que inputs */
select {
  height: var(--control-h);
  padding: 0 38px 0 14px;
  font-size: 14px;
  line-height: normal;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

button { cursor: pointer; border: 0; }

/* Accesibilidad: ocultar visualmente, mantener para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Utilidad de carga */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   HISTORIAL — estados de atencion (identicos a osTicket) + gestion
   Pills de los 4 estados, celda de atencion con selector inline, barra
   de seleccion multiple e icono de ayuda. Reusan .pill (sin vineta).
   ===================================================================== */
/* Pills de estado: Abierto (ambar) / Atendido (azul) / Resuelto (teal) /
   Cerrado (verde). Sin vineta, igual que el resto de pills del historial. */
.att-open     { background: var(--warn-bg);  color: var(--warn); }
.att-attended { background: var(--brand-bg); color: #1e40af; }
.att-resolved { background: #e0f2fe;         color: #0369a1; }
.att-closed   { background: var(--success-bg); color: #15803d; }
.att-open::before, .att-attended::before,
.att-resolved::before, .att-closed::before { display: none; }

/* Celda de atencion: selector de estado + punto de sync + boton refrescar,
   todo en UNA fila; la auditoria va debajo en gris pequeno. Compacta. */
.att-cell { display: flex; flex-direction: row; align-items: center; gap: 6px; flex-wrap: nowrap; }
.att-row-sel { height: 28px; font-size: 12px; padding: 0 24px 0 9px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-soft); font-family: inherit;
  font-weight: 600; cursor: pointer; outline: none; max-width: 116px; }
.att-row-sel:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
/* Color del selector segun el estado actual (mismo codigo que los pills). */
.att-row-sel.att-open     { background: var(--warn-bg);    color: var(--warn);  border-color: #f5d99a; }
.att-row-sel.att-attended { background: var(--brand-bg);   color: #1e40af;      border-color: #c3d9fd; }
.att-row-sel.att-resolved { background: #e0f2fe;           color: #0369a1;      border-color: #bae0fb; }
.att-row-sel.att-closed   { background: var(--success-bg); color: #15803d;      border-color: #bbe7c4; }

/* Icono de ayuda "?" junto al encabezado Atencion. */
.att-help { display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700;
  color: var(--brand); background: var(--brand-bg); margin-left: 4px; cursor: help;
  vertical-align: middle; }
.att-help:hover { background: var(--brand); color: #fff; }

/* Barra de seleccion multiple (aparece al elegir filas, estilo wizard). */
.hsel-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--brand-bg); border: 1px solid #d3e2fd; border-radius: var(--radius-md);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px; color: var(--ink-soft); }
.hsel-bar b { color: var(--brand); }
.hsel-bar select { height: 32px; font-size: 12.5px; padding: 0 26px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-family: inherit; outline: none; }
.hsel-bar input { height: 32px; padding: 0 11px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-family: inherit; outline: none; }
.hsel-bar select:focus, .hsel-bar input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* Checkbox de fila/cabecera del historial. */
.tablebox .chk { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; }

/* Auditoria del cambio de estado (quien/cuando) bajo el selector. */
.att-audit { font-size: 10.5px; color: var(--faint); line-height: 1.3; margin-top: 3px; }
.att-comment { font-size: 11px; color: var(--muted); font-style: italic; line-height: 1.35; margin-top: 2px; }

/* Modal de ayuda de estados: lista legible (pill a la izquierda, texto a la
   derecha). Reusa .modal-ov/.modal-box del panel. */
.att-help-modal { max-width: 460px; }
.att-help-intro { font-size: 13px; color: var(--muted); margin: 6px 0 14px; line-height: 1.5; }
.att-help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.att-help-list li { display: grid; grid-template-columns: 92px 1fr; align-items: start; gap: 12px; }
.att-help-list li .pill { justify-self: start; }
.att-help-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

/* Punto/icono compacto de sincronizacion con osTicket (en la grilla). */
.sync-dot { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700;
  flex: 0 0 auto; cursor: default; }
.sync-dot.sd-ok   { background: var(--success-bg); color: #15803d; }
.sync-dot.sd-fail { background: var(--danger-bg);  color: #b91c1c; }
.sync-dot.sd-pend { background: var(--warn-bg);    color: var(--warn); }

/* Boton-icono generico (cuadrado pequeno, solo glifo). Usado p.ej. por el
   re-sincronizar de la celda de atencion y las acciones de la grilla. */
.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; font-size: 13px; line-height: 1;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-soft); cursor: pointer; flex: 0 0 auto;
  vertical-align: middle; }
.icon-btn + .icon-btn, .btn + .icon-btn { margin-left: 4px; }
.icon-btn:hover { background: var(--brand-bg); color: var(--brand); border-color: #bfdbfe; }
.icon-btn:disabled { opacity: .5; cursor: default; }
/* Feedback breve (sin cambiar el glifo). */
.icon-btn.is-busy { opacity: .6; }
.icon-btn.is-ok   { background: var(--success-bg); color: #15803d; border-color: #bbe7c4; }
.icon-btn.is-err  { background: var(--danger-bg);  color: #b91c1c; border-color: #f3c2c2; }
.att-syncbtn { color: var(--brand); }

/* Enlace directo al ticket en osTicket (pill con # clicable). */
a.ot-link { text-decoration: none; cursor: pointer; }
a.ot-link:hover { filter: brightness(0.95); text-decoration: underline; }

/* Banda de estado del detalle (Variante A): Atencion + osTicket en una
   franja propia arriba de la tarjeta, separada de los metadatos. */
.statusband { display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 18px; margin-bottom: 18px; }
.sb-block { display: flex; flex-direction: column; gap: 7px; }
.sb-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); font-weight: 700; }
.sb-row { display: flex; align-items: center; gap: 8px; }
.sb-audit { font-size: 11px; color: var(--faint); margin-top: 2px; line-height: 1.35; }
.sb-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

/* Modal de confirmacion / aviso (reemplazan confirm()/alert() nativos). */
.confirm-modal { max-width: 440px; }
.confirm-msg { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin: 4px 0 4px; }
.notice-error .modal-head span { color: var(--danger); }
.notice-success .modal-head span { color: var(--success); }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.95); }

/* Modal de reenvio a osTicket (opcion D): slots de documentos a re-adjuntar. */
.resend-modal { max-width: 560px; }
.rs-intro { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin: 4px 0 14px; }
.rs-error { color: var(--danger); font-size: 13px; }
.rs-ok { color: var(--brand); font-size: 13px; font-weight: 600; }
.rs-status { margin-top: 10px; min-height: 18px; }
.rs-slots { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.rs-slot { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.rs-slot-info { flex: 1; min-width: 0; }
.rs-slot-info .ced { font-size: 11px; color: var(--faint); margin-left: 4px; }
.rs-slot-doc { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.rs-slot-file { flex: 0 0 auto; }
