/* =============================================================================
   Switch Account — banner, dropdown items, picker modal
   ----------------------------------------------------------------------------
   Scoped purely to impersonation UI. Designed to fit the existing tokens
   palette (var(--bs-primary), --bs-warning, --bs-danger, --bs-gray-*).
   ============================================================================= */


/* ── Impersonation banner ───────────────────────────────────────────────── */
:root { --impersonation-banner-h: 56px; }

.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1080;
    min-height: var(--impersonation-banner-h);
    background: linear-gradient(135deg, #b54708 0%, #d97706 50%, #f59e0b 100%);
    color: #fff;
    box-shadow: 0 4px 14px -4px rgba(217, 119, 6, 0.45);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    animation: impersonationSlide 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Push chrome down so the banner never hides the sidebar logo / top bar. */
body.is-impersonating { padding-top: var(--impersonation-banner-h); }
body.is-impersonating .sidebar {
    top: var(--impersonation-banner-h);
    height: calc(100vh - var(--impersonation-banner-h));
}
body.is-impersonating .content-header { top: var(--impersonation-banner-h); }
body.is-impersonating .mobile-header { top: var(--impersonation-banner-h); }

@keyframes impersonationSlide {
    0%   { opacity: 0; transform: translateY(-100%); }
    100% { opacity: 1; transform: translateY(0); }
}

.impersonation-banner-inner {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.625rem 1rem;
    max-width: 100%;
}

.impersonation-banner-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    font-size: 1rem;
}

.impersonation-banner-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.impersonation-banner-text strong {
    font-weight: 600;
    font-size: 0.875rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.impersonation-banner-sub {
    display: inline-block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.86);
}

.impersonation-banner-actor {
    font-weight: 600;
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(255, 255, 255, 0.6);
}

.impersonation-banner-actions { margin: 0; }

.impersonation-banner-btn {
    background: #fff;
    color: #b54708;
    border: none;
    border-radius: 0.5rem;
    padding: 0.4rem 0.85rem;
    font-weight: 600;
    font-size: 0.78125rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.impersonation-banner-btn:hover {
    color: #92400e;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
}

@media (max-width: 575.98px) {
    :root { --impersonation-banner-h: 116px; }
    .impersonation-banner-inner { flex-wrap: wrap; }
    .impersonation-banner-actions { width: 100%; }
    .impersonation-banner-btn { width: 100%; }
}


/* ── Dropdown additions ─────────────────────────────────────────────────── */
.account-dropdown-icon.icon-switch {
    background-color: rgba(var(--bs-primary-rgb), 0.10);
    color: var(--bs-primary);
}
.account-dropdown-item:hover .icon-switch {
    background-color: rgba(var(--bs-primary-rgb), 0.18);
}

.account-dropdown-icon.icon-switchback {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.14), rgba(245, 158, 11, 0.18));
    color: #b54708;
}
.account-dropdown-item:hover .icon-switchback {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.22), rgba(245, 158, 11, 0.28));
}

.account-dropdown-switchback { color: #b54708; font-weight: 600; }
.account-dropdown-switchback:hover {
    background-color: rgba(217, 119, 6, 0.07);
    color: #92400e;
}


/* ── Switch Account Modal ───────────────────────────────────────────────── */
.switch-account-modal .modal-content {
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: 1rem;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 24px 48px -12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.switch-account-modal .modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
    background: linear-gradient(135deg, var(--bs-gray-50) 0%, rgba(var(--bs-primary-rgb), 0.04) 100%);
}

.switch-account-modal .modal-body { padding: 1.25rem; }
.switch-account-modal .modal-footer { padding: 0.75rem 1.25rem; background: var(--bs-gray-50); }

.switch-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
    font-size: 1rem;
}

.alert-info-subtle {
    background-color: rgba(var(--bs-primary-rgb), 0.06);
    border: 1px solid rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-gray-700);
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0;
}

.switch-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bs-gray-500);
    font-size: 0.875rem;
    pointer-events: none;
}

.switch-search-input { padding-left: 2.1rem; }


