/* Adaptive UI Contrast Enhancer Styles */

/* CSS Variables for dynamic contrast adjustments */
:root {
    --contrast-multiplier: 1.0;
    --contrast-filter: contrast(1);
    
    /* Base contrast colors */
    --contrast-bg-primary: #ffffff;
    --contrast-bg-secondary: #f8f9fa;
    --contrast-text-primary: #1a202c;
    --contrast-text-secondary: #4a5568;
    --contrast-border: #e2e8f0;
    --contrast-accent: #2563eb;
    
    /* Enhanced contrast colors */
    --contrast-enhanced-bg: #ffffff;
    --contrast-enhanced-text: #000000;
    --contrast-enhanced-border: #333333;
    --contrast-enhanced-accent: #0056b3;
}

/* Contrast Control Panel Styles */
.contrast-control-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #2563eb;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    z-index: 9999;
    transform: translateX(350px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
}

.contrast-control-panel.show {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.contrast-panel-header {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: between;
    align-items: center;
    border-radius: 10px 10px 0 0;
    margin: -1px -1px 0 -1px;
}

.contrast-panel-header h6 {
    margin: 0;
    font-weight: 700;
    font-size: 14px;
    flex: 1;
}

.btn-close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-close-panel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.contrast-panel-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.contrast-setting-group {
    margin-bottom: 20px;
}

.contrast-setting-group:last-child {
    margin-bottom: 0;
}

.contrast-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    margin-bottom: 8px;
}

.contrast-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    transition: border-color 0.2s;
}

.contrast-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.contrast-subheading {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 4px;
}

.contrast-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
}

.contrast-checkbox input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

.contrast-checkbox span {
    flex: 1;
}

.contrast-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.contrast-shortcuts-info {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    text-align: center;
}

/* Toggle Button */
.contrast-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contrast-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(37, 99, 235, 0.4);
}

.contrast-toggle-btn:active {
    transform: translateY(0);
}

/* Hide toggle when panel is open */
.contrast-control-panel.show + .contrast-toggle-btn {
    opacity: 0;
    visibility: hidden;
}

/* Skip Links */
.skip-links {
    position: absolute;
    top: -100px;
    left: 20px;
    z-index: 10000;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #2563eb;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
    color: white;
    text-decoration: none;
}

/* Test Overlay */
.contrast-test-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(5px);
}

.contrast-test-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

/* Notification */
.contrast-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    border: 2px solid #10b981;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.contrast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.contrast-notification-info {
    border-color: #3b82f6;
    color: #1e40af;
}

.contrast-notification-success {
    border-color: #10b981;
    color: #047857;
}

/* Theme Styles */

/* Light Theme */
.theme-light {
    --contrast-bg-primary: #ffffff;
    --contrast-bg-secondary: #f8f9fa;
    --contrast-text-primary: #1a202c;
    --contrast-text-secondary: #4a5568;
    --contrast-border: #e2e8f0;
}

/* Dark Theme */
.theme-dark {
    --contrast-bg-primary: #1a202c;
    --contrast-bg-secondary: #2d3748;
    --contrast-text-primary: #f7fafc;
    --contrast-text-secondary: #cbd5e0;
    --contrast-border: #4a5568;
    
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%) !important;
}

.theme-dark .navbar {
    background: rgba(26, 32, 44, 0.95) !important;
}

.theme-dark .card {
    background: rgba(45, 55, 72, 0.9) !important;
    color: #f7fafc !important;
}

.theme-dark .card-header {
    background: linear-gradient(135deg, #2d3748, #4a5568) !important;
    color: #f7fafc !important;
}

.theme-dark .table {
    color: #f7fafc !important;
    background: transparent;
}

.theme-dark .table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.theme-dark .form-control, .theme-dark .form-select {
    background: #2d3748 !important;
    border-color: #4a5568 !important;
    color: #f7fafc !important;
}

.theme-dark .form-control:focus, .theme-dark .form-select:focus {
    background: #374151 !important;
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.25) !important;
}

/* High Contrast Blue Theme */
.theme-blue {
    --contrast-bg-primary: #f0f8ff;
    --contrast-bg-secondary: #e6f3ff;
    --contrast-text-primary: #003366;
    --contrast-text-secondary: #004080;
    --contrast-border: #0066cc;
    --contrast-accent: #0052cc;
}

.theme-blue .navbar {
    background: rgba(240, 248, 255, 0.98) !important;
    border-bottom: 2px solid #0066cc !important;
}

.theme-blue .navbar-nav .nav-link {
    color: #003366 !important;
    border: 2px solid #0066cc !important;
}

