/* Mobile-specific loading and skeleton screens */

/* Skeleton loading animation */
@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 25%,
        var(--gray-100) 50%,
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Skeleton card for listings */
.skeleton-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.skeleton-image {
    width: 100%;
    height: 120px;
    background: linear-gradient(
        90deg,
        var(--gray-200) 25%,
        var(--gray-100) 50%,
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-content {
    padding: 10px;
}

.skeleton-text {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 60%;
}

/* Loading spinner */
.mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

.mobile-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Pull to refresh indicator animation */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.pull-refresh-indicator i {
    animation: bounce 1s ease-in-out infinite;
}

/* Smooth page transitions */
@media (max-width: 480px) {
    .page-enter {
        animation: pageEnter 0.3s ease;
    }
    
    @keyframes pageEnter {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Fade in listings */
    .listing-card {
        animation: fadeInUp 0.4s ease backwards;
    }

    .listing-card:nth-child(1) { animation-delay: 0.05s; }
    .listing-card:nth-child(2) { animation-delay: 0.1s; }
    .listing-card:nth-child(3) { animation-delay: 0.15s; }
    .listing-card:nth-child(4) { animation-delay: 0.2s; }
    .listing-card:nth-child(5) { animation-delay: 0.25s; }
    .listing-card:nth-child(6) { animation-delay: 0.3s; }

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

    /* Smooth transitions for interactive elements */
    button,
    a,
    .listing-card,
    .category-card {
        transition: transform 0.15s ease, opacity 0.15s ease;
    }

    /* Loading state overlay */
    .mobile-loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(4px);
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-loading-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    /* Floating action button for quick actions */
    .mobile-fab {
        position: fixed;
        bottom: 80px;
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 90;
        transition: all 0.3s ease;
    }

    .mobile-fab:active {
        transform: scale(0.9);
    }

    .mobile-fab:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5);
    }

    /* Scroll to top button */
    .scroll-top-btn {
        position: fixed;
        bottom: 80px;
        right: 16px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--surface);
        color: var(--primary);
        border: 2px solid var(--primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        cursor: pointer;
        z-index: 89;
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
        transform: translateY(100px);
    }

    .scroll-top-btn.visible {
        opacity: 1;
        pointer-events: all;
        transform: translateY(0);
    }

    .scroll-top-btn:active {
        transform: scale(0.9);
    }
}

/* Dark mode support for mobile */
@media (max-width: 480px) and (prefers-color-scheme: dark) {
    .mobile-loading-overlay {
        background: rgba(0, 0, 0, 0.9);
    }

    .skeleton {
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%
        );
    }

    .skeleton-image {
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%
        );
    }
}

/* iOS-specific optimizations */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 480px) {
        /* Safe area for iPhone notch */
        .mobile-bottom-nav {
            padding-bottom: env(safe-area-inset-bottom);
        }

        .site-header {
            padding-top: env(safe-area-inset-top);
        }

        /* Prevent rubber band effect */
        body {
            overscroll-behavior-y: contain;
        }
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-bottom-nav {
        padding: 0.25rem 0;
    }

    .mobile-bottom-nav .nav-item span {
        display: none;
    }

    .mobile-bottom-nav .nav-item {
        padding: 0.25rem;
    }
}
