/* Mobile Optimizations for PHP Auth System v1.0.0 */

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    /* Mobile Navigation */
    .navbar {
        padding: 0.5rem 1rem;
        min-height: 60px;
    }

    .navbar-brand {
        font-size: 1.2rem;
        margin-right: auto;
    }

    .navbar-toggler {
        border: none;
        padding: 0.5rem;
    }

    .navbar-toggler:focus {
        box-shadow: none;
    }

    .navbar-collapse {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        padding: 2rem 1rem;
        z-index: 1050;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .navbar-collapse.show {
        transform: translateX(0);
    }

    .navbar-nav {
        flex-direction: column;
        gap: 1rem;
    }

    .navbar-nav .nav-link {
        padding: 1rem 0;
        font-size: 1.1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }

    /* Mobile Cards */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
    }

    .card-body {
        padding: 1.5rem 1rem;
    }

    /* Mobile Forms */
    .form-container {
        max-width: 100%;
        padding: 0 1rem;
    }

    .form-floating > .form-control,
    .form-floating > .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem 0.75rem;
    }

    .form-floating > label {
        padding: 1rem 0.75rem;
        font-size: 0.9rem;
    }

    .btn {
        min-height: 48px; /* Minimum touch target */
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        margin-bottom: 0.25rem;
    }

    /* Mobile Tables */
    .table-responsive {
        border-radius: 12px;
        margin: -1rem;
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.9rem;
    }

    .table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .table td,
    .table th {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Mobile Dashboard */
    .dashboard-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .stat-item {
        padding: 1.5rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        text-align: center;
    }

    .stat-value {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    /* Mobile Modals */
    .modal {
        padding: 1rem;
    }

    .modal-dialog {
        margin: 0;
        max-width: none;
        width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
    }

    .modal-content {
        border-radius: 16px;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-body {
        padding: 1.5rem;
    }

    /* Mobile Alerts */
    .alert {
        margin-bottom: 1rem;
        border-radius: 12px;
        padding: 1rem;
    }

    /* Mobile Tabs */
    .nav-tabs {
        flex-direction: column;
        background: transparent;
        padding: 0;
        gap: 0.5rem;
    }

    .nav-tabs .nav-link {
        border-radius: 8px;
        margin-bottom: 0.25rem;
    }

    /* Mobile Pagination */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
        margin: 0.125rem;
        min-width: 40px;
    }

    /* Mobile Dropdowns */
    .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
        box-shadow: none;
        border: 1px solid rgba(0, 0, 0, 0.1);
    }

    .dropdown-item {
        padding: 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .dropdown-item:last-child {
        border-bottom: none;
    }
}

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    .card {
        margin-bottom: 1.5rem;
    }

    .btn-group {
        flex-wrap: wrap;
    }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Touch targets for mobile */
    .btn,
    .nav-link,
    .dropdown-item,
    .form-control,
    .form-select {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .hover-lift:hover {
        transform: none;
    }

    .card:hover {
        transform: none;
        box-shadow: var(--shadow-light);
    }

    .btn:hover {
        transform: none;
    }

    /* Touch feedback */
    .btn:active,
    .nav-link:active,
    .card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    .card,
    .btn,
    .alert {
        transition: none;
    }

    /* Optimize images for mobile */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Reduce shadow complexity on mobile */
    .card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }

    /* Optimize typography for mobile reading */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }

    /* Mobile-specific spacing */
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }

    .col,
    [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Mobile Navigation Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile Swipe Gestures Support */
@media (max-width: 768px) {
    .swipe-container {
        touch-action: pan-y;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .swipe-container::-webkit-scrollbar {
        display: none;
    }

    .swipe-item {
        scroll-snap-align: start;
        flex-shrink: 0;
        width: 100%;
    }

    /* Mobile gesture hints */
    .swipe-hint {
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        font-size: 0.875rem;
        opacity: 0;
        animation: fadeInOut 3s ease-in-out;
    }

    @keyframes fadeInOut {
        0%, 100% { opacity: 0; }
        20%, 80% { opacity: 1; }
    }
}

/* Mobile Keyboard Optimizations */
@media (max-width: 768px) {
    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Mobile keyboard optimizations */
    .mobile-keyboard-optimized {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        border-top: 1px solid #dee2e6;
        z-index: 1060;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .mobile-keyboard-optimized.show {
        transform: translateY(0);
    }
}

/* Mobile Loading States */
@media (max-width: 768px) {
    .mobile-loading {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.9);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1070;
    }

    .mobile-spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #667eea;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
}

/* Mobile Accessibility Enhancements */
@media (max-width: 768px) {
    /* Larger touch targets for accessibility */
    .accessibility-touch-target {
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* High contrast mode for mobile */
    @media (prefers-contrast: high) {
        .card {
            border: 3px solid #000;
        }

        .btn {
            border: 3px solid currentColor;
        }

        .form-control {
            border: 3px solid #000;
        }
    }

    /* Reduced motion for accessibility */
    @media (prefers-reduced-motion: reduce) {
        .mobile-nav-overlay,
        .navbar-collapse,
        .modal,
        .mobile-keyboard-optimized {
            transition: none;
        }

        .swipe-hint {
            animation: none;
        }
    }
}

/* Mobile PWA Support */
@media (max-width: 768px) {
    .pwa-install-prompt {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--primary-gradient);
        color: white;
        padding: 1rem;
        text-align: center;
        z-index: 1050;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .pwa-install-prompt.show {
        transform: translateY(0);
    }

    .pwa-install-prompt .btn {
        margin: 0.5rem;
        min-width: 120px;
    }
}

/* Mobile Offline Support */
@media (max-width: 768px) {
    .offline-indicator {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: #dc3545;
        color: white;
        padding: 0.5rem 1rem;
        text-align: center;
        font-size: 0.9rem;
        z-index: 1040;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
    }

    .offline-indicator.show {
        transform: translateY(0);
    }
}

/* Mobile Network Status */
@media (max-width: 768px) {
    .network-status {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: #ffc107;
        color: #000;
        padding: 0.25rem 1rem;
        text-align: center;
        font-size: 0.8rem;
        z-index: 1030;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
    }

    .network-status.show {
        transform: translateY(0);
    }

    .network-status.slow {
        background: #fd7e14;
    }

    .network-status.offline {
        background: #dc3545;
        color: white;
    }
}
