/* ============================================
   EEIM Platform - WCAG 2.1 AA Accessibility
   ============================================ */

/* ---- SKIP LINK (WCAG 2.4.1) ---- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--primary);
    color: #fff;
    padding: 12px 24px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 10000;
    font-weight: 700;
    font-size: 0.9rem;
    transition: top 0.2s;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ---- FOCUS INDICATORS (WCAG 2.4.7) ---- */
/* All interactive elements must have visible focus */
*:focus-visible {
    outline: 3px solid var(--accent) !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Remove default outline only when using mouse */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for buttons */
.btn:focus-visible,
.nav-link:focus-visible,
.header-btn:focus-visible {
    outline: 3px solid var(--accent) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.2) !important;
}

/* Enhanced focus for inputs */
.form-control:focus-visible {
    outline: 3px solid var(--accent) !important;
    outline-offset: 0 !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15) !important;
}

/* ---- COLOR CONTRAST (WCAG 1.4.3 - 4.5:1 ratio) ---- */
/* Ensure text meets minimum contrast ratios */

/* Primary text on dark bg: #f1f5f9 on #0f172a = 15.4:1 ✓ */
/* Secondary text: #94a3b8 on #0f172a = 5.6:1 ✓ */
/* Muted text upgraded for WCAG */
:root {
    --text-muted-wcag: #8b9bb5; /* Upgraded from #64748b (3.9:1) to 4.6:1 */
}

/* Override muted text color for WCAG compliance */
.breadcrumb,
.nav-section-title,
.stat-info h4,
.event-info .meta,
.calendar-date,
.member-card .phone,
.song-info .author,
.form-help,
.empty-state p,
.sidebar-user-info .role,
.compliance-footer small {
    color: var(--text-muted-wcag);
}

/* Tags need sufficient contrast */
.tag-blue { background: rgba(59,130,246,0.2); color: #93bbfd; }
.tag-purple { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.tag-green { background: rgba(16,185,129,0.2); color: #6ee7b7; }
.tag-orange { background: rgba(245,158,11,0.2); color: #fcd34d; }
.tag-red { background: rgba(239,68,68,0.2); color: #fca5a5; }
.tag-cyan { background: rgba(6,182,212,0.2); color: #67e8f9; }

/* ---- TEXT RESIZING (WCAG 1.4.4) ---- */
/* Use relative units, allow 200% zoom */
html {
    font-size: 100%; /* Respect user preferences */
}

/* ---- REDUCED MOTION (WCAG 2.3.3) ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .toast {
        animation: none !important;
    }

    .modal {
        transition: none !important;
    }
}

/* ---- HIGH CONTRAST MODE ---- */
@media (prefers-contrast: high) {
    :root {
        --border: rgba(255, 255, 255, 0.3);
        --text-secondary: #e2e8f0;
        --text-muted-wcag: #cbd5e1;
    }

    .card,
    .stat-card,
    .event-card,
    .team-card,
    .member-card,
    .song-item {
        border-width: 2px;
    }

    .btn {
        border: 2px solid currentColor;
    }

    .form-control {
        border-width: 2px;
    }
}

/* ---- FORM ACCESSIBILITY ---- */

/* Required field indicator */
.required {
    color: #f87171;
    font-weight: 700;
}

/* Form help text */
.form-help {
    font-size: 0.75rem;
    color: var(--text-muted-wcag);
    margin-top: 4px;
    display: block;
}

/* Error states (WCAG 3.3.1) */
.form-control[aria-invalid="true"],
.form-control.error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-error {
    color: #fca5a5;
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-error::before {
    content: '⚠';
}

/* Success states */
.form-control.success {
    border-color: var(--success);
}

/* ---- ALERT COMPONENTS (WCAG 4.1.3) ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

/* ---- PASSWORD FIELD ---- */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
}

.password-toggle:hover {
    background: rgba(255,255,255,0.05);
}

/* ---- SECURITY BADGE ---- */
.security-badge {
    text-align: center;
    font-size: 0.72rem;
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    margin-bottom: 20px;
}

.compliance-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.compliance-footer small {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

/* ---- LINK DISTINCTION (WCAG 1.4.1) ---- */
/* Links must be distinguishable not just by color */
a:not(.btn):not(.nav-link):not(.sidebar-user) {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:not(.btn):not(.nav-link):not(.sidebar-user):hover {
    text-decoration-thickness: 2px;
}

/* ---- TABLE ACCESSIBILITY (WCAG 1.3.1) ---- */
table {
    border-collapse: collapse;
}

thead th {
    text-align: left;
    font-weight: 700;
}

/* Row hover should not rely solely on color */
tbody tr:hover {
    outline: 1px solid var(--border-active);
}

/* ---- KEYBOARD NAVIGATION for cards ---- */
.event-card:focus-visible,
.team-card:focus-visible,
.member-card:focus-visible,
.song-item:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Make clickable cards keyboard accessible */
[onclick] {
    cursor: pointer;
}

[onclick]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ---- MODAL ACCESSIBILITY ---- */
.modal[role="dialog"] {
    /* Ensure modal is announced */
}

/* ---- TOUCH TARGETS (WCAG 2.5.5) ---- */
/* Minimum 44x44px touch targets */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-link {
        min-height: 44px;
    }

    .header-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .tab-btn {
        min-height: 44px;
    }

    .form-control {
        min-height: 44px;
    }

    .password-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- PASSWORD STRENGTH METER ---- */
.password-strength {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.password-strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.1);
    transition: background 0.3s;
}

.password-strength-bar.active.weak { background: var(--danger); }
.password-strength-bar.active.medium { background: var(--warning); }
.password-strength-bar.active.strong { background: var(--success); }

.password-strength-label {
    font-size: 0.72rem;
    margin-top: 4px;
}

/* ---- SCREEN READER ONLY (WCAG) ---- */
.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;
}

/* ---- NIS2 AUDIT LOG PAGE ---- */
.audit-severity-info { color: var(--info); }
.audit-severity-warning { color: var(--warning); }
.audit-severity-critical { color: var(--danger); }
.audit-severity-emergency { color: #ff4444; font-weight: 700; }

/* ---- PRINT ACCESSIBILITY ---- */
@media print {
    .skip-link,
    .password-toggle,
    .security-badge,
    .compliance-footer {
        display: none !important;
    }

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