/* =================================== */
/* MOBILE ENHANCEMENTS - Only applies on mobile */
/* =================================== */

/* CSS Custom Properties with fallbacks */
:root {
    --vh: 1vh; /* Fallback for browsers that don't support custom properties */
}

/* Only apply these base styles on mobile devices */
@media (max-width: 768px) {
    /* Mobile-specific base styles */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        /* Use custom --vh or fallback to standard vh */
        height: 100vh; /* Fallback */
        height: calc(var(--vh, 1vh) * 100);
    }

    /* Preserve desktop box-sizing, only enhance mobile */
    * {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
        tap-highlight-color: rgba(59, 130, 246, 0.2);
    }
}

/* Desktop-first approach - ensure desktop styles work unchanged */

/* =================================== */
/* MOBILE NAVIGATION ENHANCEMENTS */
/* =================================== */

/* Only enhance navigation on mobile */
@media (max-width: 576px) {  /* Changed from 768px to 576px to match Bootstrap's sm breakpoint */
    /* Mobile navigation enhancements */
    .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
    }

    .navbar-toggler:focus {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    }

    /* Mobile brand text shortening */
    .navbar-brand {
        max-width: 70%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Enhanced mobile dropdown */
    .navbar-nav .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Ensure navbar text is visible on mobile */
    .navbar .nav-link span:not(.d-none) {
        display: inline !important;
    }
}

/* Keep desktop navigation unchanged */

/* =================================== */
/* MOBILE LAYOUT ENHANCEMENTS */
/* =================================== */

/* Only apply mobile layout enhancements */
@media (max-width: 768px) {
    /* Enhanced mobile containers */
    .container, .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Enhanced mobile cards */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
    }

    .card-body {
        padding: 1rem !important;
    }
}

/* Desktop layout unchanged */

/* =================================== */
/* MOBILE CARD ENHANCEMENTS */
/* =================================== */

/* Only enhance cards on mobile */
@media (max-width: 768px) {
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Enhanced mobile card interactions */
    .card.hover-card {
        transition: transform 0.2s ease;
    }

    .card.hover-card:active {
        transform: scale(0.98);
    }
}

/* Desktop cards unchanged */

/* =================================== */
/* MOBILE BUTTON ENHANCEMENTS */
/* =================================== */

/* Only enhance buttons on mobile */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        min-width: 44px;
        font-size: 1rem;
        padding: 0.75rem 1rem;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:focus {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
    }

    /* Enhanced mobile button interactions */
    .btn:active {
        transform: scale(0.98);
    }
}

/* Desktop buttons unchanged */

/* =================================== */
/* MOBILE FORM ENHANCEMENTS */
/* =================================== */

/* Only enhance forms on mobile */
@media (max-width: 768px) {
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.75rem 1rem;
    }

    .form-control:focus, .form-select:focus {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    }

    .form-label {
        font-weight: 500;
    }
}

/* Desktop forms unchanged */

/* =================================== */
/* MOBILE TABLE ENHANCEMENTS */
/* =================================== */

/* Only enhance tables on mobile */
@media (max-width: 768px) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        min-height: 44px;
    }

    .table th {
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

/* Desktop tables unchanged */

/* =================================== */
/* MOBILE MODAL ENHANCEMENTS */
/* =================================== */

/* Only enhance modals on mobile */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Desktop modals unchanged */

/* =================================== */
/* MOBILE UTILITIES */
/* =================================== */

/* Spacing utilities */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 1rem !important; }
.pt-4 { padding-top: 1.5rem !important; }
.pt-5 { padding-top: 3rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 1rem !important; }
.pb-4 { padding-bottom: 1.5rem !important; }
.pb-5 { padding-bottom: 3rem !important; }

/* Text utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.text-primary { color: #3b82f6 !important; }
.text-success { color: #10b981 !important; }
.text-warning { color: #f59e0b !important; }
.text-danger { color: #ef4444 !important; }
.text-muted { color: rgba(255, 255, 255, 0.6) !important; }

/* Display utilities - Only apply on mobile to avoid overriding Bootstrap responsive classes */
/* Removed conflicting display utilities that override Bootstrap's responsive system */

/* Flex utilities */
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }

.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }

/* =================================== */
/* MOBILE RESPONSIVE BREAKPOINTS */
/* =================================== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
    
    .col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-sm-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
    
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    .col-lg-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    
    .col-lg-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-lg-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
    
    .col-lg-9 {
        flex: 0 0 75%;
        max-width: 75%;
    }
    
    .col-lg-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* =================================== */
/* MOBILE TOUCH OPTIMIZATIONS */
/* =================================== */

/* Touch-friendly card interactions */
.touch-card {
    position: relative;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
    tap-highlight-color: rgba(59, 130, 246, 0.2);
}

