/* Accessibility improvements for Minutes in a Second */
/* WCAG 2.1 AA compliance focused styles */

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-blue);
    color: var(--white);
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Focus styles - visible and clear */
*:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Remove outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Ensure focus is visible on all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        forced-color-adjust: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        color: blue;
        text-decoration: underline;
    }
    
    button, .btn {
        border: 2px solid;
    }
    
    .organisation-card,
    .minute-card {
        border: 2px solid black;
    }
}

/* Screen reader only content */
.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;
}

/* Make screen reader content visible when focused */
.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Ensure sufficient color contrast */
.low-contrast {
    color: var(--gray-600); /* Only for decorative text */
}

/* Improve link differentiation */
a {
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.4);
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-color: var(--primary-blue);
}

a:visited {
    color: #6d28d9; /* Purple for visited links */
}

/* Ensure interactive elements are distinguishable */
button, .btn, input[type="submit"] {
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.025em;
}

/* Disabled state styling */
[disabled], .disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading states for screen readers */
[aria-busy="true"] {
    position: relative;
}

[aria-busy="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Improve form accessibility */
label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-1);
    color: var(--gray-700);
}

/* Required field indicators */
.required::after {
    content: " *";
    color: #dc2626;
    font-weight: bold;
}

/* Error messages */
.error-message {
    color: #dc2626;
    font-size: var(--text-sm);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.error-message::before {
    content: "⚠";
    font-size: var(--text-base);
}

/* Success messages */
.success-message {
    color: var(--secondary-green);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.success-message::before {
    content: "✓";
    font-size: var(--text-base);
}

/* Improve table accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

table caption {
    font-weight: bold;
    margin-bottom: var(--space-2);
    text-align: left;
}

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

/* Zebra striping for better row differentiation */
tbody tr:nth-child(odd) {
    background-color: var(--gray-50);
}

tbody tr:hover {
    background-color: var(--gray-100);
}

/* Improve icon accessibility */
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Ensure icons have text alternatives */
.icon-only {
    position: relative;
}

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

/* Improve heading hierarchy visibility */
h1, h2, h3, h4, h5, h6 {
    margin-top: var(--space-8);
    margin-bottom: var(--space-4);
}

h1:first-child,
h2:first-child,
h3:first-child {
    margin-top: 0;
}

/* Ensure sufficient spacing between interactive elements */
.button-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Improved focus for keyboard navigation */
.card:focus-within {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Ensure modals and overlays are accessible */
.modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: var(--white);
    padding: var(--space-6);
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* Ensure proper heading structure in modals */
.modal-content h2:first-child {
    margin-top: 0;
}

/* Improve landmark navigation */
main {
    min-height: 50vh;
}

/* Add visual cues for navigation */
nav[aria-label="Breadcrumb"] ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
}

nav[aria-label="Breadcrumb"] li::after {
    content: "›";
    margin: 0 var(--space-2);
    color: var(--gray-400);
}

nav[aria-label="Breadcrumb"] li:last-child::after {
    content: "";
}

/* Ensure proper contrast for placeholder text */
::placeholder {
    color: var(--gray-500);
    opacity: 1;
}

/* Improve selection visibility */
::selection {
    background-color: rgba(37, 99, 235, 0.2);
    color: var(--gray-900);
}

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

/* Dark mode support with proper contrast */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-300: #6b7280;
        --gray-600: #d1d5db;
        --gray-700: #e5e7eb;
        --gray-800: #f3f4f6;
        --gray-900: #f9fafb;
        --white: #111827;
        --primary-blue: #60a5fa;
        --primary-dark: #93bbfc;
    }
    
    body {
        background-color: var(--gray-900);
        color: var(--gray-100);
    }
    
    a:visited {
        color: #a78bfa;
    }
}

/* Ensure touch targets meet minimum size */
a, button, input, select, textarea, [role="button"], [tabindex] {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-2);
}

/* Exception for inline text links */
p a, li a, td a {
    min-height: auto;
    min-width: auto;
    padding: 0;
}

/* Improve error page accessibility */
.error-page {
    text-align: center;
    padding: var(--space-16) var(--space-4);
}

.error-code {
    font-size: var(--text-4xl);
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: var(--space-4);
}

/* Ensure status messages are announced */
[role="status"],
[role="alert"],
[aria-live] {
    position: relative;
    padding: var(--space-3);
    border-radius: 4px;
    margin: var(--space-4) 0;
}

[role="alert"] {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

[role="status"] {
    background-color: #dbeafe;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}