/**
 * =============================================================================
 * Menú de accesibilidad — estilos (diseño card moderno)
 * =============================================================================
 * Branding: --a11y-brand viene de configuration_general.color_barra (Intraweb).
 * Fallback: #3b82f6 (azul del mockup).
 * =============================================================================
 */

/* -----------------------------------------------------------------------------
 * Tokens
 * -------------------------------------------------------------------------- */
:root {
  --a11y-brand: #3b82f6;
  --a11y-brand-soft: color-mix(in srgb, var(--a11y-brand) 14%, white);
  --a11y-text: #1e293b;
  --a11y-muted: #94a3b8;
  --a11y-surface: #ffffff;
  --a11y-tile: #f1f5f9;
  --a11y-tile-icon: #e2e8f0;
  --a11y-border: #e2e8f0;
  --a11y-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  --a11y-radius: 18px;
  --a11y-fab-size: 56px;
  --a11y-z: 99990;
}

/* -----------------------------------------------------------------------------
 * Contenedor raíz
 * -------------------------------------------------------------------------- */
.a11y-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--a11y-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: var(--a11y-text);
  -webkit-font-smoothing: antialiased;
}

body.has-a11y-widget .btn-scroll-to-top,
body:has(.a11y-widget) .btn-scroll-to-top {
  bottom: 90px !important;
}

/* -----------------------------------------------------------------------------
 * FAB — icono clásico plano (círculo + anillo blanco + figura)
 * -------------------------------------------------------------------------- */
.a11y-fab {
  position: relative;
  width: var(--a11y-fab-size);
  height: var(--a11y-fab-size);
  border: none;
  border-radius: 50%;
  background: var(--a11y-brand);
  color: #fff;
  box-shadow: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, filter 0.2s ease;
}

/* Anillo blanco concéntrico (estilo icono universal) */
.a11y-fab::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  pointer-events: none;
}

.a11y-fab:hover,
.a11y-fab:focus-visible {
  transform: scale(1.04);
  filter: brightness(1.06);
  outline: 2px solid var(--a11y-brand);
  outline-offset: 3px;
}

.a11y-fab[aria-expanded="true"] {
  filter: brightness(0.95);
}

.a11y-fab svg {
  width: 26px;
  height: 26px;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/* -----------------------------------------------------------------------------
 * Panel
 * -------------------------------------------------------------------------- */
.a11y-panel {
  position: absolute;
  right: 0;
  bottom: calc(var(--a11y-fab-size) + 12px);
  width: min(300px, calc(100vw - 32px));
  background: var(--a11y-surface);
  border: 1px solid var(--a11y-border);
  border-radius: var(--a11y-radius);
  box-shadow: var(--a11y-shadow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  pointer-events: none;
}

.a11y-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header: icono brand + título + subtítulo + cerrar */
.a11y-panel__header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px 6px;
  background: transparent;
  border-bottom: none;
}

.a11y-panel__brand-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--a11y-brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.a11y-panel__brand-icon svg {
  width: 18px;
  height: 18px;
}

.a11y-panel__heading {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 1px;
}

.a11y-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--a11y-text);
}

.a11y-panel__subtitle {
  margin: 2px 0 0;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--a11y-muted);
}

.a11y-panel__close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--a11y-tile);
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.a11y-panel__close:hover,
.a11y-panel__close:focus-visible {
  background: var(--a11y-tile-icon);
  color: var(--a11y-text);
  outline: none;
}

.a11y-panel__close svg {
  width: 12px;
  height: 12px;
}

.a11y-panel__body {
  padding: 8px 14px 12px;
}

/* -----------------------------------------------------------------------------
 * Grilla de tiles
 * -------------------------------------------------------------------------- */
.a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.a11y-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--a11y-tile);
  color: var(--a11y-text);
  padding: 10px;
  min-height: 86px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.a11y-btn:hover {
  transform: translateY(-1px);
  background: #e8eef5;
}

.a11y-btn:focus-visible {
  outline: 2px solid var(--a11y-brand);
  outline-offset: 2px;
}

.a11y-btn.is-active {
  border-color: var(--a11y-brand);
  background: var(--a11y-brand-soft);
  box-shadow: inset 0 0 0 1px var(--a11y-brand);
}

.a11y-btn.is-active .a11y-btn__icon {
  background: var(--a11y-brand);
  color: #fff;
}

.a11y-btn__icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--a11y-tile-icon);
  color: var(--a11y-text);
}

.a11y-btn__icon svg {
  width: 15px;
  height: 15px;
}

.a11y-btn__label {
  display: block;
  line-height: 1.2;
}

.a11y-btn__meta {
  display: block;
  margin-top: -4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--a11y-muted);
}

/* -----------------------------------------------------------------------------
 * Restablecer — color institucional (color_barra)
 * -------------------------------------------------------------------------- */
.a11y-reset {
  width: 100%;
  margin-top: 10px;
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  background: var(--a11y-brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.a11y-reset:hover,
.a11y-reset:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
  outline: 2px solid var(--a11y-brand);
  outline-offset: 2px;
}

.a11y-reset svg {
  width: 16px;
  height: 16px;
}

/* -----------------------------------------------------------------------------
 * Footer
 * -------------------------------------------------------------------------- */
.a11y-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--a11y-border);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--a11y-text);
}

.a11y-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--a11y-muted);
}

.a11y-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--a11y-brand);
}

/* -----------------------------------------------------------------------------
 * Efectos globales en <html>
 * -------------------------------------------------------------------------- */
html.a11y-font-scaled {
  font-size: calc(100% * var(--a11y-font-scale, 1)) !important;
}

html.a11y-contrast {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast img,
html.a11y-contrast video,
html.a11y-contrast picture,
html.a11y-contrast iframe,
html.a11y-contrast canvas {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast .a11y-widget {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-sat-high body > *:not(.a11y-widget) {
  filter: saturate(1.8);
}

html.a11y-sat-low body > *:not(.a11y-widget) {
  filter: saturate(0.35);
}

html.a11y-sat-gray body > *:not(.a11y-widget) {
  filter: grayscale(1);
}

html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2' d='M8 4v36l9.5-9.5 6.5 15.5 5-2-6.5-15.5H40z'/%3E%3C/svg%3E") 4 4, auto !important;
}

html.a11y-tab-focus *:focus {
  outline: 3px solid #ffbf00 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(255, 191, 0, 0.35) !important;
}

html.a11y-tab-focus *:focus:not(:focus-visible) {
  outline: none !important;
  box-shadow: none !important;
}

html.a11y-tab-focus *:focus-visible {
  outline: 3px solid #ffbf00 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(255, 191, 0, 0.35) !important;
}

html.a11y-tab-focus .a11y-widget *:focus-visible {
  outline-color: var(--a11y-brand) !important;
  box-shadow: 0 0 0 4px var(--a11y-brand-soft) !important;
}

.a11y-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;
}

@media (max-width: 380px) {
  .a11y-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-fab,
  .a11y-panel,
  .a11y-btn,
  .a11y-reset {
    transition: none !important;
  }
}

/* Fallback si el navegador no soporta color-mix */
@supports not (color: color-mix(in srgb, #000 50%, white)) {
  :root {
    --a11y-brand-soft: rgba(59, 130, 246, 0.14);
  }
}
