/**
 * Comprehensive accessibility styles for terminal interface
 * WCAG 2.1 AA compliance with enhanced contrast and focus indicators
 */

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

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #0f0;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    border: 2px solid #0f0;
}

.skip-link:focus {
    top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .terminal,
    .monitor-interface,
    .split-screen-container {
        border: 2px solid currentColor;
    }
    
    .command-input,
    button {
    }
    
    .voice-indicator,
    .pane-refresh {
        border: 1px solid currentColor;
        padding: 2px;
    }
}

/* Reduced motion support */
@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;
    }
    
    .matrix-rain,
    .particle-effect,
    .typewriter-effect {
        animation: none !important;
    }
}

/* Enhanced focus indicators */
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus,
canvas:focus {
    outline: 3px solid #0ff;
    outline-offset: 2px;
    background-color: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(0, 255, 255, 0.3);
    /* Ensure focus is visible in Windows High Contrast */
    forced-color-adjust: none;
}

/* Focus indicators with better contrast ratios */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
canvas:focus-visible {
    outline: 3px solid #00ffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #000, 0 0 0 4px #00ffff;
}

/* High contrast focus for dark themes */
.theme-matrix button:focus,
.theme-matrix input:focus,
.theme-cyberpunk button:focus,
.theme-cyberpunk input:focus {
    outline-color: #0f0;
    box-shadow: 0 0 0 3px rgba(0, 255, 0, 0.3);
}

/* Ensure minimum touch target sizes (44x44px minimum) */
button,
.voice-toggle,
.speech-toggle,
.split-btn,
.control {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Accessible form controls */
.command-input {
    min-height: 44px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: #0f0;
    font-family: 'JetBrains Mono', monospace;
}

.command-input:focus {
    background: rgba(0, 255, 0, 0.1);
}

/* Accessible color contrast ratios (WCAG AA compliance) */
.terminal {
    color: #00ff41; /* High contrast green on black (7.1:1 ratio) */
    background-color: #000;
}

.prompt {
    color: #00ffff; /* Cyan for prompts (7.1:1 ratio) */
    font-weight: bold;
}

/* Ensure monitor interface has sufficient contrast */
.monitor-interface {
    color: #ffffff; /* White text on dark background (21:1 ratio) */
    background-color: #000000;
}

.pane-title {
    color: #00ff41; /* High contrast green for headings */
    font-weight: bold;
}

/* Status indicators with accessible colors */
.metric-success {
    color: #00ff00; /* Bright green (5.5:1 ratio) */
}

.metric-warning {
    color: #ffcc00; /* Bright yellow (4.8:1 ratio) */
}

.metric-critical,
.metric-error {
    color: #ff4444; /* Bright red (4.6:1 ratio) */
}

.voice-status {
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
}

/* Error and success states */
.error {
    color: #ff4444;
}

.success {
    color: #44ff44;
}

.warning {
    color: #ffaa00;
}

/* ARIA live regions styling */
[aria-live] {
    position: relative;
}

[aria-live="assertive"] {
    border-left: 3px solid #ff4444;
    padding-left: 8px;
}

[aria-live="polite"] {
    border-left: 3px solid #0ff;
    padding-left: 8px;
}

/* Loading and status indicators */
.loading {
    position: relative;
}

.loading::after {
    content: "Loading...";
    position: absolute;
    left: 0;
    top: 100%;
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* Keyboard navigation helpers */
.keyboard-navigation-visible button:focus,
.keyboard-navigation-visible input:focus,
.keyboard-navigation-visible [tabindex]:focus {
    outline: 3px solid #0ff;
    outline-offset: 2px;
}

/* Print styles for accessibility */
@media print {
    .skip-link,
    .voice-controls,
    .window-controls,
    .split-controls {
        display: none;
    }
    
    .terminal,
    .monitor-interface {
        background: white;
        color: black;
        border: 1px solid black;
    }
    
    .command-input {
        background: white;
        color: black;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Enhanced dark mode styles already handled by main theme */
}

/* Light mode fallback for accessibility */
@media (prefers-color-scheme: light) {
    .terminal {
        background-color: #f0f0f0;
        color: #000;
    }
    
    .command-input {
        background: #fff;
        color: #000;
    }
    
    .prompt {
        color: #006600;
    }
}

/* Voice/Speech indicators */
.speaking {
    animation: speak-pulse 1s infinite;
}

@keyframes speak-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Speech toggle button */
.speech-toggle {
    background: rgba(0, 255, 0, 0.1);
    color: #00ff41;
    margin-left: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.speech-toggle:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
}

.speech-toggle:active {
    transform: scale(0.95);
}

.speech-toggle.disabled {
    opacity: 0.5;
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
}

/* Responsive text sizing */
@media (max-width: 768px) {
    .terminal,
    .command-input,
    .monitor-interface {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* Larger touch targets on mobile */
    button,
    .voice-toggle,
    .split-btn {
        min-width: 48px;
        min-height: 48px;
        padding: 12px;
    }
}

/* Large text support */
@media (min-resolution: 2dppx) {
    .terminal,
    .command-input {
        font-size: 16px;
        line-height: 1.5;
    }
}

/* Windows High Contrast Mode */
@media (-ms-high-contrast: active) {
    .terminal,
    .monitor-interface {
        border: 2px solid;
    }
    
    .command-input,
    button {
    }
    
    .voice-indicator {
        border: 1px solid;
    }
}

/* Focus management for modal dialogs */
.modal-open {
    overflow: hidden;
}

.modal-open .modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
}

/* Accessible tooltips */
.tooltip {
    position: relative;
}

.tooltip[aria-describedby]:hover::after,
.tooltip[aria-describedby]:focus::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid #666;
}

/* Accessible progress indicators */
.progress {
    background: #333;
    overflow: hidden;
    height: 8px;
    width: 100%;
}

.progress-bar {
    height: 100%;
    background: #0f0;
    transition: width 0.3s ease;
}

/* Accessible status badges */
.status-online {
    color: #44ff44;
}

.status-offline {
    color: #ff4444;
}

.status-warning {
    color: #ffaa00;
}

/* Ensure charts have accessible alternatives */
canvas[role="img"] {
    outline: 1px solid transparent;
}

canvas[role="img"]:focus {
    outline: 3px solid #0ff;
}

/* Accessible data tables (if needed) */
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #333;
    padding: 8px;
    text-align: left;
}

th {
    background: rgba(0, 255, 0, 0.1);
    font-weight: bold;
}

/* Accessible form validation */
.field-error {
    color: #ff4444;
    font-size: 12px;
    margin-top: 4px;
}

.field-error::before {
    content: "⚠ ";
}

/* Landmark styling */
main[role="main"],
header[role="banner"],
nav[role="navigation"],
section[role="region"] {
    position: relative;
}

/* Screen reader announcements */
.sr-announcement {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Accessible drag and drop (if implemented) */
[draggable="true"]:focus {
    outline: 3px dashed #0ff;
}

.drop-zone {
    border: 2px dashed #666;
    padding: 20px;
    text-align: center;
}

.drop-zone.drag-over {
    border-color: #0ff;
    background: rgba(0, 255, 255, 0.1);
}