/* ── SmartConnect Tenant Switcher ─────────────────────────── */

.sc-switcher {
    --sw-primary: #2271b1;
    --sw-primary-hover: #135e96;
    --sw-text: #1d2327;
    --sw-muted: #646970;
    --sw-border: #c3c4c7;
    --sw-bg: #ffffff;
    --sw-bg-soft: #f8fafc;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    color: var(--sw-text);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: clip;
    container-type: inline-size;
}

.sc-switcher *,
.sc-switcher *::before,
.sc-switcher *::after { box-sizing: border-box; }

.sc-switcher [hidden] { display: none !important; }

/* ── Notice / single-tenant CTA ─── */

.sc-switcher--notice {
    padding: 18px 22px;
    background: var(--sw-bg-soft);
    border: 1px dashed var(--sw-border);
    border-radius: 8px;
    color: var(--sw-muted);
    text-align: center;
    font-size: 14px;
}

.sc-switcher--single { padding: 0; }

.sc-switcher__cta-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--sw-primary);
    color: #fff !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    transition: background 0.15s;
}
.sc-switcher__cta-button:hover { background: var(--sw-primary-hover); color: #fff !important; }

/* ── Header / search ─────────── */

.sc-switcher__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.sc-switcher__title {
    /* Section titles: portal-typography.css. Form labels: dropdown/workspace overrides. */
    margin: 0;
}

.sc-switcher__count {
    color: var(--sw-muted);
    font-size: 13px;
}

.sc-switcher__search {
    position: relative;
    margin-bottom: 14px;
}

.sc-switcher__search-input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border: 1px solid var(--sw-border);
    border-radius: 8px;
    background: var(--sw-bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23646970' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 14px center;
    font-size: 14px;
    font-family: inherit;
    color: var(--sw-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sc-switcher__search-input:focus {
    outline: none;
    border-color: var(--sw-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

.sc-switcher__search-count {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sw-muted);
    font-size: 12px;
    pointer-events: none;
}

.sc-switcher__empty {
    padding: 24px;
    text-align: center;
    color: var(--sw-muted);
    font-style: italic;
    background: var(--sw-bg-soft);
    border-radius: 8px;
}

/* ── Cards layout ─────────────── */

.sc-switcher__grid {
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}
.sc-switcher__grid[data-columns="1"] { grid-template-columns: 1fr; }
.sc-switcher__grid[data-columns="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sc-switcher__grid[data-columns="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sc-switcher__grid[data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sc-switcher__grid > * { min-width: 0; }

@media (max-width: 900px) {
    .sc-switcher__grid[data-columns="3"],
    .sc-switcher__grid[data-columns="4"] { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .sc-switcher__grid[data-columns] { grid-template-columns: 1fr; }
}

/* Container queries handle narrow embeds (e.g., popup modals) where
   viewport media queries are too coarse. */
@container (max-width: 900px) {
    .sc-switcher__grid[data-columns="3"],
    .sc-switcher__grid[data-columns="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 600px) {
    .sc-switcher__grid[data-columns] { grid-template-columns: 1fr; }
}

.sc-switcher__card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--sw-bg);
    border: 1px solid var(--sw-border);
    border-radius: 10px;
    text-decoration: none !important;
    color: var(--sw-text) !important;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    min-width: 0;
    max-width: 100%;
}

.sc-switcher__card:hover {
    border-color: var(--sw-primary);
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.10);
    transform: translateY(-1px);
}

.sc-switcher__card-logo {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--sw-bg-soft);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sc-switcher__card-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sc-switcher__card-logo--placeholder {
    background: linear-gradient(135deg, #e7f1f9, #d1e3f3);
    color: var(--sw-primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.04em;
}

.sc-switcher__card-body {
    flex: 1;
    min-width: 0;
}

.sc-switcher__card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--sw-text);
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.sc-switcher__card-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--sw-muted);
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.sc-switcher__card-arrow {
    flex: 0 0 auto;
    color: var(--sw-muted);
    font-size: 18px;
    transition: transform 0.15s, color 0.15s;
}

/* Brokers section */
.sc-switcher--brokers { margin-bottom: 28px; }
.sc-switcher--brokers .sc-switcher__card { border-color: rgba(45, 19, 80, 0.18); }
.sc-switcher--brokers .sc-switcher__card:hover {
    border-color: #5F2F9E;
    box-shadow: 0 4px 12px rgba(95, 47, 158, 0.14);
}
.sc-switcher__broker-badge {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(45, 19, 80, 0.10);
    color: #2D1350;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sc-switcher__card:hover .sc-switcher__card-arrow {
    color: var(--sw-primary);
    transform: translateX(2px);
}

.sc-switcher__card[hidden] { display: none; }

/* ── List layout ─────────────── */

.sc-switcher__list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--sw-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--sw-bg);
}

.sc-switcher__list li { border-bottom: 1px solid #ebebeb; }
.sc-switcher__list li:last-child { border-bottom: none; }
.sc-switcher__list li[hidden] { display: none; }

.sc-switcher__row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    text-decoration: none !important;
    color: var(--sw-text) !important;
    transition: background 0.1s;
}

.sc-switcher__row:hover { background: var(--sw-bg-soft); }

.sc-switcher__row-name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sc-switcher__row-key {
    font-family: ui-monospace, "SF Mono", Monaco, Menlo, monospace;
    font-size: 12px;
    color: var(--sw-muted);
    background: var(--sw-bg-soft);
    padding: 2px 8px;
    border-radius: 4px;
}
.sc-switcher__row-arrow { font-size: 13px; color: var(--sw-primary); font-weight: 600; }

/* ── Dropdown layout ──────────── */

.sc-switcher--dropdown { max-width: 360px; }

.sc-switcher--dropdown .sc-switcher__title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--sw-muted);
    margin-bottom: 4px;
}

.sc-switcher__combo { position: relative; }

.sc-switcher__combo-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--sw-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--sw-bg);
}
.sc-switcher__combo-input:focus {
    outline: none;
    border-color: var(--sw-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

.sc-switcher__combo-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--sw-muted);
    cursor: pointer;
    font-size: 14px;
}

.sc-switcher__combo.is-open .sc-switcher__combo-toggle { transform: translateY(-50%) rotate(180deg); }

.sc-switcher__combo-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--sw-bg);
    border: 1px solid var(--sw-border);
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    max-height: 280px;
    overflow-y: auto;
}

.sc-switcher__combo-list { list-style: none; margin: 0; padding: 4px 0; }

.sc-switcher__combo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.1s;
}
.sc-switcher__combo-item > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sc-switcher__combo-item:hover,
.sc-switcher__combo-item.is-active { background: #f0f6fc; }
.sc-switcher__combo-item[hidden] { display: none; }

.sc-switcher__combo-key {
    font-family: ui-monospace, "SF Mono", Monaco, monospace;
    font-size: 11px;
    color: var(--sw-muted);
    background: var(--sw-bg-soft);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
}

.sc-switcher__combo-empty {
    padding: 14px;
    text-align: center;
    color: var(--sw-muted);
    font-size: 13px;
    font-style: italic;
}

/* ── Workspace picker (my-portal) ── */

.sc-switcher--workspace { max-width: 480px; }

.sc-switcher__workspace-hint {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--sw-muted);
    line-height: 1.45;
}

.sc-switcher__workspace-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.sc-switcher__workspace-select {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 1px solid var(--sw-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--sw-bg);
}

.sc-switcher__workspace-go {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--sw-primary, #2D1350);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.sc-switcher__workspace-go:hover {
    filter: brightness(1.08);
}
