/**
 * UI/UX Enhancements for DRC Assist
 * Addresses accessibility, responsive design, and user experience improvements
 */

/* ===== ACCESSIBILITY & FORM IMPROVEMENTS ===== */

/* Enhanced Radio Buttons and Checkboxes */
.form-check-input {
    width: 1.25em !important;
    height: 1.25em !important;
    margin-top: 0.125em;
    cursor: pointer;
    transform: scale(1.2);
    margin-right: 0.75rem;
}

.form-check-input:focus {
    border-color: #6366f1;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25);
}

.form-check-input:hover {
    border-color: #8b5cf6;
    transform: scale(1.25);
    transition: all 0.2s ease;
}

.form-check-label {
    cursor: pointer;
    font-weight: 500;
    color: #ffffff;
    padding-left: 0.5rem;
}

/* Enhanced Color Contrast */
.text-muted {
    color: #b0b3b8 !important; /* Improved contrast from default */
}

.text-secondary {
    color: #8b949e !important;
}

/* Better Focus Indicators */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 3px solid rgba(99, 102, 241, 0.5);
    outline-offset: 2px;
}

/* Enhanced Button States */
.btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
    transition: all 0.1s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5b21b6, #7c3aed);
    border-color: #5b21b6;
}

/* ===== FORM VALIDATION & ERROR HANDLING ===== */

/* Required Field Indicators */
.required-field::after {
    content: " *";
    color: #ef4444;
    font-weight: bold;
}

/* Validation States */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: #22c55e;
    background-color: rgba(34, 197, 94, 0.1);
}

.invalid-feedback {
    display: block;
    color: #ef4444;
    font-weight: 500;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.valid-feedback {
    display: block;
    color: #22c55e;
    font-weight: 500;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Error Summary Box */
.error-summary {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.error-summary h5 {
    color: #ef4444;
    margin-bottom: 10px;
}

.error-summary ul {
    color: #ef4444;
    margin-bottom: 0;
}

.error-summary li {
    margin-bottom: 5px;
}

/* ===== LOADING & PROGRESS INDICATORS ===== */

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #6366f1;
    animation: spin 1s ease-in-out infinite;
}

.loading-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

/* Progress Bar */
.progress-indicator {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-indicator .progress-bar {
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-indicator .progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 10px 10px;
    animation: move 1s linear infinite;
}

@keyframes move {
    0% { background-position: 0 0; }
    100% { background-position: 10px 10px; }
}

/* Loading States for Cards and Sections */
.loading-state {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: inherit;
    z-index: 10;
}

.loading-state::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #6366f1;
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* ===== ERROR MESSAGE IMPROVEMENTS ===== */

/* User-Friendly Error Messages */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    color: #ffffff;
}

.error-message .error-title {
    font-weight: bold;
    color: #ef4444;
    margin-bottom: 8px;
}

.error-message .error-details {
    font-size: 0.9rem;
    color: #b0b3b8;
    margin-bottom: 10px;
}

.error-message .error-actions {
    margin-top: 15px;
}

.error-message .error-actions .btn {
    margin-right: 10px;
}

/* Success Messages */
.success-message {
    background: rgba(34, 197, 94, 0.1);
    border-left: 4px solid #22c55e;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    color: #ffffff;
}

.success-message .success-title {
    font-weight: bold;
    color: #22c55e;
    margin-bottom: 8px;
}

/* Warning Messages */
.warning-message {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid #f59e0b;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    color: #ffffff;
}

.warning-message .warning-title {
    font-weight: bold;
    color: #f59e0b;
    margin-bottom: 8px;
}

/* ===== RESPONSIVE DESIGN IMPROVEMENTS ===== */

/* Enhanced Mobile Experience */
@media (max-width: 768px) {
    .form-check-input {
        width: 1.5em !important;
        height: 1.5em !important;
        transform: scale(1.4);
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        min-height: 48px; /* Touch target accessibility */
    }
    
    .form-control, .form-select {
        padding: 12px 16px;
        font-size: 1rem;
        min-height: 48px;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .modal-dialog {
        margin: 10px;
    }
    
    /* Improve text readability on mobile */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1, h2, h3, h4, h5, h6 {
        line-height: 1.3;
        margin-bottom: 1rem;
    }
}

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .btn {
        padding: 10px 18px;
    }
}

/* ===== KEYBOARD NAVIGATION SUPPORT ===== */

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #6366f1;
    color: #ffffff;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
}

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

/* Enhanced Tab Navigation */
.nav-link:focus,
.dropdown-item:focus,
a:focus {
    outline: 3px solid rgba(99, 102, 241, 0.5);
    outline-offset: 2px;
    text-decoration: none;
}

/* Modal Focus Management */
.modal:focus {
    outline: none;
}

.modal-content:focus {
    outline: 3px solid rgba(99, 102, 241, 0.5);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Lazy Loading for Images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Reduced Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000000;
        border-color: #ffffff;
        color: #ffffff;
    }
    
    .form-control, .form-select {
        background: #000000;
        border-color: #ffffff;
        color: #ffffff;
    }
    
    .card {
        border-color: #ffffff;
    }
}

/* ===== UTILITY CLASSES ===== */

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

/* Focus Visible Polyfill */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .btn, .form-control {
        border: 1px solid #000 !important;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
    }
}