/**
 * Site-Wide Fixes and Improvements
 * Comprehensive CSS fixes for better UX
 */

/* ========================================
   SIDEBAR FIXES
   ======================================== */

/* Sidebar stays fixed on screen while scrolling, but with hidden scrollbar */
.sidebar {
    position: fixed !important;  /* Keep sidebar fixed on screen */
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateX(0);
    transition: transform var(--transition-normal);
    overflow-y: auto !important; /* Allow scrolling but hide scrollbar */
    overflow-x: hidden;
    box-shadow: var(--shadow-xl);
    padding-bottom: 2rem;
    /* Hide scrollbar for all browsers */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for webkit browsers (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    display: none;
    width: 0px;
    height: 0px;
    background: transparent;
}

/* Ensure sidebar content is scrollable even without visible scrollbar */
.sidebar-nav {
    height: auto !important;
    overflow-y: visible !important;
}

/* ========================================
   MAIN CONTENT ADJUSTMENTS
   ======================================== */

/* Adjust main content to account for absolute positioned sidebar */
.main-content {
    margin-left: 280px;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
    position: relative;
}

/* ========================================
   MOBILE SIDEBAR FIX
   ======================================== */

@media (max-width: 768px) {
    /* On mobile, sidebar should be fixed and off-screen by default */
    .sidebar {
        position: fixed !important;
        height: 100vh !important;
        min-height: 100vh;
        overflow-y: auto !important;
        transform: translateX(-100%);
    }

    /* Show sidebar when active */
    .sidebar.active {
        transform: translateX(0);
    }

    /* Main content takes full width on mobile */
    .main-content {
        margin-left: 0;
    }
}

/* ========================================
   IMPROVED SCROLLING
   ======================================== */

/* Smooth scrolling for all elements */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar styling for main content */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

/* ========================================
   RECENT ACTIVITY FIXES
   ======================================== */

/* Ensure Recent Activity doesn't overflow */
.recent-activity {
    max-width: 100%;
    overflow: hidden;
}

.activity-item {
    max-width: 100%;
}

.activity-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   VIDEO EMBEDS IMPROVEMENTS
   ======================================== */

/* Ensure video embeds are responsive */
.video-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ========================================
   BUTTON IMPROVEMENTS
   ======================================== */

/* Ensure all buttons are properly styled */
.btn {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   CARD HOVER EFFECTS
   ======================================== */

/* Smooth card transitions */
.game-card,
.video-card,
.cheat-card,
.discord-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game-card:hover,
.video-card:hover,
.cheat-card:hover,
.discord-card:hover {
    transform: translateY(-5px);
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Add smooth loading animations */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading-skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
}

.skip-to-main:focus {
    top: 0;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* GPU acceleration for animations */
.game-card,
.video-card,
.cheat-card,
.sidebar {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Prevent layout shift */
img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   TEXT IMPROVEMENTS
   ======================================== */

/* Better text rendering */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent text overflow */
h1, h2, h3, h4, h5, h6, p, span, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================================
   FORM IMPROVEMENTS
   ======================================== */

/* Better form input styling */
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ========================================
   GRID IMPROVEMENTS
   ======================================== */

/* Responsive grids */
.games-grid,
.videos-grid,
.discord-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

@media (max-width: 768px) {
    .games-grid,
    .videos-grid,
    .discord-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   FOOTER FIXES
   ======================================== */

/* Ensure footer is at bottom */
.footer {
    margin-top: auto;
}

/* ========================================
   DARK MODE ENHANCEMENTS
   ======================================== */

/* Smooth dark mode transitions */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Exclude specific elements from transition */
.sidebar,
.main-content,
.hero {
    transition: transform var(--transition-normal), margin-left var(--transition-normal);
}

/* ========================================
   MOBILE IMPROVEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Better mobile padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Stack buttons vertically on mobile */
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    /* Better mobile stats */
    .hero-stats,
    .youtube-stats {
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
    }

    .stat {
        min-width: 100px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .mobile-sidebar-btn,
    .footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: white;
        color: black;
    }
}

/* ========================================
   ANIMATION PERFORMANCE
   ======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Z-INDEX MANAGEMENT
   ======================================== */

/* Proper z-index layering */
.sidebar { z-index: 1000; }
.mobile-sidebar-btn { z-index: 999; }
.hero-bg { z-index: -1; }
.toast { z-index: 10000; }
.custom-tooltip { z-index: 10001; }

/* ========================================
   UTILITY CLASSES
   ======================================== */

.no-scroll {
    overflow: hidden;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
