/* Desktop Grid Fix - Ensure 4 columns 2 rows layout */

/* Desktop only - override mobile scroll CSS */
@media (min-width: 769px) {
    /* Reset numbers grid to proper Bootstrap grid */
    #numbers-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow: visible !important;
        scroll-behavior: auto !important;
        gap: 1.5rem !important;
        padding: 0 !important;
        margin: 0 !important;
        -webkit-overflow-scrolling: auto !important;
        scroll-snap-type: none !important;
        touch-action: auto !important;
    }
    
    /* Ensure proper Bootstrap column behavior */
    #numbers-grid .col-lg-3,
    #numbers-grid .col-md-6,
    #numbers-grid .col-sm-6 {
        flex: 0 0 calc(25% - 1.125rem) !important; /* 4 columns with gap */
        max-width: calc(25% - 1.125rem) !important;
        width: auto !important;
        margin: 0 !important;
        scroll-snap-align: none !important;
    }
    
    /* Alternative approach - use CSS Grid for precise control */
    .desktop-grid-4x2 #numbers-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        grid-template-rows: repeat(2, auto) !important;
        gap: 1.5rem !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .desktop-grid-4x2 #numbers-grid .col-lg-3,
    .desktop-grid-4x2 #numbers-grid .col-md-6,
    .desktop-grid-4x2 #numbers-grid .col-sm-6 {
        flex: none !important;
        max-width: none !important;
        width: auto !important;
        margin: 0 !important;
    }
    
    /* Hide mobile elements on desktop */
    #mobile-loading {
        display: none !important;
    }
    
    .universal-scroll-hint {
        display: none !important;
    }
    
    /* Show pagination on desktop */
    #pagination-container {
        display: flex !important;
        justify-content: center !important;
        margin-top: 2rem !important;
    }
    
    /* Ensure cards have proper height */
    #numbers-grid .number-card-glass {
        height: auto !important;
        min-height: 320px !important;
        max-height: none !important;
    }
    
    /* Override any mobile-specific card styling */
    #numbers-grid .number-card-glass {
        padding: 1.5rem !important;
        border-radius: 20px !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    /* Ensure proper button layout */
    #numbers-grid .d-flex.gap-2 {
        gap: 0.5rem !important;
        margin-top: auto !important;
    }
    
    #numbers-grid .btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        white-space: nowrap !important;
    }
}

/* Large desktop - ensure proper spacing */
@media (min-width: 1200px) {
    #numbers-grid {
        gap: 2rem !important;
    }
    
    #numbers-grid .col-lg-3 {
        flex: 0 0 calc(25% - 1.5rem) !important;
        max-width: calc(25% - 1.5rem) !important;
    }
    
    .desktop-grid-4x2 #numbers-grid {
        gap: 2rem !important;
    }
}

/* Medium desktop - adjust for smaller screens */
@media (min-width: 769px) and (max-width: 991px) {
    #numbers-grid .col-lg-3 {
        flex: 0 0 calc(25% - 1rem) !important;
        max-width: calc(25% - 1rem) !important;
    }
    
    #numbers-grid {
        gap: 1rem !important;
    }
    
    .desktop-grid-4x2 #numbers-grid {
        gap: 1rem !important;
    }
}

/* Force 4x2 grid layout class */
.force-4x2-grid #numbers-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: repeat(2, auto) !important;
    gap: 1.5rem !important;
}

.force-4x2-grid #numbers-grid > * {
    grid-column: auto !important;
    grid-row: auto !important;
}

/* Debug helper - show grid lines */
.debug-grid #numbers-grid {
    border: 2px dashed #007bff;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent calc(25% - 1px),
        #007bff calc(25% - 1px),
        #007bff 25%
    );
}

.debug-grid #numbers-grid .col-lg-3 {
    border: 1px solid #dc3545;
    background: rgba(220, 53, 69, 0.1);
}