/* ============================================
   Advanced Features and Optimizations
   ============================================ */

/* Skip link styles */
.skip-to-main:focus {
    position: absolute;
    top: 0;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px 12px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 0 0 4px 4px;
    font-weight: 600;
}

/* Toast container improvements */
.toast-container {
    pointer-events: none;
}

.toast-container .toast {
    pointer-events: auto;
    margin-bottom: 0.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Advanced button states */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    color: inherit;
}

/* Loading and skeleton states */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* Error states */
.error-state {
    padding: 2rem;
    text-align: center;
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin: 1rem 0;
}

.error-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dc3545;
}

/* Success states */
.success-state {
    padding: 2rem;
    text-align: center;
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    margin: 1rem 0;
}

.success-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #28a745;
}

/* Advanced dropdown animations */
.enhanced-header .dropdown-menu {
    transform-origin: top center;
}

.enhanced-header .dropdown-menu.show {
    animation: dropdownFadeIn 0.3s ease-out;
}

@keyframes dropdownFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Advanced hover effects */
.enhanced-header .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #64b5f6, #42a5f5);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.enhanced-header .nav-link:hover::after {
    width: 80%;
}

/* Brand logo improvements */
.brand-logo {
    max-height: 40px;
    width: auto;
    transition: all 0.3s ease;
}

.brand-logo:hover {
    transform: scale(1.05);
}

/* Enhanced badge styles */
.badge-pulse {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

/* Modern glassmorphism effects */
.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Custom scrollbar for dropdown menus */
.enhanced-header .dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.enhanced-header .dropdown-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.enhanced-header .dropdown-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.enhanced-header .dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Better visual hierarchy */
.enhanced-header .dropdown-header {
    position: relative;
}

.enhanced-header .dropdown-header::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 1.5rem;
    right: 1.5rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, #dee2e6, transparent);
}

/* Improved focus management */
.focus-trap-active {
    overflow: hidden;
}

/* Improved contrast for accessibility */
@media (prefers-contrast: high) {
    .enhanced-header {
        background: #000;
    }
    
    .enhanced-header .nav-link {
        color: #fff !important;
        border: 1px solid #fff;
    }
    
    .enhanced-header .dropdown-menu {
        background: #fff;
        border: 2px solid #000;
    }
    
    .enhanced-header .dropdown-item {
        color: #000;
        border-bottom: 1px solid #000;
    }
}

/* Additional utility classes */
.text-shadow {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.box-shadow-lg {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.transition-all {
    transition: all 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-shadow:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Micro-interactions */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.backface-hidden {
    backface-visibility: hidden;
}

/* GPU acceleration */
.gpu-accelerated {
    transform: translateZ(0);
}

/* Animation performance */
@keyframes optimizedFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in-optimized {
    animation: optimizedFadeIn 0.3s ease-out;
    will-change: opacity;
}

/* Prefers reduced motion - comprehensive */
@media (prefers-reduced-motion: reduce) {
    .btn-ripple::before,
    .badge-pulse,
    .enhanced-header .nav-link::after,
    .hover-scale:hover,
    .hover-shadow:hover {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
    .notification-badge,
    .admin-badge {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
    .enhanced-header {
        background: ButtonFace;
        border-bottom: 1px solid ButtonText;
    }
    
    .enhanced-header .nav-link {
        color: LinkText;
    }
    
    .enhanced-header .nav-link:hover {
        color: VisitedText;
    }
    
    .notification-badge,
    .admin-badge {
        background: Highlight;
        color: HighlightText;
    }
}
