/* Mobile and Cross-Browser Optimization for The Flock */
/* Comprehensive responsive design improvements */

/* Enhanced Viewport and Touch Support */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: contain;
}

/* Improved Touch Targets */
.btn, .nav-link, .dropdown-item, .card-clickable {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced Mobile Navigation */
@media (max-width: 991.98px) {
    .navbar-nav {
        background: white;
        border-radius: 12px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        margin-top: 1rem;
        padding: 1rem;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1rem;
        border-radius: 8px;
        width: 100%;
    }
    
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 0 1rem;
    }
}

/* Mobile-First Dashboard Layout */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .dashboard-widget {
        margin-bottom: 1.5rem;
    }
    
    .widget-header {
        padding: 1rem;
    }
    
    .widget-content {
        padding: 1rem;
    }
    
    /* Stack dashboard cards on mobile */
    .row .col-lg-4,
    .row .col-lg-6,
    .row .col-lg-8 {
        margin-bottom: 1rem;
    }
    
    /* Larger touch targets for mobile */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Mobile-friendly tables */
    .table-responsive {
        border: none;
    }
    
    .table td {
        padding: 1rem 0.5rem;
        vertical-align: middle;
    }
    
    /* Hide less important columns on mobile */
    .table .d-none.d-md-table-cell {
        display: none !important;
    }
}

/* Tablet Optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .dashboard-widget {
        height: auto;
        min-height: 200px;
    }
    
    .widget-content {
        padding: 1.5rem;
    }
}

/* Small Mobile Devices */
@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .brand-text {
        display: none;
    }
    
    .brand-icon {
        width: 32px;
        height: 32px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .dashboard-widget {
        border-radius: 12px;
        margin-bottom: 1rem;
    }
    
    .widget-value {
        font-size: 1.75rem;
    }
    
    .widget-label {
        font-size: 0.875rem;
    }
    
    /* Single column layout for very small screens */
    .col-lg-4,
    .col-lg-6,
    .col-lg-8,
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Improved form inputs */
    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* Better modal sizing */
    .modal-dialog {
        margin: 1rem;
    }
    
    .modal-content {
        border-radius: 12px;
    }
}

/* Large Mobile Devices */
@media (min-width: 576px) and (max-width: 767px) {
    .row .col-lg-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .dashboard-widget {
        margin-bottom: 1.5rem;
    }
}

/* Cross-Browser Font Optimization */
@supports (font-variation-settings: normal) {
    body {
        font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    }
}

/* Safari iOS Specific Fixes */
/* DISABLED - This was causing ALL elements to be unclickable by setting body to position: fixed */
/*
@supports (-webkit-touch-callout: none) {
    .navbar {
        -webkit-backdrop-filter: blur(10px);
    }
    
    .dropdown-menu {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    body {
        position: fixed;
        overflow: hidden;
        width: 100%;
        height: 100%;
    }
    
    #main-content {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
*/

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .card {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    
    .navbar {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    }
    
    .text-muted {
        color: #94a3b8 !important;
    }
}

/* 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 */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000080;
        border-color: #000080;
    }
    
    .text-primary {
        color: #000080 !important;
    }
    
    .card {
        border: 2px solid #000;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .notification-badge,
    .admin-indicator {
        display: none !important;
    }
    
    .container-fluid {
        padding: 0;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        break-inside: avoid;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}

/* Landscape Mobile Optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 0.25rem 0;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .user-avatar {
        width: 24px;
        height: 24px;
    }
    
    .dashboard-widget {
        padding: 0.75rem;
    }
    
    .widget-value {
        font-size: 1.5rem;
    }
}

/* Enhanced Focus States for Accessibility */
.btn:focus,
.nav-link:focus,
.form-control:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

/* Sticky Elements Optimization */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    will-change: transform;
}

/* Performance Optimizations */
.card,
.btn,
.dropdown-menu {
    will-change: transform;
    backface-visibility: hidden;
}

/* Smooth Scrolling for Supported Browsers */
html {
    scroll-behavior: smooth;
}

/* Enhanced Loading States */
.loading-text {
    position: relative;
    color: transparent;
}

.loading-text::after {
    content: 'Loading...';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: currentColor;
    animation: pulse 1.5s infinite;
}

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