/*
  ═══════════════════════════════════════════════════════════════════════════════
  Wiser Workplace  -  WCAG 2.1 Level AA Accessibility Stylesheet

  This file provides site-wide accessibility standards including:
  - Skip-to-content link styling
  - Enhanced focus indicators (2px solid outline with 2px offset)
  - Screen reader only content
  - Reduced motion support
  - High contrast mode support
  - Minimum touch target sizes (44x44px)
  - Focus-within styles for form groups
  ═══════════════════════════════════════════════════════════════════════════════
*/

/* ──────────────────────────────────────────────────────────────────────────────
   SKIP-TO-CONTENT LINK STYLES
   ────────────────────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #3AAFA9;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
  font-weight: 600;
  font-size: 14px;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #17252A;
  outline-offset: 2px;
}

/* Alternative sr-only skip link for inline spans */
a.skip-link.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;
}

a.skip-link.sr-only:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  padding: 12px 20px;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background-color: #17252A;
  color: white;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 999;
}

/* ──────────────────────────────────────────────────────────────────────────────
   FOCUS INDICATORS
   WCAG 2.4.7: Ensure keyboard focus is always visible
   ────────────────────────────────────────────────────────────────────────────── */

/* Default focus styles for all interactive elements */
button,
a,
input,
textarea,
select,
[role="button"],
[role="link"],
[role="menuitem"],
[role="tab"] {
  position: relative;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus,
[role="button"]:focus,
[role="link"]:focus,
[role="menuitem"]:focus,
[role="tab"]:focus {
  outline: 2px solid #3AAFA9;
  outline-offset: 2px;
}

/* Modern :focus-visible is preferred for keyboard-only focus */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="tab"]:focus-visible {
  outline: 2px solid #3AAFA9;
  outline-offset: 2px;
  box-shadow: inset 0 0 0 3px #DEF2F1;
}

/* ──────────────────────────────────────────────────────────────────────────────
   SCREEN READER ONLY CONTENT
   Content visible only to screen readers (hidden visually)
   ────────────────────────────────────────────────────────────────────────────── */

.sr-only,
.screen-reader-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Allow screen reader only content to be visible when focused */
.sr-only:focus,
.screen-reader-only:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  margin: 0;
  padding: inherit;
}

/* ──────────────────────────────────────────────────────────────────────────────
   REDUCED MOTION PREFERENCES
   WCAG 2.3.3: Respect user's motion preferences
   ────────────────────────────────────────────────────────────────────────────── */

@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;
  }
}

/* ──────────────────────────────────────────────────────────────────────────────
   HIGH CONTRAST MODE SUPPORT
   Styles for users with high contrast preferences
   ────────────────────────────────────────────────────────────────────────────── */

@media (prefers-contrast: more) {
  button,
  a,
  input,
  textarea,
  select {
    border-width: 2px;
  }

  /* Enhance focus indicators in high contrast mode */
  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible {
    outline-width: 3px;
  }

  /* Increase text weight for better readability */
  body {
    font-weight: 500;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-weight: 700;
  }
}

/* ──────────────────────────────────────────────────────────────────────────────
   MINIMUM TOUCH TARGET SIZES
   WCAG 2.5.5: Ensure touch targets are at least 44x44 CSS pixels
   ────────────────────────────────────────────────────────────────────────────── */

button,
a[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="checkbox"],
input[type="radio"],
select,
[role="button"],
[role="link"],
[role="menuitem"],
[role="tab"],
.clickable {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
}

/* For inline buttons/links that should be 44x44 minimum */
button,
a[role="button"],
[role="button"] {
  min-height: 44px;
  padding: 10px 16px;
}

/* Touch-friendly form inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
}

/* ──────────────────────────────────────────────────────────────────────────────
   COLOR CONTRAST
   Ensure all text meets WCAG AA standards (4.5:1 for normal, 3:1 for large)
   ────────────────────────────────────────────────────────────────────────────── */

/* Ensure sufficient contrast on links */
a {
  color: #3AAFA9;
  text-decoration: underline;
}

a:visited {
  color: #2B7A78;
}

a:hover,
a:active {
  text-decoration: underline;
  opacity: 0.8;
}

/* ──────────────────────────────────────────────────────────────────────────────
   FORM STYLING FOR ACCESSIBILITY
   ────────────────────────────────────────────────────────────────────────────── */

label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: #17252A;
}

/* Required field indicator */
.required::after,
[aria-required="true"]::after {
  content: " *";
  color: #dc2626;
  font-weight: bold;
}

/* Form group with focus-within styling */
.form-group {
  margin-bottom: 16px;
}

.form-group:focus-within label {
  color: #3AAFA9;
  font-weight: 600;
}

.form-group:focus-within input,
.form-group:focus-within textarea,
.form-group:focus-within select {
  border-color: #3AAFA9;
  box-shadow: 0 0 0 3px rgba(58, 175, 169, 0.1);
}

/* Error and success states */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #dc2626;
  background-color: #fef2f2;
}

input[aria-invalid="false"],
textarea[aria-invalid="false"],
select[aria-invalid="false"] {
  border-color: #16a34a;
}

