/* TURBOO STORE - Responsive Design Fixes */
/* Ensure smooth experience on all devices */

/* Mobile First - Base Styles */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

img, video {
    max-width: 100%;
    height: auto;
}

/* Fix container overflow */
.container {
    width: 100%;
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1280px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Navigation Responsive Fixes */
@media (max-width: 768px) {
    /* Hide desktop-only navigation items on mobile */
    .top-bar-actions > a:not(:first-child) {
        font-size: 0.75rem;
    }
    
    /* Ensure mobile menu is accessible */
    .mobile-menu {
        width: 100%;
        max-width: 100vw;
    }
    
    /* Fix header overflow */
    header {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    /* Reduce icon size on mobile */
    .flex.items-center.gap-6 {
        gap: 0.5rem;
    }
    
    .flex.items-center.gap-6 a {
        font-size: 1.25rem;
    }
    
    /* Hide some icons on very small screens */
    @media (max-width: 480px) {
        .flex.items-center.gap-6 a:not(:first-child):not(:last-child) {
            display: none;
        }
    }
    
    /* Category menu wrapping */
    .categories-menu {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .categories-menu a {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Top bar responsive */
    .bg-gradient-to-l {
        font-size: 0.7rem;
        padding: 0.5rem 1rem;
    }
    
    .bg-gradient-to-l .flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Grid Responsive Fixes */
@media (max-width: 640px) {
    /* Ensure single column on mobile */
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Product cards - full width on mobile */
    .product-grid > div,
    .game-card,
    .digital-product-card {
        width: 100%;
        margin: 0 auto;
    }
    
    /* Products grid - 1 column on mobile */
    #productsContainer {
        grid-template-columns: 1fr !important;
    }
    
    /* Games grid - 1 column on mobile */
    #gamesGrid {
        grid-template-columns: 1fr !important;
    }
    
    /* Payment methods - 2 columns max on mobile */
    #paymentMethodsContainer {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Category filters - stack on mobile */
    #categoryFilters {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #categoryFilters button {
        width: 100%;
    }
}

/* Tablet Optimizations (640px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    /* 2 columns for products on tablet */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Payment methods - 3 columns on tablet */
    #paymentMethodsContainer {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Form Responsive Fixes */
@media (max-width: 768px) {
    /* Stack form fields on mobile */
    form .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Full width inputs on mobile */
    input, select, textarea {
        width: 100%;
        min-width: 0;
    }
    
    /* Button full width on mobile */
    button[type="submit"] {
        width: 100%;
    }
}

/* Text Responsive Sizes */
@media (max-width: 640px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    
    /* Adjust text in cards */
    .game-card h3 {
        font-size: 1rem;
    }
    
    .digital-product-title {
        font-size: 1rem;
    }
}

/* Container Padding Fixes */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Reduce padding in sections on mobile */
    section {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Table Responsive */
@media (max-width: 768px) {
    /* Make tables scrollable on mobile */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack table rows on very small screens */
    @media (max-width: 480px) {
        thead {
            display: none;
        }
        
        tbody tr {
            display: block;
            margin-bottom: 1rem;
            border: 1px solid #e5e7eb;
            border-radius: 0.5rem;
        }
        
        tbody td {
            display: block;
            text-align: right;
            padding: 0.5rem 1rem;
        }
        
        tbody td::before {
            content: attr(data-label) ": ";
            font-weight: 700;
            float: right;
            margin-left: 0.5rem;
        }
    }
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal {
        width: 95%;
        max-width: 95%;
        margin: 1rem auto;
        padding: 1rem;
    }
    
    /* Full screen modal on mobile */
    @media (max-width: 640px) {
        .modal {
            width: 100%;
            max-width: 100%;
            height: 100vh;
            margin: 0;
            border-radius: 0;
        }
    }
}

/* Hero Section Responsive */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    /* Hero slides */
    .hero-slide {
        padding: 1.5rem 1rem !important;
    }
    
    .hero-slide h1 {
        font-size: 1.75rem !important;
    }
    
    .hero-slide p {
        font-size: 1rem !important;
    }
    
    .hero-slide a {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
    }
}

/* Card Spacing Fixes */
@media (max-width: 640px) {
    /* Reduce gap between cards on mobile */
    .grid.gap-6, .grid.gap-4 {
        gap: 1rem;
    }
    
    /* Reduce padding in cards on mobile */
    .card, .game-card, .digital-product-card {
        padding: 0.75rem;
    }
    
    /* Category cards smaller on mobile */
    .category-card {
        padding: 1rem !important;
    }
    
    .category-card i {
        font-size: 2rem !important;
    }
    
    .category-card h3 {
        font-size: 0.875rem !important;
    }
}

/* Prevent Horizontal Scroll */
body, html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

/* Fix all sections */
section {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Fix all containers */
.container, .max-w-6xl, .max-w-4xl, .max-w-2xl {
    width: 100%;
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container, .max-w-6xl, .max-w-4xl, .max-w-2xl {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Fix RTL on mobile */
[dir="rtl"] {
    direction: rtl;
}

/* Header responsive fixes */
@media (max-width: 768px) {
    /* Top bar - stack on mobile */
    .bg-gradient-to-l .flex {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    /* Navigation - better spacing */
    nav .container {
        padding: 0.75rem 1rem;
    }
    
    /* Logo text smaller on mobile */
    .text-2xl {
        font-size: 1.25rem;
    }
    
    .text-lg {
        font-size: 0.875rem;
    }
}

/* Search bar responsive */
@media (max-width: 640px) {
    #mobileSearchBar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 1rem;
        background: white;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
}

/* Footer responsive */
@media (max-width: 768px) {
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }
    
    footer .text-center {
        text-align: center !important;
    }
}

/* Tables responsive - make scrollable */
@media (max-width: 768px) {
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
    
    table {
        min-width: 600px;
    }
}

/* Forms responsive */
@media (max-width: 640px) {
    /* Stack all form fields */
    .grid.md\\:grid-cols-2,
    .grid.md\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    /* Full width inputs */
    input, select, textarea, button {
        width: 100%;
        max-width: 100%;
    }
    
    /* Better spacing */
    .space-y-4 > * + * {
        margin-top: 1rem;
    }
    
    .space-y-6 > * + * {
        margin-top: 1.5rem;
    }
}

/* Buttons responsive */
@media (max-width: 640px) {
    .flex.gap-2, .flex.gap-4 {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .flex.gap-2 button,
    .flex.gap-4 button {
        width: 100%;
    }
}

/* Images responsive */
@media (max-width: 640px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Product images */
    .w-full.h-48,
    .w-full.h-40 {
        height: 12rem;
    }
}

/* Text responsive */
@media (max-width: 480px) {
    .text-4xl {
        font-size: 1.5rem;
    }
    
    .text-3xl {
        font-size: 1.25rem;
    }
    
    .text-2xl {
        font-size: 1.125rem;
    }
    
    .text-xl {
        font-size: 1rem;
    }
    
    .text-lg {
        font-size: 0.875rem;
    }
}

/* Touch Target Sizes (iOS HIG: 44x44px minimum) */
@media (max-width: 768px) {
    button, a, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Links and buttons padding */
    a, button {
        padding: 0.75rem 1rem;
    }
}

/* Landscape Mobile Fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 1.5rem 1rem;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
}

/* Very Small Screens (320px - 480px) */
@media (max-width: 480px) {
    /* Extra small text adjustments */
    body {
        font-size: 0.875rem;
    }
    
    /* Reduce spacing further */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Stack all elements */
    .flex:not(.flex-row):not(.items-center):not(.justify-between) {
        flex-direction: column;
    }
    
    /* Single column for everything */
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Header adjustments */
    header nav {
        padding: 0.75rem 1rem;
    }
    
    /* Logo smaller on mobile */
    .w-14.h-14 {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    /* Text sizes */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    /* Buttons full width */
    button, .btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }
    
    /* Cards padding */
    .card, .game-card, .bg-white {
        padding: 1rem;
    }
}

/* Large Screens (1920px+) */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
}

/* Ultra Wide Screens (2560px+) */
@media (min-width: 2560px) {
    .container {
        max-width: 2400px;
    }
}

/* Print Styles */
@media print {
    header, footer, nav, .no-print {
        display: none;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: underline;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark Mode Responsive Fixes */
@media (max-width: 768px) {
    .dark .bg-gray-800 {
        background-color: #1f2937;
    }
    
    .dark .text-white {
        color: #f9fafb;
    }
}
