/* ============================================
   MOBILE RESPONSIVE FIX - OVERFLOW PREVENTION
   ============================================ */

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    box-sizing: border-box;
}

/* Image and media fixes - ALWAYS */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Table fixes - ALWAYS */
.xf-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    max-width: 100%;
}

/* Pre and code fixes - ALWAYS */
pre,
code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
}

/* Content fixes - ALWAYS */
.xf-post-content,
.xf-topic-content {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* ============================================
   MOBILE ONLY (768px and below)
   ============================================ */
@media (max-width: 768px) {
    /* Container - mobile only */
    .xf-container {
        max-width: 100%;
        overflow-x: hidden;
        padding: 0 12px !important;
    }
    
    .xf-header,
    .xf-main,
    .xf-sidebar,
    .xf-footer {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Force all elements to respect viewport */
    * {
        max-width: 100vw;
    }
    
    /* Header mobile fix */
    .xf-header {
        position: relative;
        width: 100%;
    }
    
    .xf-header-content {
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
    }
    
    .xf-logo {
        flex: 0 1 auto;
        max-width: calc(100% - 60px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Hide desktop nav completely */
    .xf-nav {
        display: none !important;
    }
    
    /* Mobile menu button */
    .xf-mobile-menu-btn {
        flex: 0 0 auto;
        margin-left: 12px;
    }
    
    /* Layout fixes */
    .xf-layout {
        width: 100%;
        max-width: 100%;
        display: block;
    }
    
    .xf-main,
    .xf-sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    /* Block fixes */
    .xf-block,
    .xf-category-card,
    .xf-topic-item,
    .xf-post {
        width: 100%;
        max-width: 100%;
    }
    
    /* Form fixes */
    .xf-input,
    .xf-textarea,
    .xf-select {
        width: 100%;
        max-width: 100%;
    }
    
    /* Button fixes */
    .xf-btn {
        max-width: 100%;
    }
    
    /* Grid fixes */
    .xf-category-grid,
    .xf-stats-grid {
        max-width: 100%;
    }
}
