/* ── Switch / checkbox baseline ─────────────────────────────────────── */
/* Standing in for the parts of Bootstrap's form-check/form-switch that
   dash-bootstrap-components renders, since the app runs fully offline
   and doesn't load Bootstrap's CSS from a CDN. */
.form-check {
    display: flex;
    align-items: center;
    padding-left: 0;
    margin-bottom: 0;
}

.form-switch .form-check-input {
    appearance: none;
    -webkit-appearance: none;
    width: 2.5em;
    height: 1.4em;
    margin: 0;
    background-color: rgba(var(--color-shadow-rgb), 0.15);
    border: 1px solid rgba(var(--color-shadow-rgb), 0.15);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease-in-out;
}

.form-switch .form-check-input::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(1.4em - 4px);
    height: calc(1.4em - 4px);
    border-radius: 50%;
    background-color: #fff;
    transition: transform 0.15s ease-in-out;
}

.form-switch .form-check-input:checked {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

.form-switch .form-check-input:checked::before {
    transform: translateX(1.1em);
}

.form-switch .form-check-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.form-switch .form-check-input:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: 2px;
}

/* Plain (non-switch) checkbox — dbc.Checkbox renders a .form-check wrapper
   without the .form-switch modifier dbc.Switch adds, so it would otherwise
   fall through to the browser's native control and ignore the theme.
   Same accent/disabled/focus language as the switch above. */
.form-check:not(.form-switch) .form-check-input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.05em;
    height: 1.05em;
    margin: 0;
    background-color: var(--color-bg-surface);
    border: 1px solid rgba(var(--color-shadow-rgb), 0.3);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.form-check:not(.form-switch) .form-check-input[type="checkbox"]:checked {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

/* Rotated-rectangle tick rather than a glyph, so it stays crisp at this
   size without depending on any font. */
.form-check:not(.form-switch) .form-check-input[type="checkbox"]:checked::before {
    content: "";
    position: absolute;
    top: 0.08em;
    left: 0.31em;
    width: 0.3em;
    height: 0.58em;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-check:not(.form-switch) .form-check-input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.form-check:not(.form-switch) .form-check-input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: 2px;
}

/* ── dcc.Dropdown ──────────────────────────────────────────────────────
   Dash 4's Dropdown ships its own baked-in default appearance (a fixed
   border color unrelated to this app's tokens), same "renders but doesn't
   match our palette" situation as dbc components — overridden here so it
   also responds to the dark theme. Class names (dash-dropdown-*,
   dash-options-list-*) come from the component's runtime markup, not a
   documented API — recheck if the Dash version changes. */
.dash-dropdown {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-bg-surface);
    font-family: var(--font-family);
}

.dash-dropdown-grid-container {
    padding: 8px 12px;
}

.dash-dropdown-value,
.dash-dropdown-value-item {
    color: var(--color-text-main);
}

.dash-dropdown-placeholder {
    color: var(--color-text-muted);
}

.dash-dropdown-trigger-icon {
    color: var(--color-text-muted);
}

.dash-dropdown-content {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(var(--color-shadow-rgb), 0.12);
    padding: 6px;
}

.dash-dropdown-search-container {
    background-color: var(--color-bg-surface);
}

.dash-dropdown-search {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 4px;
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--color-text-main);
}

/* Kept in sync with (and slightly above) the `maxHeight` prop set on the
   sidebar filter dropdowns (components/analysis_sidebar.py) — with a small
   gap between the two, .dash-dropdown-content (the actual popup, sized via
   that prop) is always the one that clips/scrolls first, so this inner
   list's own overflow rarely triggers, avoiding two independent, stacked
   scrollbars for what's visually one list. */
.dash-options-list {
    max-height: 620px;
    overflow-y: auto;
}

.dash-dropdown-option {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--color-text-main);
    cursor: pointer;
}

.dash-dropdown-option:hover {
    background-color: rgba(var(--color-accent-rgb), 0.08);
}

.dash-dropdown-option.selected {
    background-color: rgba(var(--color-accent-rgb), 0.12);
    color: var(--color-accent);
}

.dash-dropdown-option[aria-disabled="true"] {
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.dash-options-list-option-checkbox {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}