/* Country table filter styles */

/* Container for country filter */
.country-filter-container {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Wrapper for header and filter */
.table-header-with-filter {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    width: auto;
    margin-bottom: 0;
}

/* Ensure header stays on the left */
.table-header-with-filter > h1,
.table-header-with-filter > h2,
.table-header-with-filter > h3,
.table-header-with-filter > h4,
.table-header-with-filter > h5,
.table-header-with-filter > h6 {
    margin: 0;
}

/* Text showing selected country inside button */
.country-filter-selected-text {
    color: var(--md-default-fg-color, #000);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Compact spacing */
.country-filter-container + table {
    margin-top: 0;
}

/* Spacing when filter is next to header */
.table-header-with-filter + table {
    margin-top: 1rem;
}

/* Remove top and bottom margins from table wrapper */
.md-typeset__scrollwrap {
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
}

/* Wrapper for button and dropdown */
.country-filter-button-wrapper {
    position: relative;
    display: inline-block;
}

/* Button with flag and text */
.country-filter-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    min-width: auto;
    height: auto;
    border-radius: 0;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    background-color: var(--md-default-bg-color, #fff);
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
}

.country-filter-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Flag container inside button */
.country-filter-button-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 15px;
    flex-shrink: 0;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 16px;
}

.country-filter-button-flag.has-flag {
    font-size: 0;
}

/* Dropdown menu - styled like Material theme select */
.country-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.2rem;
    background-color: var(--md-default-bg-color, #fff);
    border: none;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    min-width: auto;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    padding: 0.2rem 0;
    width: auto;
}

.country-filter-button-wrapper:hover .country-filter-dropdown,
.country-filter-dropdown.show {
    display: flex;
}

/* Divider in dropdown */
.country-filter-divider {
    height: 1px;
    background-color: var(--md-default-fg-color--lighter, rgba(0, 0, 0, 0.12));
    margin: 0.2rem 0;
}

/* Option in dropdown - styled like md-select__link */
.country-filter-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    min-height: 28px;
    gap: 0.5rem;
}

.country-filter-option:hover {
    background-color: var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.05));
}

/* Flag element in option - only flag, no text */
.country-filter-flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.country-filter-flag.has-flag {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}

/* Label text in option */
.country-filter-label {
    color: var(--md-default-fg-color, #000);
    font-size: 0.8rem;
    display: block;
}

/* Responsive styles for mobile devices */
@media screen and (max-width: 59.9375em) {
    /* На мобильных устройствах селектор не должен переноситься */
    .table-header-with-filter {
        flex-wrap: nowrap;
    }
    
    .country-filter-container {
        margin-left: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* Для очень маленьких экранов селектор также не должен переноситься */
@media screen and (max-width: 30em) {
    .table-header-with-filter {
        flex-wrap: nowrap;
        align-items: center;
    }
    
    .country-filter-container {
        margin-left: 0;
        flex-shrink: 0;
        white-space: nowrap;
    }
}

