/**
 * Overflow Fix Styles
 * Prevents horizontal scrolling and fixes layout issues
 */

/* Prevent horizontal overflow on html and body */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Ensure all containers don't exceed viewport width */
.container-fluid,
.container {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Fix Bootstrap row overflow issues */
.row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
}

/* Ensure columns don't cause overflow */
[class*="col-"] {
    max-width: 100%;
    overflow-x: hidden;
}

/* Fix main content area */
.main-content {
    max-width: 100%;
    overflow-x: hidden;
    padding-left: 15px !important;
    padding-right: 15px !important;
}

/* Sidebar responsive fixes */
.sidebar {
    max-width: 100%;
    overflow-x: hidden;
}

/* Fix any elements that might cause horizontal scroll */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* Ensure forms don't overflow */
.form-control,
.form-select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix card components */
.card {
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsive images and media */
img {
    max-width: 100%;
    height: auto;
}

/* Fix navigation elements */
.navbar,
.nav {
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile specific fixes */
@media (max-width: 768px) {
    body {
        overflow-x: hidden !important;
        position: relative !important;
    }
    
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .main-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    /* Fix table overflow on mobile */
    .table {
        font-size: 0.875rem;
    }
    
    /* Ensure buttons don't cause overflow */
    .btn {
        word-wrap: break-word;
        max-width: 100%;
    }
    
    /* Mobile-specific sidebar fixes */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    /* Prevent horizontal scrolling on mobile */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    [class*="col-"] {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    
    /* Fix mobile navbar overflow */
    .navbar-collapse {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Mobile form fixes */
    .form-control,
    .form-select,
    .input-group {
        max-width: 100% !important;
        min-width: 0 !important;
    }
    
    /* Trading specific mobile fixes */
    .trading-form-container,
    .position-card,
    .order-summary {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* Desktop specific fixes */
@media (min-width: 769px) {
    /* Ensure proper spacing for desktop sidebar layout */
    .main-content {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Fix any charts or widgets that might overflow */
.chart-container,
.widget-container {
    max-width: 100%;
    overflow: hidden;
}

/* Trading specific fixes */
.trading-form-container {
    max-width: 100%;
    overflow-x: hidden;
}

.position-card,
.order-summary {
    max-width: 100%;
    box-sizing: border-box;
}

/* Notification fixes */
.notification-item,
.alert {
    max-width: 100%;
    word-wrap: break-word;
}

/* Additional Bootstrap utility overrides */
.w-100 {
    max-width: 100% !important;
}

/* Fix any potential negative margins */
* {
    max-width: 100%;
}

*:not(.container):not(.container-fluid):not(.row) {
    box-sizing: border-box;
}

/* Specific fix for elements that commonly cause overflow */
pre,
code {
    overflow-x: auto;
    max-width: 100%;
}

/* Flexbox fixes */
.d-flex,
.flex-row,
.flex-column {
    max-width: 100%;
    overflow: hidden;
}

/* Form accessibility improvements */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
}

legend.form-label {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    margin-bottom: 0.5rem;
    border: none;
    padding: 0;
    width: auto;
    float: none;
}
