#smb_backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2;
    background: rgba(0, 0, 0, 0.45);
    cursor: default;
}

#smb_backdrop.smb_backdrop_visible {
    display: block;
}

#smb_wrapper {
    position: sticky;
    top: 10px;
    z-index: 3;
}

#selected_materials_bar {
    background: #0B64DD;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 20px;
    flex-wrap: nowrap;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    scrollbar-width: none;
    border-radius: 10px;
    transition: border-radius 0.2s;
}

#selected_materials_bar::-webkit-scrollbar { display: none; }

#smb_wrapper.smb_wrapper_open #selected_materials_bar {
    border-radius: 10px 10px 0 0;
    box-shadow: none;
}

#smb_panel_close {
    flex-shrink: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    opacity: 0;
    user-select: none;
}

#smb_panel_close.smb_panel_close_visible {
    opacity: 1;
}

#smb_panel_close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

#smb_panel_close .material-symbols-outlined {
    font-size: 20px !important;
    line-height: 1;
}

#smb_panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    max-height: 0;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    transition: max-height 0.35s ease;
}

#smb_wrapper.smb_wrapper_open #smb_panel {
    max-height: 65vh;
    overflow-y: auto;
}

#smb_panel_list {
    list-style: none;
    padding: 8px;
    margin: 0;
}

.smb_panel_item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    border-radius: 8px;
    transition: background 0.1s;
}

.smb_panel_item:last-child {
    border-bottom: none;
}

.smb_panel_item:hover {
    background: #f8f9fb;
}

.smb_panel_img {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #eee;
}

.smb_panel_img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.smb_panel_body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.smb_panel_title {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    line-height: 1.35;
    cursor: pointer;
    padding-bottom: 4px;
}

.smb_panel_desc {
    font-size: 12px;
    color: #666;
    cursor: pointer;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.smb_panel_footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 6px;
}

.smb_panel_tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.smb_panel_tag_badge {
    background: rgba(11, 100, 222, 0.1);
    color: #0B64DD;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}

.smb_panel_actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

.smb_item_fav,
.smb_item_remove {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.smb_item_fav {
    background: rgba(11, 100, 222, 0.08);
    color: #0B64DD;
}

.smb_item_fav:hover,
.smb_item_fav.smb_item_fav_active {
    background: rgba(11, 100, 222, 0.18);
}

.smb_item_remove {
    background: rgba(200, 30, 30, 0.07);
    color: #c00;
}

.smb_item_remove:hover {
    background: rgba(200, 30, 30, 0.18);
}

.smb_item_fav .material-symbols-outlined,
.smb_item_remove .material-symbols-outlined {
    font-size: 15px !important;
    line-height: 1;
}

.smb_panel_empty {
    padding: 32px 16px;
    text-align: center;
    color: #aaa;
    font-size: 14px;
}

.smb_label {
    font-size: 12px;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.smb_tiles {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.smb_tile {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1.5px solid rgba(255, 255, 255, 0.45);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    background: transparent;
    transition: all 0.15s;
    cursor: pointer;
}

.smb_tile.smb_tile_active {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
    color: #fff;
}

#smb_wrapper.smb_wrapper_open .smb_tile.smb_tile_active {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.45);
    color: rgba(255, 255, 255, 0.85);
}

#smb_wrapper.smb_wrapper_open .smb_tile.smb_tile_selected {
    background: rgba(255, 255, 255, 0.35);
    border-color: #fff;
    color: #fff;
}

#materials_page_layout {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    width: calc(100% - 32px);
    max-width: 1400px;
    margin: 24px auto 0 auto;
}

#filters_sidebar {
    flex: 0 0 210px;
    width: 210px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    padding: 16px;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
}

.filters_header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #222;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
    margin-bottom: 2px;
}

.filters_header .material-symbols-outlined {
    font-size: 18px !important;
    line-height: 18px !important;
    color: #555;
}

.filters_content {
    height: 100%;
    overflow-y: scroll;
    scrollbar-width: none;
}

.filter_group {
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.filter_group:last-of-type {
    border-bottom: none;
    padding-bottom: 4px;
}

.fg_title {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 10px;
}

/* Filter items list */
.fg_list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.fg_list li {
    display: flex;
    align-items: flex-start;
}

.fg_list li.fg_item_hidden {
    display: none !important;
}

.fg_list li label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 400;
    color: #333;
    padding: 3px 5px;
    border-radius: 5px;
    width: 100%;
    transition: background 0.1s, color 0.1s;
}

.fg_list li label span {
    padding-top: 2px;
}

.fg_list li label:hover {
    color: #0B64DD;
    background: rgba(11, 100, 221, 0.05);
}

.fg_list li.fg_child label {
    padding-left: 20px;
    font-size: 12px;
    color: #666;
}

.fg_list li label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin-top: 3px;
    accent-color: #0B64DD;
    cursor: pointer;
    flex-shrink: 0;
}

