/*
 * Tooltip global (webroot/js/tooltip.js). Lo cargan TODOS los layouts vía
 * templates/element/tooltip.php.
 *
 * Va colgado del <body> con position:fixed (§10.3): dentro de una tabla o un
 * modal con overflow no se recorta, y ningún hermano con transform lo tapa.
 * pointer-events:none → nunca le roba un clic a lo que está debajo.
 */
.fl-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  max-width: 260px;
  padding: 7px 11px;
  border-radius: 8px;
  background: #0d1b4b;
  color: #fff;
  font: 500 12.5px/1.45 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  letter-spacing: .1px;
  box-shadow: 0 8px 24px rgba(13, 27, 75, .22), 0 1px 3px rgba(13, 27, 75, .18);
  white-space: pre-line;
  overflow-wrap: break-word;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
}
.fl-tip.abajo { transform: translateY(-4px); }
.fl-tip.on {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity .14s ease, transform .14s ease, visibility 0s;
}
.fl-tip-t { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.fl-tip-t:empty { display: none; }
.fl-tip.ayuda { padding: 10px 13px; max-width: 280px; }

/* Flecha: un cuadro girado del mismo color, centrado en el elemento. */
.fl-tip-a {
  position: absolute;
  bottom: -4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: inherit;
  transform: rotate(45deg);
  border-radius: 1px;
}
.fl-tip.abajo .fl-tip-a { bottom: auto; top: -4px; }

/* Icono de ayuda «?» para explicar un campo: <span class="tip-help" data-tip="…"></span> */
.tip-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  font: 700 11px/1 'DM Sans', system-ui, sans-serif;
  vertical-align: middle;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
  transition: background .15s ease, transform .15s ease;
}
.tip-help::before { content: '?'; }
.tip-help:hover { background: #ea580c; transform: scale(1.08); }
.tip-help:focus-visible { outline: 2px solid #0ea5e9; outline-offset: 2px; }

/* Modo «hover» (?tips=hover): sin «?»; la etiqueta lleva un subrayado punteado tenue. */
.tips-hover .tip-help { display: none !important; }
.tips-hover .tip-ancla {
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: rgba(100, 116, 139, .55);
  text-underline-offset: 3px;
}

/* Modo oscuro: un tooltip navy sobre fondo navy se pierde. */
body.dark .fl-tip { background: #f1f5f9; color: #0d1b4b; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }

@media (prefers-reduced-motion: reduce) {
  .fl-tip, .fl-tip.on, .tip-help { transition: none; transform: none; }
}
