/* Mobile Layout Fixes and Improvements */

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .form-control, .btn, input, textarea {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0.375rem;
    }
    
    /* Fix for sticky hover states on iOS */
    .btn:hover {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .form-control:focus {
        border-color: #059669;
        box-shadow: 0 0 0 0.2rem rgba(5, 150, 105, 0.25);
    }
}

/* Touch scrolling improvements */
.mobile-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Mobile offcanvas improvements */
.offcanvas-backdrop {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Improved mobile buttons */
.mobile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active {
    transform: scale(0.98);
}

/* Mobile card improvements */
.mobile-card {
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile navigation improvements */
.mobile-nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:active {
    background-color: rgba(5, 150, 105, 0.1);
}

/* Safe area insets for modern phones */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .container, .container-fluid {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .modal-dialog {
        margin-left: max(0.5rem, env(safe-area-inset-left));
        margin-right: max(0.5rem, env(safe-area-inset-right));
    }
}

/* Improved focus states for accessibility */
.btn:focus,
.form-control:focus,
.nav-link:focus {
    outline: 2px solid #059669;
    outline-offset: 2px;
}

/* Loading states for better UX */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #059669;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Better mobile typography */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.5;
    }
    
    .small {
        font-size: 14px;
    }
    
    .lead {
        font-size: 18px;
    }
    
    /* Better spacing for mobile */
    .mb-mobile {
        margin-bottom: 1rem !important;
    }
    
    .mt-mobile {
        margin-top: 1rem !important;
    }
    
    .px-mobile {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-mobile {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

.container-fluid,
.row {
    max-width: 100%;
}

/* Improved mobile form layouts */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .input-group {
        flex-wrap: nowrap;
    }
    
    .input-group .form-control {
        min-width: 0;
    }
}

/* Mobile-specific utilities */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    .mobile-flex {
        display: flex !important;
    }
    
    .mobile-block {
        display: block !important;
    }
    
    .mobile-inline {
        display: inline !important;
    }
    
    .mobile-inline-block {
        display: inline-block !important;
    }
}