.fg_more_btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #0B64DD;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    padding: 5px 12px;
    margin-top: 8px;
    transition: background 0.15s, transform 0.1s;
}

.fg_more_btn:hover {
    background: #0B64DD;
}

.fg_more_btn.hidden {
    display: none;
}

.fg_more_btn .material-symbols-outlined {
    font-size: 15px !important;
    line-height: 15px !important;
    transition: transform 0.25s;
}

.fg_more_btn.expanded .material-symbols-outlined {
    transform: rotate(180deg);
}

.filters_footer {
    padding-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#filters_clear_btn {
    background: #f2f2f2;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

#filters_clear_btn:hover {
    background: #e2e2e2;
    color: #111;
}

.fs_count_badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0B64DD;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 10px;
    white-space: nowrap;
    min-width: 72px;
    text-align: center;
}

#materials_main_col {
    flex: 1;
    min-width: 0;
}

#materials_main_col .content_wrapper {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sort_bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 12px;
    background: #fff;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    margin-bottom: 12px;
}

.active_filters_chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    margin: 4px 0;
}

.active_filter_chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(11, 100, 222, 0.1);
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 12px;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
    cursor: pointer;
    transition: all 0.3s;
}

.active_filter_chip:hover {
    background: rgba(11, 100, 222, 0.2);
    color: #111;
}

.active_filter_chip_label {
    white-space: nowrap;
}

.active_filter_chip_remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #c00;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.active_filter_chip_remove .material-symbols-outlined {
    font-size: 16px !important;
    line-height: 1;
}

.sort_label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font: 500 13px/16px "Inter", serif;
    color: #555;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}

.sort_select_wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#sort_select {
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 34px 7px 62px;
    font: 13px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

#sort_select:hover,
#sort_select:focus {
    border-color: #0B64DD;
    outline: none;
}

.sort_select_wrap::after {
    content: "\e5cf";
    font-family: "Material Symbols Outlined";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #666;
    pointer-events: none;
    line-height: 1;
}

.filters_toggle_icon {
    font-size: 22px !important;
    line-height: 22px !important;
    margin-left: auto;
    transition: transform 0.25s;
    color: #555;
}

.filters_toggle_icon.material-symbols-outlined {
    display: none;
}

#filters_sidebar.is-open .filters_toggle_icon {
    transform: rotate(180deg);
}

.filters_mobile_active_count {
    display: none;
    align-items: center;
    justify-content: center;
    background: #0B64DD;
    color: #fff;
    font: 700 11px/12px "Inter", serif;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 6px;
    white-space: nowrap;
}

.filters_mobile_active_count.hidden {
    visibility: hidden;
}

@media (max-width: 767.98px) {
    #materials_page_layout {
        flex-direction: column;
        width: calc(100% - 24px);
        margin-top: 16px;
        gap: 12px;
    }

    #filters_sidebar {
        width: 100%;
        flex: none;
        position: static;
        border-radius: 8px;
        padding: 0;
        overflow: hidden;
        max-height: unset;
    }

    .filters_header {
        cursor: pointer;
        padding: 12px 16px;
        border-radius: 8px;
        margin-bottom: 0;
        border-bottom: none;
        user-select: none;
        -webkit-user-select: none;
    }

    .filters_header:hover {
        background: rgba(11, 100, 221, 0.04);
    }

    #filters_sidebar.is-open .filters_header {
        border-bottom: 1px solid #eee;
        border-radius: 8px 8px 0 0;
    }

    .filters_toggle_icon.material-symbols-outlined {
        display: block;
    }

    .filters_mobile_active_count:not(.hidden) {
        display: inline-flex;
    }

    .filters_content,
    .filters_footer {
        display: none;
        padding: 0 16px;
    }

    #filters_sidebar.is-open .filters_content {
        display: block;
        padding: 12px 16px 4px 16px;
    }

    #filters_sidebar.is-open .filters_footer {
        display: flex;
        padding: 8px 16px 14px 16px;
    }

    #materials_main_col {
        width: 100%;
    }

    .sort_bar {
        flex-direction: column;
    }

    .sort_select_wrap {
        align-self: flex-end;
    }

    #selected_materials_bar {
        padding: 8px 12px;
        gap: 8px;
    }

    #smb_wrapper.smb_wrapper_open #smb_panel {
        max-height: calc(100vh - 280px);
        overflow-y: auto;
    }

    .smb_label {
        font-size: 12px;
    }

    .smb_tile {
        font-size: 12px;
        padding: 4px 10px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    #filters_sidebar {
        flex: 0 0 185px;
        width: 185px;
    }
}

@media (min-width: 992px) {
    #materials_page_layout {
        padding-top: 8px;
    }
}

@media (min-width: 1200px) {
    #materials_page_layout {
        max-width: 970px;
    }
}