.error-message,
[role="alert"] {
  color: #991b1b;
  font-size: 14px;
  margin-top: 4px;
  display: block;
}

.success-message {
  color: #166534;
  font-size: 14px;
  margin-top: 4px;
  display: block;
}

/* ──────────────────────────────────────────────────────────────────────────────
   ICON ACCESSIBILITY
   ────────────────────────────────────────────────────────────────────────────── */

/* Ensure SVG icons have proper accessibility */
svg {
  display: inline-block;
  vertical-align: middle;
}

/* Hide decorative icons from screen readers */
svg[aria-hidden="true"] {
  pointer-events: none;
}

/* ──────────────────────────────────────────────────────────────────────────────
   TABLE ACCESSIBILITY
   ────────────────────────────────────────────────────────────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  font-weight: 600;
  padding: 12px;
  border-bottom: 2px solid #e5e7eb;
  background-color: #f9fafb;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}

/* Alternating row colors for readability */
tbody tr:nth-child(odd) {
  background-color: #f9fafb;
}

tbody tr:hover {
  background-color: #f3f4f6;
}

/* ──────────────────────────────────────────────────────────────────────────────
   HEADING HIERARCHY
   Ensure proper heading structure throughout the site
   ────────────────────────────────────────────────────────────────────────────── */

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  margin-top: 24px;
  line-height: 1.3;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  margin-top: 20px;
  line-height: 1.4;
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

h5 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.5;
}

h6 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────────────────────
   LIST ACCESSIBILITY
   ────────────────────────────────────────────────────────────────────────────── */

ul,
ol {
  margin-left: 24px;
  margin-bottom: 16px;
}

li {
  margin-bottom: 8px;
  line-height: 1.6;
}

/* ──────────────────────────────────────────────────────────────────────────────
   MAIN CONTENT WRAPPER
   Ensure main content area is properly identified
   ────────────────────────────────────────────────────────────────────────────── */

main,
[role="main"] {
  outline: none; /* Remove outline since it should come from skip-link target */
}

main:focus,
[role="main"]:focus {
  outline: 2px solid #3AAFA9;
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────────────────────────────────────
   SENSORY CHARACTERISTICS
   Don't rely solely on color to convey information
   ────────────────────────────────────────────────────────────────────────────── */

/* Use patterns or text in addition to colors */
.success {
  background-color: #dcfce7;
  border: 2px solid #16a34a;
  border-left: 4px solid #16a34a;
  padding: 12px;
  border-radius: 4px;
}

.success::before {
  content: "✓ ";
  font-weight: bold;
  color: #166534;
}

.error {
  background-color: #fee2e2;
  border: 2px solid #dc2626;
  border-left: 4px solid #dc2626;
  padding: 12px;
  border-radius: 4px;
}

.error::before {
  content: "✕ ";
  font-weight: bold;
  color: #991b1b;
}

.warning {
  background-color: #fef3c7;
  border: 2px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  padding: 12px;
  border-radius: 4px;
}

.warning::before {
  content: "! ";
  font-weight: bold;
  color: #d97706;
}

.info {
  background-color: #dbeafe;
  border: 2px solid #0284c7;
  border-left: 4px solid #0284c7;
  padding: 12px;
  border-radius: 4px;
}

.info::before {
  content: "ℹ ";
  font-weight: bold;
  color: #0369a1;
}

/* ──────────────────────────────────────────────────────────────────────────────
   PRINT STYLES
   ────────────────────────────────────────────────────────────────────────────── */

@media print {
  /* Hide interactive elements that don't make sense in print */
  .no-print,
  .skip-link,
  nav,
  footer,
  .chat-widget,
  [aria-hidden="true"] {
    display: none !important;
  }

  /* Improve print readability */
  a {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    color: black;
    background: white;
  }

  h1,
  h2,
  h3 {
    page-break-after: avoid;
  }

  p,
  ul,
  ol {
    page-break-inside: avoid;
  }
}

/* ──────────────────────────────────────────────────────────────────────────────
   DARK MODE SUPPORT
   For users with dark color scheme preference
   ────────────────────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }

  body {
    background-color: #1a1b1f;
    color: #e5e7eb;
  }

  a {
    color: #5ee7df;
  }

  a:visited {
    color: #6b9a94;
  }

  /* Adjust form styling for dark mode */
  input,
  textarea,
  select {
    background-color: #2a2b2f;
    color: #e5e7eb;
    border-color: #4b5563;
  }

  input:focus,
  textarea:focus,
  select:focus {
    background-color: #3a3b3f;
    border-color: #3AAFA9;
  }

  label {
    color: #e5e7eb;
  }

  .error-message {
    color: #fca5a5;
  }

  .success-message {
    color: #bbf7d0;
  }
}

/* ──────────────────────────────────────────────────────────────────────────────
   UTILITIES
   ────────────────────────────────────────────────────────────────────────────── */

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

/* Utility class for elements that should not be announced by screen readers */
.aria-hidden-false {
  aria-hidden: false;
}

/* Focus visible debugging - uncomment to visualize keyboard focus */
/*
[tabindex]:focus-visible::after {
  content: "tab";
  display: inline-block;
  background: red;
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  margin-left: 4px;
}
*/
