/* ===================================
   🎨 PROFESSIONAL HOME PAGE DESIGN
   ✨ Responsive | Modern | Fast
   =================================== */

/* ========== MOBILE RESPONSIVENESS FIX ========== */
* {
    box-sizing: border-box;
}

.pro-layout,
.pro-layout .main-content,
.pro-layout .games-grid,
.pro-layout .container,
.pro-layout .row {
    max-width: 100%;
    overflow-x: hidden;
}

/* ========== ROOT VARIABLES ========== */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #1a1625;
    --sidebar-hover: #2a2235;
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-hover: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --transition-speed: 0.3s;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ========== SIDEBAR TOGGLE BUTTON (MOBILE) ========== */
.sidebar-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    display: none; /* Hidden on desktop */
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.sidebar-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

/* ========== MAIN LAYOUT ========== */
.pro-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ========== CATEGORIES SIDEBAR ========== */
.categories-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-speed) ease;
}

/* Custom Scrollbar for Sidebar */
.categories-sidebar::-webkit-scrollbar {
    width: 6px;
}

.categories-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.categories-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.categories-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar Header */
.sidebar-header {
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    padding: 25px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.sidebar-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.sidebar-close {
    display: none; /* Hidden on desktop */
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: background var(--transition-speed);
}

.sidebar-close:hover {
    background: var(--sidebar-hover);
}

/* Sidebar Content */
.sidebar-content {
    padding: 10px;
}

/* Categories List */
.categories-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 4px;
}

.category-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.category-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform var(--transition-speed);
}

.category-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    transform: translateX(5px);
}

.category-link:hover::before {
    transform: scaleY(1);
}

.category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border-radius: 8px;
    flex-shrink: 0;
    transition: all var(--transition-speed);
}

.category-link:hover .category-icon {
    background: var(--primary-color);
    transform: rotate(5deg);
}

.category-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.category-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.category-name {
    font-size: 14px;
    font-weight: 600;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px 0;
    transition: margin-left var(--transition-speed);
}

.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== GAMES SECTIONS ========== */
.games-section {
    margin-bottom: 50px;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.title-icon {
    font-size: 32px;
}

.view-all-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-speed);
}

.view-all-link:hover {
    color: var(--primary-hover);
    gap: 10px;
}

/* Section Controls (Slider Buttons) */
.section-controls {
    display: flex;
    gap: 10px;
}

.slider-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
}

.slider-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.slider-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: scale(1);
}

/* ========== GAMES SLIDER (Trending/Featured) ========== */
.games-slider {
    position: relative;
    overflow: hidden;
    margin: 0 -10px;
    padding: 0 10px;
}

.slider-track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 10px;
}

.slider-track::-webkit-scrollbar {
    display: none;
}

/* Featured Card (Larger, for trending) */
.featured-card {
    min-width: 280px;
    max-width: 280px;
}

.featured-card .card-image {
    height: 360px;
}

/* ========== GAMES GRID ========== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.games-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 25px;
}

/* ========== GAME CARDS ========== */
.game-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all var(--transition-speed);
    position: relative;
}

.game-card:hover {
    background: var(--card-hover);
    transform: translateY(-8px);
    box-shadow: var(--box-shadow);
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Card Image */
.card-image {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1625, #2a2235);
}

.card-image-large {
    position: relative;
    width: 100%;
    height: 320px;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1625, #2a2235);
}

.game-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-speed);
}

.game-card:hover .game-thumb {
    transform: scale(1.1);
}

/* Card Overlay */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.game-card:hover .card-overlay {
    opacity: 1;
}

/* Play Button */
.play-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.8);
    transition: all var(--transition-speed);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.5);
}

.game-card:hover .play-button {
    transform: scale(1);
}

.play-button-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.8);
    transition: all var(--transition-speed);
}

.game-card:hover .play-button-small {
    transform: scale(1);
}

/* Game Badge */
.game-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    backdrop-filter: blur(10px);
    z-index: 2;
}

.hot-badge {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
}

.new-badge {
    background: linear-gradient(135deg, #51cf66, #37b24d);
    color: white;
}

/* Card Content */
.card-content {
    padding: 15px;
}

.card-content-compact {
    padding: 12px;
}

.card-content-large {
    padding: 18px;
}

/* Game Title */
.game-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-title-compact {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-title-large {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Game Meta */
.game-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.game-meta-compact {
    font-size: 12px;
}

.game-meta-large {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.game-rating,
.game-rating-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.game-plays {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.game-category {
    padding: 4px 10px;
    background: var(--card-bg);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== LOAD MORE SECTION ========== */
.load-more-section {
    text-align: center;
    margin: 40px 0;
}

.btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-load-more:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-load-more:active {
    transform: scale(0.95);
}

.btn-load-more svg {
    transition: transform var(--transition-speed);
}

.btn-load-more:hover svg {
    transform: translateY(3px);
}

/* Loading State */
.btn-load-more.loading {
    opacity: 0.7;
    cursor: wait;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Tablet */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 240px;
    }
    
    .categories-sidebar {
        width: 240px;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .games-grid-large {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .section-title {
        font-size: 24px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Show sidebar toggle button */
    .sidebar-toggle {
        display: flex;
    }
    
    /* Hide sidebar by default */
    .categories-sidebar {
        transform: translateX(-100%);
    }
    
    .categories-sidebar.active {
        transform: translateX(0);
    }
    
    /* Show close button in sidebar */
    .sidebar-close {
        display: block;
    }
    
    /* Show overlay when sidebar is open */
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Remove sidebar margin from main content */
    .main-content {
        margin-left: 0;
        padding: 20px 0 80px 0; /* Extra bottom padding for toggle button */
    }
    
    .container-fluid {
        padding: 0 15px;
    }
    
    /* Adjust sections */
    .games-section {
        margin-bottom: 35px;
    }
    
    .section-header {
        flex-wrap: wrap;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .section-title {
        font-size: 22px;
    }
    
    .title-icon {
        font-size: 26px;
    }
    
    /* Adjust grids for mobile */
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .games-grid-large {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    /* Adjust slider */
    .featured-card {
        min-width: 240px;
        max-width: 240px;
    }
    
    .featured-card .card-image {
        height: 300px;
    }
    
    /* Adjust card heights */
    .card-image {
        height: 180px;
    }
    
    .card-image-large {
        height: 220px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    /* Extra mobile overflow protection */
    body, html {
        overflow-x: hidden !important;
    }
    
    .main-content {
        padding: 10px 5px 80px 5px;
    }
    
    .container-fluid {
        padding: 0 10px;
    }
    
    .section-title {
        font-size: 20px;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .games-grid-large {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .featured-card {
        min-width: 200px;
        max-width: 200px;
    }
    
    .featured-card .card-image {
        height: 260px;
    }
    
    .card-image {
        height: 160px;
    }
    
    .card-image-large {
        height: 180px;
    }
    
    .btn-load-more {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .sidebar-toggle {
        bottom: 15px;
        left: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* ✅ Better card text sizing for mobile */
    .game-title {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .game-meta {
        font-size: 11px;
        gap: 8px;
    }
    
    .card-content {
        padding: 12px;
    }
}

/* ✅ Ultra Small Screens */
@media (max-width: 360px) {
    .games-grid,
    .games-grid-large {
        gap: 8px;
    }
    
    .game-title {
        font-size: 13px;
    }
    
    .game-meta {
        font-size: 10px;
    }
    
    .main-content {
        padding: 10px;
    }
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* GPU Acceleration for smooth animations */
.game-card,
.category-link,
.sidebar-toggle,
.btn-load-more {
    will-change: transform;
}

/* Optimize font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}