/* ==========================================================================
   Stock Agent v2.0 - Accessibility Styles (WCAG 2.1 AA)
   Include on all pages for consistent focus indicators, contrast fixes,
   and screen-reader utility classes.
   ========================================================================== */

/* ---- Screen Reader Only ---- */
.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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ---- High-Contrast Focus Indicators ---- */
/* Applies to all interactive elements when focused via keyboard */
*:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.25);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.25);
}

/* Light theme focus indicator */
[data-theme="light"] *:focus-visible {
  outline-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

/* ---- Color Contrast Fixes (Dark Theme) ---- */
/* Many muted/tertiary text values are too low contrast on dark backgrounds.
   WCAG AA requires 4.5:1 for normal text, 3:1 for large text.
   #71717a on #0a0a0b is ~4.1:1 (fails). Bumping to #8a8a94 gives ~5.3:1. */

/* Fix low-contrast secondary text */
.text-tertiary,
.nav-group-label,
.metric-sub,
.activity-time,
.quick-stat-label,
.hero-label,
.status-subtitle,
.analytics-stat-sub,
.risk-level-sub,
.risk-cb-status-sub,
.risk-heat-label,
.risk-drawdown-depth-label,
.ace-log-ts,
.pnl-ticker-empty,
.empty-state-text,
.insight-card-confidence,
.section-subtitle,
.page-subtitle {
  color: rgba(255, 255, 255, 0.55) !important;
}

[data-theme="light"] .text-tertiary,
[data-theme="light"] .nav-group-label,
[data-theme="light"] .metric-sub,
[data-theme="light"] .activity-time,
[data-theme="light"] .quick-stat-label,
[data-theme="light"] .hero-label,
[data-theme="light"] .status-subtitle,
[data-theme="light"] .analytics-stat-sub,
[data-theme="light"] .risk-level-sub,
[data-theme="light"] .risk-cb-status-sub,
[data-theme="light"] .risk-heat-label,
[data-theme="light"] .risk-drawdown-depth-label,
[data-theme="light"] .ace-log-ts,
[data-theme="light"] .pnl-ticker-empty,
[data-theme="light"] .empty-state-text,
[data-theme="light"] .insight-card-confidence,
[data-theme="light"] .section-subtitle,
[data-theme="light"] .page-subtitle {
  color: rgba(0, 0, 0, 0.6) !important;
}

/* ---- Focus trap overlay background ---- */
.dialog-overlay,
.confirm-overlay {
  /* Ensure text on overlay dialogs is readable */
}

.dialog-overlay .dialog-box,
.confirm-overlay .confirm-dialog {
  /* Already styled; ensure focus ring works on dialog container */
}

.dialog-overlay .dialog-box:focus,
.confirm-overlay .confirm-dialog:focus {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* ---- Skip to Content Link ---- */
.sa-nav-skip:focus {
  position: fixed !important;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100001;
  padding: 8px 16px;
  background: #1e40af;
  color: #fff;
  font-weight: 600;
  border-radius: 4px;
  clip: auto !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  white-space: normal !important;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Loading State ---- */
[aria-busy="true"] {
  cursor: progress;
}

/* ---- Disabled State ---- */
[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
