.toggle-color-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.toggle-color-label {
    color: var(--bs-body-color);
    margin-bottom: 0;
}

/* Apple-style toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 2.4rem;
    height: 1.35rem;
    flex-shrink: 0;
    margin-bottom: 0;
    cursor: pointer;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    left: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

/* When the hidden Shiny checkbox (sibling in .toggle-color-row) is checked,
   style the toggle-slider as "on" via :has() on the parent row. */
.toggle-color-row:has(input[type="checkbox"]:checked) .toggle-slider {
    background-color: var(--bs-success);
    border-color: var(--bs-success);
}

.toggle-color-row:has(input[type="checkbox"]:checked) .toggle-slider::before {
    transform: translateY(-50%) translateX(1.05rem);
}

.toggle-switch:focus-visible .toggle-slider {
    outline: 2px solid var(--bs-success);
    outline-offset: 2px;
}

.toggle-color-picker {
    margin-bottom: 0.5rem;
}

.toggle-color-picker .form-group {
    margin-bottom: 0;
}

/*
Override some style of colourPicker::colourInput
when parent component is of class .toggle-color-picker--direction-up,
to make the color picker panel expand upwards instead of downwards.
*/
.toggle-color-picker--direction-up .colourpicker-input-container {
    display: flex;
    flex-direction: column-reverse;
}

.toggle-color-picker--direction-up .colourpicker-panel {
    bottom: 2.6em;
}
