/* Additional Mobile Fixes and Optimizations */

/* Prevent horizontal scrolling on mobile */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Improve touch scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

/* Fix for mobile Safari viewport issues */
@supports (-webkit-appearance: none) {
    .mobile-safari-fix {
        min-height: -webkit-fill-available;
    }
}

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

/* Apply no-select to buttons and navigation elements */
button, .btn, .mobile-menu-btn, .nav-links a, .mobile-menu-nav a {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Improve tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    -webkit-touch-callout: none;
}
/* Fix for iOS input zoom */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
        transform: translateZ(0);
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* Improve button touch targets */
@media (max-width: 768px) {
    button, .btn, a.btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        margin: 2px;
    }
    
    /* Improve select dropdowns */
    select {
        min-height: 44px;
        padding: 12px 16px;
        background-size: 16px;
        background-position: right 12px center;
    }
}

/* Fix for mobile menu z-index issues */
.mobile-menu-overlay {
    z-index: 9998;
}

.mobile-menu {
    z-index: 9999;
}

/* Improve card interactions on touch devices */
@media (hover: none) and (pointer: coarse) {
    .card-hover {
        transition: none;
    }
    
    .card-hover:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    .card-hover:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Fix for sticky elements on mobile */
@media (max-width: 768px) {
    .sticky {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* Improve form validation styling on mobile */
@media (max-width: 768px) {
    input:invalid {
        border-color: #ef4444;
        box-shadow: 0 0 0 1px #ef4444;
    }
    
    input:valid {
        border-color: #10b981;
    }
}

/* Fix for mobile keyboard issues */
@media (max-width: 768px) {
    .keyboard-fix {
        position: relative;
        z-index: 1;
    }
    
    /* Prevent viewport jumping when keyboard appears */
    .form-container {
        padding-bottom: 50vh;
    }
}

/* Improve loading states on mobile */
@media (max-width: 768px) {
    .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 #6366f1;
        border-radius: 50%;
        border-top-color: transparent;
        animation: spin 1s linear infinite;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fix for mobile navigation active states */
@media (max-width: 768px) {
    .mobile-menu-nav a.active {
        background-color: rgba(99, 102, 241, 0.2);
        color: #6366f1;
    }
    
    .mobile-menu-nav a:active {
        background-color: rgba(99, 102, 241, 0.1);
    }
}

/* Improve mobile search experience */
@media (max-width: 768px) {
    .search-container {
        position: relative;
    }
    
    .search-results {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #1e293b;
        border: 1px solid #334155;
        border-top: none;
        border-radius: 0 0 8px 8px;
        max-height: 300px;
        overflow-y: auto;
        z-index: 1000;
    }
}

/* Fix for mobile modal/overlay issues */
@media (max-width: 768px) {
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.8);
        z-index: 9999;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        position: relative;
        margin: 20px;
        background: #1e293b;
        border-radius: 12px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
}

/* Improve mobile accessibility */
@media (max-width: 768px) {
    /* Larger focus indicators for touch devices */
    button:focus,
    a:focus,
    input:focus,
    select:focus {
        outline: 3px solid #6366f1;
        outline-offset: 2px;
    }
    
    /* Better contrast for mobile */
    .text-gray-400 {
        color: #9ca3af;
    }
    
    .text-gray-500 {
        color: #6b7280;
    }
}
