/* Fix for Bootstrap toast borders - override any red border styling */
.toast {
    border: 1px solid transparent !important;
    border-width: 1px !important;
}

/* Success toast border - make sure it overrides Bootstrap defaults */
.toast.border-success,
.toast.border-success:focus,
.toast.border-success:hover {
    border-color: var(--bs-success-border-subtle, #a3cfbb) !important;
    border-style: solid !important;
    border-width: 1px !important;
}

/* Danger toast border */
.toast.border-danger,
.toast.border-danger:focus,
.toast.border-danger:hover {
    border-color: var(--bs-danger-border-subtle, #f1aeb5) !important;
    border-style: solid !important;
    border-width: 1px !important;
}

.toast.border-warning {
    border-color: var(--bs-warning-border-subtle, #ffecb5) !important;
}

.toast.border-info {
    border-color: var(--bs-info-border-subtle, #b6effb) !important;
}

.toast.border-primary {
    border-color: var(--bs-primary-border-subtle, #b6d7ff) !important;
}

/* Force override any Bootstrap default toast border styles */
.toast:not(.border-danger):not(.border-warning):not(.border-info):not(.border-primary),
.toast.border-success {
    border-color: var(--bs-success-border-subtle, #a3cfbb) !important;
}

/* Ensure toast containers don't inherit border colors */
.toast-container .toast {
    border-color: inherit !important;
}

/* Additional fix: Override any default Bootstrap toast border that might be applied */
.toast-container .toast.border-success,
#actionToast.border-success {
    border: 1px solid var(--bs-success-border-subtle, #a3cfbb) !important;
    border-radius: 0.375rem !important;
}

/* Override any inherited or default border colors for success toasts */
.toast.border-success *,
.toast-container .toast.border-success *,
#actionToast.border-success * {
    border-color: inherit !important;
}

/* Enhanced toast color contrast */
.toast .toast-header.bg-success {
    background-color: var(--bs-success) !important;
    color: white !important;
}

.toast .toast-header.bg-danger {
    background-color: var(--bs-danger) !important;
    color: white !important;
}

.toast .toast-header.bg-warning {
    background-color: var(--bs-warning) !important;
    color: var(--bs-dark) !important;
}

.toast .toast-header.bg-info {
    background-color: var(--bs-info) !important;
    color: var(--bs-dark) !important;
}

.toast .toast-body.text-success {
    color: var(--bs-success) !important;
    background-color: var(--bs-light) !important;
}

.toast .toast-body.text-danger {
    color: var(--bs-danger) !important;
    background-color: var(--bs-light) !important;
}

.toast .toast-body.text-warning {
    color: var(--bs-warning-text-emphasis, #664d03) !important;
    background-color: var(--bs-light) !important;
}

.toast .toast-body.text-info {
    color: var(--bs-info-text-emphasis, #055160) !important;
    background-color: var(--bs-light) !important;
}

/* Accessibility Utilities */
.visually-hidden,
.um-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.visually-hidden-focusable:focus,
.visually-hidden-focusable:focus-within {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: inherit !important;
}

/* Enhanced Focus Indicators */
*:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* High Contrast Focus for Interactive Elements */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #fff, 0 0 0 4px #0d6efd;
}

/* ARIA Live Region Styling */
[aria-live] {
    font-weight: 500;
}

/* Role-based Styling */
[role="status"] {
    padding: 0.25rem;
    border-radius: 0.25rem;
}

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

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor;
    }
    
    button,
    input,
    select,
    textarea {
        border: 2px solid currentColor;
    }
}

/* Touch Target Minimum Size */
@media (pointer: coarse) {
    button,
    [role="button"],
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Enhanced touch targets for mobile */
    .form-check-input {
        width: 1.5em;
        height: 1.5em;
        margin-top: 0.125em;
    }
    
    .form-check-label {
        padding-left: 0.5rem;
        line-height: 1.5;
    }
    
    /* Larger clickable areas for dropdown toggles */
    .dropdown-toggle {
        padding: 0.75rem 1rem;
    }
}

/* Mobile Responsive Accessibility Enhancements */
@media (max-width: 768px) {
    /* Enhanced spacing for touch interfaces */
    .btn {
        padding: 0.75rem 1rem;
        margin: 0.25rem;
    }
    
    /* Improved form control sizing */
    .form-control,
    .form-select {
        padding: 0.75rem 0.75rem;
        font-size: 1rem;
        line-height: 1.5;
    }
    
    /* Better spacing for form groups */
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }
    
    /* Enhanced focus indicators for mobile */
    *:focus {
        outline: 3px solid #0d6efd;
        outline-offset: 3px;
    }
    
    /* Improved table responsiveness */
    .table-responsive {
        font-size: 0.875rem;
        border-radius: 0.5rem;
        overflow-x: auto;
        /* Removed deprecated -webkit-overflow-scrolling: touch; - modern browsers handle momentum scrolling automatically */
    }
    
    /* Better modal sizing for mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    /* Enhanced alert styling for mobile */
    .alert {
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Improved navigation for mobile screen readers */
    .navbar-nav .nav-link {
        padding: 1rem 0.75rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Small Mobile Devices (phones in portrait) */
@media (max-width: 576px) {
    /* Stack form controls vertically */
    .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Enhanced button spacing */
    .btn-group-vertical .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Better card spacing */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }
    
    /* Improved breadcrumb navigation */
    .breadcrumb {
        flex-wrap: wrap;
        font-size: 0.875rem;
    }
    
    /* Enhanced pagination for mobile */
    .pagination {
        justify-content: center;
    }
    
    .pagination .page-link {
        padding: 0.75rem 1rem;
        margin: 0 0.125rem;
    }
}

/* Tablet Landscape Orientation */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    /* Optimized layout for tablet landscape */
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    /* Better table column sizing */
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
}

/* High DPI/Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Enhanced focus indicators for high DPI */
    *:focus {
        outline-width: 2px;
    }
    
    /* Better border definition */
    .table th,
    .table td,
    .card,
    .btn {
        border-width: 1px;
    }
}

/* Landscape Mobile Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    /* Compact navigation for landscape mobile */
    .navbar {
        padding: 0.25rem 1rem;
    }
    
    /* Reduced modal padding */
    .modal-body {
        padding: 1rem;
    }
    
    /* Optimized form layout */
    .form-floating {
        margin-bottom: 1rem;
    }
}

/* Voice Control and Switch Navigation Support */
@media (prefers-reduced-motion: no-preference) {
    /* Subtle transitions for better voice control feedback */
    button:hover,
    .btn:hover,
    [role="button"]:hover {
        transition: all 0.15s ease-in-out;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Focus Management for Touch Devices */
@media (pointer: coarse) {
    /* Disable hover effects that interfere with touch */
    *:hover {
        transition: none;
    }
    
    /* Enhanced active states for touch feedback */
    button:active,
    .btn:active,
    [role="button"]:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Screen Reader Optimizations */
.sr-only-mobile {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 768px) {
    .sr-only-mobile {
        position: static !important;
        width: auto !important;
        height: auto !important;
        padding: inherit !important;
        margin: inherit !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: inherit !important;
    }
}

/* Print Accessibility */
@media print {
    /* Ensure focus indicators are visible in print */
    *:focus {
        outline: 2px solid #000 !important;
    }
    
    /* Hide non-essential interactive elements */
    .btn,
    .dropdown,
    .modal {
        display: none !important;
    }
    
    /* Ensure sufficient contrast for print */
    .table th,
    .table td {
        border: 1px solid #000 !important;
    }
}
