/* Edara Org Switcher — header pill + dropdown.
   All classes prefixed `edara-org-switcher__` to avoid collisions. */

.edara-org-switcher {
    position: relative;
    display: inline-flex;
    margin-inline-start: 8px;
    max-width: 100%;
    min-width: 0;
}

.edara-org-switcher::before {
    content: '';
    position: absolute;
    inset-inline-start: -8px;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background: var(--outline-variant);
    opacity: 0.6;
}

.edara-org-switcher__pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    max-width: 100%;
    min-width: 0;
    padding: 3px 8px 3px 3px;
    border-radius: 999px;
    background: var(--surface-container-low, rgba(0, 0, 0, 0.03));
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: inherit;
    cursor: pointer;
    font: inherit;
    transition: background 120ms ease, border-color 120ms ease;
}

[dir="rtl"] .edara-org-switcher__pill {
    padding: 3px 3px 3px 8px;
}

.edara-org-switcher__pill:hover:not(:disabled) {
    background: var(--surface-container, rgba(0, 0, 0, 0.05));
    border-color: var(--outline-variant);
}

.edara-org-switcher__pill:focus-visible {
    outline: 2px solid var(--primary, #3a5bdc);
    outline-offset: 2px;
}

.edara-org-switcher__pill:disabled,
.edara-org-switcher--single .edara-org-switcher__pill {
    cursor: default;
}

.edara-org-switcher__pill-avatar-slot {
    display: inline-flex;
}

.edara-org-switcher__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 11px;
    line-height: 1;
    flex: 0 0 auto;
}

.edara-org-switcher__text {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
    min-width: 0;
    flex: 0 1 auto;
    text-align: start;
}

.edara-org-switcher__label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    opacity: 0.85;
}

.edara-org-switcher__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface);
    max-width: 180px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edara-org-switcher__chevron {
    display: inline-flex;
    color: var(--on-surface-variant);
    transition: transform 160ms ease;
    flex: 0 0 auto;
    opacity: 0.7;
}

.edara-org-switcher__chevron svg {
    display: block;
    width: 16px;
    height: 16px;
}

.edara-org-switcher--open .edara-org-switcher__chevron {
    transform: rotate(180deg);
}

.edara-org-switcher--single .edara-org-switcher__chevron {
    display: none;
}

/* ----- Menu ----- */

.edara-org-switcher__menu {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    min-width: 280px;
    max-width: 360px;
    background: var(--surface-container-low, var(--surface, #fff));
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    padding: 8px;
    z-index: 1000;
    animation: edara-org-switcher-fade 120ms ease-out;
}

@keyframes edara-org-switcher-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.edara-org-switcher__menu-header {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    padding: 8px 12px 6px;
}

.edara-org-switcher__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.edara-org-switcher__row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-align: start;
    transition: background 120ms ease;
}

.edara-org-switcher__row:hover,
.edara-org-switcher__row:focus-visible {
    background: var(--surface-container, rgba(0, 0, 0, 0.04));
    outline: none;
}

.edara-org-switcher__row--selected {
    background: var(--primary-container, rgba(58, 91, 220, 0.08));
}

.edara-org-switcher__row-name {
    flex: 1 1 auto;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edara-org-switcher__row-check {
    display: inline-flex;
    color: var(--primary, #3a5bdc);
    flex: 0 0 auto;
}

.edara-org-switcher__row-check svg {
    display: block;
}

/* ----- Dark mode tuning (portal already toggles .dark on <html>) ----- */

html.dark .edara-org-switcher__menu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ----- On a dark header surface (e.g. price-checker) ----- */

.edara-org-switcher--on-dark .edara-org-switcher__pill {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.edara-org-switcher--on-dark .edara-org-switcher__pill:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
}

.edara-org-switcher--on-dark .edara-org-switcher__label {
    color: rgba(255, 255, 255, 0.6);
    opacity: 1;
}

.edara-org-switcher--on-dark .edara-org-switcher__name {
    color: rgba(255, 255, 255, 0.95);
}

.edara-org-switcher--on-dark .edara-org-switcher__chevron {
    color: rgba(255, 255, 255, 0.75);
    opacity: 1;
}

/* ----- Responsive — keep the pill compact on smaller viewports ----- */

@media (max-width: 720px) {
    .edara-org-switcher__label {
        display: none;
    }
    .edara-org-switcher__text {
        justify-content: center;
    }
    .edara-org-switcher__name {
        max-width: 140px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .edara-org-switcher__pill {
        gap: 6px;
        padding: 3px 6px 3px 3px;
        height: 32px;
    }
    [dir="rtl"] .edara-org-switcher__pill {
        padding: 3px 3px 3px 6px;
    }
    .edara-org-switcher__avatar {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }
    .edara-org-switcher__name {
        max-width: 96px;
        font-size: 12px;
    }
    .edara-org-switcher__menu {
        position: fixed;
        top: auto;
        inset-inline-start: 12px;
        inset-inline-end: 12px;
        min-width: 0;
        max-width: none;
    }
}
