/* ============================
   DROPDOWN WRAPPER
   ============================ */
.dropdown {
    position: relative;
    display: inline-block;
    outline: none;
}

/* Only the wrapper is focusable */
.dropdown:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* ============================
   HEADER (collapsed control)
   ============================ */
.dropdown-header {
    background: white;
    color: black;
    border: 1px solid #ccc;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 8px;

    user-select: none;
    caret-color: transparent;

    /* Prevent header from becoming a tab stop */
    pointer-events: none;
}

/* ============================
   FLAG ICONS
   ============================ */
.dropdown-header img,
.dropdown-item img {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    object-fit: cover;
}

/* ============================
   DROPDOWN LIST (expanded)
   ============================ */
.dropdown-list {
    position: absolute;
    top: 110%;
    left: 0;

    background: white;
    color: black;
    border: 1px solid #ccc;
    border-radius: 6px;

    max-height: 250px;
    overflow-y: auto;

    display: none;
    z-index: 9999;

    width: max-content;
    min-width: 160px;
    max-width: 90vw;
    box-sizing: border-box;
}

/* ============================
   ITEMS
   ============================ */
.dropdown-item {
    padding: 6px 10px;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background: #eee;
}

/* ============================
   FALLBACK FLAG
   ============================ */
.flag-fallback {
    width: 18px;
    height: 18px;
    background: #ccc;
    border-radius: 3px;
}

/* ============================
   MOBILE (≤600px)
   ============================ */
@media (max-width: 600px) {

    /* Hide text in header (flag-only mode) */
    .dropdown-header span {
        display: none;
    }

    .dropdown-header {
        padding: 6px 8px;
        gap: 4px;
    }

    .dropdown-header img {
        width: 22px;
        height: 16px;
    }

    .dropdown-item {
        padding: 6px 8px;
        gap: 6px;
    }

    .dropdown-item img {
        width: 20px;
        height: 14px;
    }

    /* Mobile dropdown floats under top bar */
    .dropdown-list {
        position: fixed;
        top: 60px;
        left: 50vw;
        transform: translateX(-50%);

        min-width: 220px;
        width: max-content;
        max-width: 90vw;

        z-index: 9999;
    }
}

/* ============================
   DESKTOP RIGHT-ALIGN FOR TRANSLATE DROPDOWN
   ============================ */
@media (min-width: 601px) {
    #translate-dropdown .dropdown-list {
        left: auto;
        right: 0;
        transform: none;
        margin-right: -12px;
    }
}
