/* Market Layout Adjustments for Full Height and Scrolling */

/* Ensure the entire page takes up the full window height and doesn't scroll the body */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* App root needs to be a flex container taking full height */
#app-root-container {
    height: 100vh;
    min-height: 0; /* Override any min-height */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main content area takes remaining space after header */
.main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* Inner content wrapper */
.main-content-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* The layout container for filters and list */
.items-layout.items-layout--market {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    height: 100%;
    min-height: 0;
}

/* New Wrapper for Right Content (Header + List) */
.items-layout__content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Header and list will manage their own overflow/layout */
    height: 100%;
    min-width: 0; /* Prevent flex item from overflowing */
}

/* Filters sidebar */
.items-layout__filters {
    height: 100%;
    overflow-y: auto; /* Scrollable independently */
    width: 280px; /* Set a fixed width for sidebar to prevent collapsing/expanding */
    flex-shrink: 0;
    border-right: 1px solid #1f2937; /* Optional separator */
    padding-bottom: 60px; /* Increased padding to ensure bottom content (like Reset button) is visible */
    box-sizing: border-box; /* Ensure padding doesn't affect width/height calculation */
}

/* Override minified CSS overflow rules */
.items-layout__item-list-wrapper {
    flex: 1;
    overflow: visible !important; /* Keep visible for dropdowns */
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%; /* Ensure it takes full available width */
    min-width: 0;
    min-height: 0; /* CRITICAL: Prevent flex item from growing beyond parent */
    height: 100%;
}

/* Restore necessary layout properties for header */
.items-layout__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color:  var(--color-base-900);
    border-bottom: 1px solid #1f2937;
    flex-shrink: 0;
    gap: 16px;
    width: 100%; /* Force full width */
    box-sizing: border-box; /* Include padding in width */
    /* Plus overrides */
    overflow: visible !important;
    position: relative;
    z-index: 100;
}

.market__details-filter--horizontal {
    flex: 1;
    overflow-x: auto;
    margin-bottom: 0 !important;
}

.market__sorting {
    flex-shrink: 0;
    margin-bottom: 0 !important;
    /* Plus overrides */
    overflow: visible !important;
    position: relative;
    z-index: 101;
}

/* Fix for when user adds .dropdown-list to the container */
.market__sorting.dropdown-list {
    overflow: visible !important;
    max-height: none !important;
    width: auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Ensure the dropdown itself doesn't scroll */
.dropdown {
    overflow: visible !important;
}

.dropdown-header {
    overflow: visible !important;
}

/* Ensure dropdown content is positioned correctly */
.dropdown-content {
    display: none; /* Hide by default */
    position: absolute;
    top: 100%;
    z-index: 1000;
}

/* The actual item list container */
.item-list.item-list--market.items-layout__item-list {
    flex: 1; /* Take remaining height */
    overflow-y: auto; /* Scrollable independently */
    /* height: 100%; <-- Removed to prevent overflow issues with header */
    width: 100%;
    padding: 16px; /* Add padding inside scroll area */
    position: relative;
    z-index: 1; /* Lower than header */
    min-height: 0; /* Important for nested flex scrolling */
}

/* Ensure the grid doesn't break scrolling */
.item-list__grid {
    padding-bottom: 20px; /* Add some bottom padding for scroll */
}

/* Dropdown Floating Styles */
.dropdown {
    position: relative;
}

.dropdown-content {
    display: none; /* Hide by default */
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100; /* Ensure it floats above other content */
    width: 100%; /* Or min-width: 200px; depending on design */
    min-width: max-content;
    background-color: #161b26; /* Dark background */
    border: 1px solid #1f2937;
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
}

.dropdown-content--left {
    right: 0;
    left: auto;
}

/* Ensure item list handles dynamic content scrolling correctly */
/* Redundant block removed/merged */

/* Custom Scrollbar for Webkit browsers (Chrome, Edge, Safari) */
.item-list.item-list--market.items-layout__item-list::-webkit-scrollbar,
.items-layout__filters::-webkit-scrollbar {
    width: 8px;
}

.item-list.item-list--market.items-layout__item-list::-webkit-scrollbar-track,
.items-layout__filters::-webkit-scrollbar-track {
    background: #0b0f16;
}

.item-list.item-list--market.items-layout__item-list::-webkit-scrollbar-thumb,
.items-layout__filters::-webkit-scrollbar-thumb {
    background-color: #1f2937;
    border-radius: 4px;
}

.item-list.item-list--market.items-layout__item-list::-webkit-scrollbar-thumb:hover,
.items-layout__filters::-webkit-scrollbar-thumb:hover {
    background-color: #374151;
}