.theme-blue .card {
    background: #f0f8ff !important;
    border: 2px solid #0066cc !important;
}

/* Enhancement Classes */

/* Text Contrast Enhancement */
.enhance-text-contrast {
    --text-contrast-multiplier: calc(var(--contrast-multiplier) * 1.2);
}

.enhance-text-contrast h1,
.enhance-text-contrast h2,
.enhance-text-contrast h3,
.enhance-text-contrast h4,
.enhance-text-contrast h5,
.enhance-text-contrast h6 {
    color: var(--contrast-enhanced-text) !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.enhance-text-contrast p,
.enhance-text-contrast .card-text,
.enhance-text-contrast .table td {
    color: var(--contrast-enhanced-text) !important;
    font-weight: 500;
}

.enhance-text-contrast .text-muted {
    color: var(--contrast-text-secondary) !important;
    font-weight: 600 !important;
}

/* Button Contrast Enhancement */
.enhance-button-contrast .btn {
    font-weight: 700 !important;
    border-width: 2px !important;
    border-style: solid !important;
    text-shadow: none !important;
    position: relative;
    overflow: hidden;
}

.enhance-button-contrast .btn-primary {
    background: var(--contrast-enhanced-accent) !important;
    border-color: var(--contrast-enhanced-accent) !important;
    color: white !important;
}

.enhance-button-contrast .btn-secondary {
    background: #6c757d !important;
    border-color: #6c757d !important;
    color: white !important;
}

.enhance-button-contrast .btn-outline-primary {
    background: white !important;
    border-color: var(--contrast-enhanced-accent) !important;
    color: var(--contrast-enhanced-accent) !important;
}

.enhance-button-contrast .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Card Contrast Enhancement */
.enhance-card-contrast .card {
    border: 3px solid var(--contrast-enhanced-border) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.enhance-card-contrast .card-header {
    border-bottom: 2px solid var(--contrast-enhanced-border) !important;
    font-weight: 700 !important;
}

.enhance-card-contrast .table {
    border: 2px solid var(--contrast-enhanced-border) !important;
}

.enhance-card-contrast .table th,
.enhance-card-contrast .table td {
    border: 1px solid var(--contrast-enhanced-border) !important;
}

/* Accessibility Enhancements */

/* Increased Font Size */
.increase-font-size {
    font-size: 110% !important;
}

.increase-font-size .navbar-nav .nav-link {
    font-size: 12px !important;
    padding: 10px 14px !important;
}

.increase-font-size .btn {
    font-size: 16px !important;
    padding: 10px 16px !important;
}

.increase-font-size .card-title {
    font-size: 1.5rem !important;
}

.increase-font-size .table {
    font-size: 16px !important;
}

/* Enhanced Focus Indicators */
.enhanced-focus *:focus {
    outline: 3px solid #ffd700 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(255, 215, 0, 0.3) !important;
}

.enhanced-focus .btn:focus {
    outline: 3px solid #ffd700 !important;
    outline-offset: 2px !important;
}

.enhanced-focus .form-control:focus,
.enhanced-focus .form-select:focus {
    border-color: #ffd700 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 215, 0, 0.5) !important;
}

.enhanced-focus .nav-link:focus {
    background: rgba(255, 215, 0, 0.2) !important;
    outline: 2px solid #ffd700 !important;
}

/* Reduced Motion */
.reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

.reduce-motion .progress-bar-animated {
    animation: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .contrast-control-panel {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        transform: translateY(-100%);
    }
    
    .contrast-control-panel.show {
        transform: translateY(0);
    }
    
    .contrast-toggle-btn {
        bottom: 20px;
        top: auto;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .contrast-control-panel {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
    }
    
    .contrast-panel-content {
        padding: 15px;
    }
    
    .contrast-toggle-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* High Contrast Media Query Support */
@media (prefers-contrast: high) {
    :root {
        --contrast-multiplier: 1.5;
    }
    
    .contrast-control-panel {
        border-width: 3px;
    }
    
    .btn {
        border-width: 2px !important;
    }
}

/* Reduced Motion Media Query Support */
@media (prefers-reduced-motion: reduce) {
    .contrast-control-panel {
        transition: none;
    }
    
    .contrast-toggle-btn {
        transition: none;
    }
    
    .skip-link {
        transition: none;
    }
    
    .contrast-notification {
        transition: none;
    }
}

/* Print Styles */
@media print {
    .contrast-control-panel,
    .contrast-toggle-btn,
    .skip-links {
        display: none !important;
    }
    
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}