/* ── Scope pills + clinic filter ────────────────────────────────────────── */
.switch-scope-pills {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    margin-bottom: 0.75rem;
    background: var(--bs-gray-100);
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: var(--bs-border-radius-pill);
}

.switch-scope-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border: 0;
    background: transparent;
    color: var(--bs-gray-600);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--bs-border-radius-pill);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.switch-scope-pill:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.06);
    color: var(--bs-gray-800);
}

.switch-scope-pill.is-active {
    background-color: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
}

.switch-scope-pill i { font-size: 0.85rem; line-height: 1; }

.switch-clinic-row { margin-bottom: 0.75rem; }

.switch-clinic-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bs-gray-500);
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 4;
}

.switch-clinic-select {
    padding-left: 2.1rem;
    padding-right: 2.25rem;
    font-size: 0.8125rem;
    border-radius: 0.625rem;
    cursor: pointer;
    background-color: #fff;
}

.switch-clinic-select:focus {
    border-color: rgba(var(--bs-primary-rgb), 0.5);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.12);
}

.switch-empty-pick {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--bs-gray-500);
    font-size: 0.8125rem;
}

.switch-empty-pick i {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.55;
    color: var(--bs-gray-400);
}


.switch-results-wrapper {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    background: #fff;
    max-height: 22rem;
    overflow-y: auto;
}

.switch-results-empty { font-size: 0.8125rem; }

.switch-user-list { display: flex; flex-direction: column; }

.switch-user-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    column-gap: 0.75rem;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--bs-gray-100);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.switch-user-row:last-child { border-bottom: 0; }
.switch-user-row:hover { background-color: var(--bs-gray-50); }

.switch-user-row.is-selected {
    background-color: rgba(var(--bs-primary-rgb), 0.08);
    box-shadow: inset 3px 0 0 var(--bs-primary);
}

.switch-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--bs-gray-100);
    color: var(--bs-gray-500);
    font-size: 1.5rem;
    flex-shrink: 0;
}
.switch-user-row.is-selected .switch-user-avatar {
    background: rgba(var(--bs-primary-rgb), 0.14);
    color: var(--bs-primary);
}

.switch-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.switch-user-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--bs-gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.switch-user-email {
    font-size: 0.6875rem;
    color: var(--bs-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.switch-user-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; justify-content: flex-end; }

.switch-tag {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: var(--bs-border-radius-pill);
    white-space: nowrap;
}

.switch-tag.tag-role {
    background: rgba(102, 16, 242, 0.10);
    color: #6610f2;
}

.switch-tag.tag-clinic {
    background: rgba(0, 201, 167, 0.10);
    color: #00917a;
}

.switch-user-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 1.5px solid var(--bs-gray-300);
    color: transparent;
    transition: all 0.15s ease;
}

.switch-user-row.is-selected .switch-user-check {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}


/* Dark mode tweaks */
[data-theme="dark"] .impersonation-banner {
    box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .switch-account-modal .modal-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, rgba(var(--bs-primary-rgb), 0.06) 100%);
}
[data-theme="dark"] .switch-results-wrapper {
    background: var(--bs-gray-900, #1b1f24);
    border-color: var(--bs-gray-800, #2a2f36);
}
[data-theme="dark"] .switch-user-row { border-bottom-color: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .switch-user-row:hover { background-color: rgba(255, 255, 255, 0.03); }

[data-theme="dark"] .switch-scope-pills {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .switch-scope-pill { color: rgba(255, 255, 255, 0.6); }
[data-theme="dark"] .switch-scope-pill:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.12);
    color: rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .switch-scope-pill.is-active {
    background-color: rgba(var(--bs-primary-rgb), 0.22);
    color: #fff;
}
[data-theme="dark"] .switch-clinic-icon { color: rgba(255, 255, 255, 0.55); }
[data-theme="dark"] .switch-clinic-select {
    background-color: var(--bs-gray-900, #1b1f24);
    border-color: var(--bs-gray-800, #2a2f36);
    color: rgba(255, 255, 255, 0.9);
}
[data-theme="dark"] .switch-empty-pick { color: rgba(255, 255, 255, 0.55); }
[data-theme="dark"] .switch-empty-pick i { color: rgba(255, 255, 255, 0.35); }
