/**
 * Mobile Responsive Styles
 * Ensures the website is fully mobile-friendly
 */

/* Mobile First Approach */
/* CRITICAL: Override all transform rules from other CSS files */
@media (max-width: 768px) {
    /* Force override any transform rules and hide sidebar by default */
    .ucp-sidebar {
        transform: none !important;
        left: -100% !important;
    }
    
    /* Container adjustments */
    .container {
        padding: 0 15px;
    }

    /* Navbar mobile */
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        text-align: center;
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu a {
        display: block;
        padding: 0.75rem;
        border-radius: 5px;
        background: var(--light);
    }

    /* Mobile menu toggle - show on mobile */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1002;
        background: var(--primary);
        color: white;
        border: none;
        padding: 12px 16px;
        border-radius: 8px;
        font-size: 1.2rem;
        cursor: pointer;
        box-shadow: 0 4px 6px rgba(0,0,0,0.3);
        transition: all 0.3s ease;
        min-width: 44px;
        min-height: 44px;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-toggle:hover {
        background: var(--primary-dark);
        transform: scale(1.05);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    /* Mobile overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .mobile-overlay.active {
        display: block;
    }

    /* UCP Sidebar - Mobile - MUST be hidden by default */
    .ucp-container {
        flex-direction: column;
    }

    /* Hide sidebar by default on mobile - MUST override all other CSS */
    /* Use highest specificity possible */
    html body .ucp-container .ucp-sidebar:not(.mobile-open) {
        width: 280px !important;
        max-width: 85vw !important;
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        height: 100vh !important;
        z-index: 1001 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        box-shadow: 2px 0 15px rgba(0,0,0,0.3) !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
        background: linear-gradient(180deg, #667eea 0%, #764ba2 100%) !important;
        pointer-events: none !important; /* Prevent interaction when hidden */
    }
    
    /* Show sidebar when mobile-open class is added */
    html body .ucp-container .ucp-sidebar.mobile-open {
        width: 280px !important;
        max-width: 85vw !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        z-index: 1001 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        box-shadow: 2px 0 15px rgba(0,0,0,0.3) !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
        background: linear-gradient(180deg, #667eea 0%, #764ba2 100%) !important;
        pointer-events: auto !important; /* Ensure sidebar is clickable when open */
    }
    
    /* Ensure all links and buttons inside open sidebar are clickable */
    html body .ucp-container .ucp-sidebar.mobile-open a,
    html body .ucp-container .ucp-sidebar.mobile-open button,
    html body .ucp-container .ucp-sidebar.mobile-open input,
    html body .ucp-container .ucp-sidebar.mobile-open select,
    html body .ucp-container .ucp-sidebar.mobile-open * {
        pointer-events: auto !important;
        position: relative !important;
    }

    /* Ensure content doesn't have left margin on mobile */
    .ucp-content {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 1rem !important;
        padding-top: 70px !important; /* Space for mobile menu button */
    }
    
    /* Ensure main content area is full width */
    .ucp-main {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--primary);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        font-size: 1.2rem;
        cursor: pointer;
        box-shadow: var(--shadow);
    }

    /* Overlay when menu is open */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Dashboard adjustments */
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
    }

    .user-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Games grid */
    .games-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .game-card {
        width: 100%;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100%;
    }

    /* Tables - make scrollable */
    .sessions-table,
    .transactions-table {
        overflow-x: auto;
        display: block;
    }

    .sessions-table table,
    .transactions-table table {
        min-width: 600px;
    }

    /* Cards */
    .ucp-card {
        margin-bottom: 1rem;
    }

    .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    /* Buttons */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group {
        flex-direction: column;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    footer {
        text-align: center;
        padding: 1rem;
    }

    /* Auth forms */
    .auth-form {
        padding: 1.5rem;
    }

    /* Text sizes */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .user-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .ucp-sidebar {
        width: 250px;
    }

    .ucp-content {
        margin-left: 250px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .ucp-content {
        padding: 0.5rem;
    }

    .auth-form {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .ucp-sidebar {
        width: 300px;
    }
}

/* Touch-friendly elements */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-menu a,
    .sidebar-nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    input,
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Hide mobile menu toggle on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-overlay {
        display: none !important;
    }
    
    .ucp-sidebar {
        left: 0 !important;
    }
}

/* Print styles */
@media print {
    .ucp-sidebar,
    .mobile-menu-toggle,
    .navbar,
    .btn {
        display: none;
    }

    .ucp-content {
        margin-left: 0;
        width: 100%;
    }
}

