/* ============================================
   MOBILE ENHANCEMENTS CSS
   - Bottom Navigation Bar
   - Pull to Refresh
   - Swipe Gestures
   - Loading States
   - Skeleton Loaders
   ============================================ */

/* ========== BOTTOM NAVIGATION BAR ========== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.mobile-bottom-nav-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.7rem;
    padding: 4px 8px;
    transition: all 0.2s;
    flex: 1;
    position: relative;
}

.mobile-nav-item i {
    font-size: 1.3rem;
    margin-bottom: 2px;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

.mobile-nav-badge {
    position: absolute;
    top: 0;
    right: 20%;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 10px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
    }
    
    body {
        padding-bottom: 70px; /* Space for bottom nav */
    }
    
    .mobile-sticky-bar {
        display: none !important; /* Hide old sticky bar */
    }
}

/* Dark mode support */
.dark-mode .mobile-bottom-nav {
    background: #1e293b;
    border-top-color: #334155;
}

.dark-mode .mobile-nav-item {
    color: #94a3b8;
}

.dark-mode .mobile-nav-item.active {
    color: var(--primary);
}

/* ========== PULL TO REFRESH ========== */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 999;
    font-weight: 600;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh i {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== SKELETON LOADERS ========== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.skeleton-title {
    height: 24px;
    width: 80%;
    margin-bottom: 12px;
}

.skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-badge {
    height: 20px;
    width: 80px;
    display: inline-block;
    margin-right: 10px;
}

.skeleton-image {
    height: 200px;
    width: 100%;
    margin-bottom: 15px;
}

/* Dark mode skeleton */
.dark-mode .skeleton {
    background: linear-gradient(90deg, #2d3748 25%, #1a202c 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.dark-mode .skeleton-card {
    background: #1e293b;
}

/* ========== LOADING SPINNER ========== */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-overlay .loading-text {
    margin-top: 15px;
    color: var(--text-main);
    font-weight: 600;
}

.dark-mode .loading-overlay {
    background: rgba(30, 41, 59, 0.95);
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    z-index: 9999;
    transition: width 0.3s;
    box-shadow: 0 0 10px var(--primary);
}

/* ========== LAZY LOAD IMAGES ========== */
img[data-src] {
    filter: blur(5px);
    transition: filter 0.3s;
}

img[data-src].loaded {
    filter: blur(0);
}

.lazy-image-wrapper {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.lazy-image-wrapper::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.lazy-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========== SWIPE INDICATOR ========== */
.swipe-indicator {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    border-radius: 50%;
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 1000;
}

.swipe-indicator.left {
    left: 20px;
}

.swipe-indicator.right {
    right: 20px;
}

.swipe-indicator.visible {
    opacity: 1;
}

/* ========== INFINITE SCROLL LOADER ========== */
.infinite-scroll-loader {
    text-align: center;
    padding: 30px;
    display: none;
}

.infinite-scroll-loader.active {
    display: block;
}

.infinite-scroll-loader .loading-spinner {
    margin: 0 auto;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: transform 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

.toast.info {
    background: #3b82f6;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: #64748b;
    margin-bottom: 10px;
}

/* ========== CARD SHIMMER EFFECT ========== */
.card-shimmer {
    position: relative;
    overflow: hidden;
}

.card-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */
@media (max-width: 768px) {
    /* Hide desktop elements on mobile */
    .top-bar {
        display: none;
    }
    
    .main-header {
        padding: 10px 0;
    }
    
    .main-header .logo h1 {
        font-size: 1.2rem;
    }
    
    .main-header .logo p {
        font-size: 0.75rem;
    }
    
    /* Optimize navigation */
    .main-nav {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    /* Better touch targets */
    .mobile-nav-item {
        min-height: 48px;
        min-width: 48px;
    }
}

/* ========== PULL DOWN ANIMATION ========== */
@keyframes pullDown {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(0); }
}

.pull-down-animation {
    animation: pullDown 0.3s ease-out;
}

/* ========== FADE IN ANIMATION ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* ========== SLIDE UP ANIMATION ========== */
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}