.touch-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.touch-card[data-href] {
    cursor: pointer;
}

/* Enhanced touch feedback */
@media (hover: none) and (pointer: coarse) {
    .touch-card:hover {
        transform: none;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
}

/* Mobile swipe gestures support */
.swipe-container {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on touch */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Enhanced mobile buttons */
.btn-mobile {
    min-height: 48px;
    min-width: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Mobile modal enhancements */
.modal-mobile {
    margin: 0;
    width: 100%;
    height: 100vh;
    max-width: none;
    border-radius: 0;
}

/* Mobile form enhancements */
.form-mobile .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 16px;
    min-height: 48px;
}

/* Mobile table enhancements */
.table-mobile {
    font-size: 14px;
}

.table-mobile th,
.table-mobile td {
    padding: 12px 8px;
    min-height: 48px;
}

/* Mobile navigation enhancements */
.navbar-mobile .navbar-toggler {
    border: none;
    padding: 12px;
    min-height: 48px;
    min-width: 48px;
}

/* Pull-to-refresh indicator */
.pull-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pull-refresh-indicator.show {
    opacity: 1;
}

/* =================================== */
/* MOBILE VISUAL ENHANCEMENTS */
/* =================================== */

/* Touch-active state for interactive elements */
.touch-active {
    transform: scale(0.98) !important;
    transition: transform 0.1s ease;
}

.btn-touch-active {
    transform: scale(0.95) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Mobile-optimized focus states */
@media (max-width: 768px) {
    .btn:focus,
    .form-control:focus,
    .touch-card:focus {
        outline: 3px solid rgba(59, 130, 246, 0.5);
        outline-offset: 2px;
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2);
    }
}

/* Enhanced mobile card shadows */
@media (max-width: 768px) {
    .card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: box-shadow 0.2s ease;
    }

    .card:active,
    .card.touch-active {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
}

/* Mobile loading states */
.mobile-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.mobile-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Mobile swipe indicators */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.swipe-indicator.show {
    opacity: 0.7;
}

.swipe-indicator.left {
    left: 10px;
}

.swipe-indicator.right {
    right: 10px;
}

.swipe-indicator::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translateX(-50%);
}

/* Mobile viewport height fix */
.vh-fix {
    height: calc(var(--vh, 1vh) * 100);
}

/* Mobile scroll optimizations */
.mobile-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* Enhanced mobile typography */
@media (max-width: 768px) {
    .mobile-heading {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
        line-height: 1.2;
        letter-spacing: -0.02em;
    }

    .mobile-subheading {
        font-size: clamp(1rem, 3vw, 1.25rem);
        line-height: 1.4;
    }

    .mobile-text {
        font-size: clamp(0.9rem, 2.5vw, 1rem);
        line-height: 1.5;
    }
}

/* Mobile-optimized animations */
@media (prefers-reduced-motion: no-preference) and (max-width: 768px) {
    .mobile-fade-in {
        animation: mobileFadeIn 0.3s ease-out;
    }

    .mobile-slide-up {
        animation: mobileSlideUp 0.4s ease-out;
    }
}

@keyframes mobileFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes mobileSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile-optimized gradients */
.mobile-gradient {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 197, 253, 0.1) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Enhanced mobile button styles */
@media (max-width: 768px) {
    .btn-mobile-enhanced {
        position: relative;
        overflow: hidden;
        background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        border: none;
        color: white;
        font-weight: 600;
        text-transform: none;
        letter-spacing: 0.5px;
        transition: all 0.2s ease;
    }

    .btn-mobile-enhanced::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s ease;
    }

    .btn-mobile-enhanced:hover::before {
        left: 100%;
    }

    .btn-mobile-enhanced:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    }
}

/* Touch-friendly button sizes */
@media (max-width: 768px) {
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: 0.875rem 1.75rem;
        font-size: 1.1rem;
    }
    
    .form-control {
        min-height: 48px;
        font-size: 1.1rem;
    }
    
    .navbar-toggler {
        min-height: 48px;
        min-width: 48px;
    }
}

/* Touch-friendly spacing */
@media (max-width: 768px) {
    .card {
        padding: 1.75rem;
        margin-bottom: 1.5rem;
    }
    
    .modal-body {
        padding: 1.75rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1.25rem 1.5rem;
        margin-bottom: 0.5rem;
    }
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border-width: 2px;
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .btn {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .card {
        background: rgba(0, 0, 0, 0.8);
        border-color: rgba(255, 255, 255, 0.2);
    }
}

/* =================================== */
/* MOBILE ACCESSIBILITY */
/* =================================== */

/* Focus indicators */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #3b82f6;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}
