/**
 * SalonSync Accessibility Styles
 * WCAG 2.1 AA Compliant
 *
 * This file contains accessibility-focused styles including:
 * - Enhanced focus indicators
 * - Screen reader utilities
 * - Skip links
 * - High contrast mode support
 */

/* ========================================
   FOCUS INDICATORS
   ======================================== */

/* Global focus outline */
*:focus {
    outline: 2px solid var(--color-primary-turquoise);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Enhanced focus for interactive elements */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus,
[role="button"]:focus,
[role="link"]:focus,
[tabindex="0"]:focus {
    outline: 3px solid var(--color-primary-turquoise);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(26, 176, 205, 0.1);
}

/* Remove focus outline when using mouse (but keep for keyboard) */
*:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Visible focus for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--color-primary-turquoise);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(26, 176, 205, 0.15);
}

/* ========================================
   SKIP LINKS
   ======================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary-turquoise);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    border-radius: 0 0 8px 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid white;
    outline-offset: -3px;
}

/* ========================================
   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-width: 0;
}

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

/* ========================================
   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;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
    /* Increase border visibility */
    button,
    input,
    select,
    textarea,
    .card,
    .modal {
        border-width: 2px;
        border-color: currentColor;
    }

    /* Stronger focus indicators */
    *:focus,
    *:focus-visible {
        outline-width: 4px;
        outline-offset: 4px;
    }

    /* Remove subtle shadows */
    .card,
    .modal,
    button {
        box-shadow: none;
    }
}

/* ========================================
   DARK MODE CONTRAST
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Ensure sufficient contrast in dark mode */
    :root {
        --text-contrast-min: #ffffff;
        --bg-contrast-min: #000000;
    }
}

/* ========================================
   ARIA LIVE REGIONS
   ======================================== */

[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* Visual indicator for loading/updating content */
[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--color-primary-turquoise);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   KEYBOARD NAVIGATION INDICATORS
   ======================================== */

/* Highlight currently focused element's container */
.has-focus-within:focus-within {
    background-color: rgba(102, 126, 234, 0.03);
    border-radius: 8px;
}

/* ========================================
   COLOR CONTRAST UTILITIES
   ======================================== */

/* Ensure text meets WCAG AA contrast ratio (4.5:1 for normal text) */
.text-high-contrast {
    color: #000000;
    background-color: #ffffff;
}

.text-high-contrast-inverse {
    color: #ffffff;
    background-color: #000000;
}

/* ========================================
   ACCESSIBLE FORM STYLES
   ======================================== */

/* Required field indicator */
.required::after {
    content: " *";
    color: var(--color-error);
    font-weight: bold;
    margin-left: 4px;
}

/* Error state with clear visual indicator */
[aria-invalid="true"],
.input-error {
    border-color: var(--color-error) !important;
    border-width: 2px !important;
    background-color: rgba(239, 68, 68, 0.05);
}

[aria-invalid="true"]:focus,
.input-error:focus {
    outline-color: var(--color-error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Error message */
.error-message {
    color: var(--color-error);
    font-size: 14px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message::before {
    content: "⚠";
    font-size: 16px;
}

/* ========================================
   ACCESSIBLE INTERACTIVE STATES
   ======================================== */

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

/* Pressed state */
[aria-pressed="true"] {
    background-color: var(--color-primary-turquoise);
    color: white;
    border-color: var(--color-primary-turquoise);
}

/* Expanded state */
[aria-expanded="false"] {
    /* Collapsed state styling if needed */
}

[aria-expanded="true"] {
    /* Expanded state styling if needed */
}

/* ========================================
   TOUCH TARGET SIZES
   ======================================== */

/* Ensure minimum 44x44px touch targets (WCAG 2.5.5) */
button,
a,
input[type="checkbox"],
input[type="radio"],
[role="button"],
[role="link"] {
    min-height: 44px;
    min-width: 44px;
}

/* Exception for inline text links */
a:not([role="button"]) {
    min-height: auto;
    min-width: auto;
}

/* ========================================
   LANDMARK ROLES VISUAL DEBUG
   ======================================== */

/* Only shown when debugging accessibility */
.a11y-debug [role="banner"],
.a11y-debug [role="main"],
.a11y-debug [role="navigation"],
.a11y-debug [role="contentinfo"] {
    outline: 2px dashed #ff6b6b;
    outline-offset: -2px;
}

/* ========================================
   PAGE TRANSITIONS (Accessible)
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Hide interactive elements */
    button,
    .skip-link,
    nav,
    .sidebar {
        display: none !important;
    }

    /* Ensure good contrast */
    * {
        background: white !important;
        color: black !important;
    }

    /* Show link URLs */
    a[href]::after {
        content: " (" attr(href) ")";
    }
}

/* ========================================
   TOOLTIP ACCESSIBILITY
   ======================================== */

[role="tooltip"] {
    background: var(--color-neutral-900);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    max-width: 250px;
    z-index: 9999;
}

/* ========================================
   TABLE ACCESSIBILITY
   ======================================== */

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

th {
    text-align: left;
    font-weight: 600;
    background-color: var(--color-neutral-50);
}

/* Zebra striping for readability */
tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ========================================
   FOCUS TRAP (for modals)
   ======================================== */

.focus-trap {
    position: relative;
}

/* Prevent focus from leaving modal */
.modal-open {
    overflow: hidden;
}

.modal-open *:not(.modal):not(.modal *) {
    /* Temporarily remove from tab order */
    visibility: hidden;
}

.modal-open .modal,
.modal-open .modal * {
    visibility: visible;
}
