/**
 * Mobile-Optimized Styles
 * Enhanced mobile experience for all devices
 */

/* Mobile-First Base Styles */
@media (max-width: 991px) {
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }
    
    /* Container Adjustments */
    .main-container {
        padding: 20px 16px;
    }
    
    /* Navigation */
    .navigation {
        padding: 12px 16px;
    }
    
    .nav-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-links a {
        padding: 12px 16px;
        width: 100%;
        text-align: left;
    }
    
    /* Cards */
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .card-header h2 {
        font-size: 18px;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        max-width: 100%;
        margin-bottom: 8px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 16px;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 13px;
    }
    
    /* Forum */
    .forum-category {
        padding: 16px;
    }
    
    .forum-category-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .thread-item {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .thread-meta {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    /* Profile */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-stats {
        flex-direction: column;
        gap: 12px;
    }
    
    .stat-item {
        width: 100%;
        padding: 12px;
    }
    
    /* Gallery */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    /* Members */
    .members-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .member-card {
        padding: 12px;
    }
    
    /* Modal */
    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 20px;
    }
    
    /* Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: var(--card-dark);
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }
}

/* Touch-Friendly Interactions */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover,
    .btn:hover,
    a:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .card:active,
    .btn:active,
    a:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Landscape Mobile */
@media (max-width: 991px) and (orientation: landscape) {
    .hero-section {
        min-height: 300px;
    }
    
    .modal-content {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* Small Mobile (< 375px) */
@media (max-width: 374px) {
    body {
        font-size: 13px;
    }
    
    .main-container {
        padding: 16px 12px;
    }
    
    .gallery-grid,
    .members-grid {
        grid-template-columns: 1fr;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Tablet (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .main-container {
        padding: 30px 20px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .members-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .forum-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* PWA Specific Styles */
@media all and (display-mode: standalone) {
    /* Add padding for status bar on iOS */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Hide browser UI elements */
    .browser-only {
        display: none !important;
    }
    
    /* Adjust header for standalone mode */
    .navigation {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}

/* Dark Mode Adjustments for Mobile */
@media (prefers-color-scheme: dark) and (max-width: 991px) {
    /* Ensure good contrast on mobile */
    body {
        background: #000;
    }
    
    .card {
        background: #1a1a1a;
    }
    
    input, textarea, select {
        background: #2a2a2a;
        color: #fff;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 1px solid currentColor;
    }
}

/* Mobile Navigation Enhancements */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

@media (max-width: 991px) {
    .mobile-nav-toggle {
        display: block;
    }
    
    .nav-links {
        display: none;
    }
    
    .nav-links.active {
        display: flex;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--card-dark);
        padding: 20px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        z-index: 999;
    }
}

/* Pull to Refresh Indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-purple);
    color: white;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.pull-to-refresh.active {
    transform: translateY(0);
}

/* Bottom Navigation for Mobile */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-dark);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    padding: 8px 0;
    z-index: 999;
}

@media (max-width: 991px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 11px;
        padding: 8px 12px;
        transition: color 0.2s;
    }
    
    .mobile-bottom-nav a i {
        font-size: 20px;
    }
    
    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:active {
        color: var(--primary-purple);
    }
    
    /* Add padding to body to account for bottom nav */
    body {
        padding-bottom: 70px;
    }
}

/* Loading States for Mobile */
.mobile-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.mobile-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Swipe Gestures */
.swipeable {
    touch-action: pan-y;
    user-select: none;
}

/* Image Optimization for Mobile */
@media (max-width: 991px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .lazy-load {
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .lazy-load.loaded {
        opacity: 1;
    }
}

/* Notification Styles for Mobile */
.mobile-notification {
    position: fixed;
    top: 20px;
    left: 16px;
    right: 16px;
    background: var(--card-dark);
    border-left: 4px solid var(--primary-purple);
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}