/* Shared theme tokens. Dark palette is only active on /ui and reserved areas. */
html[data-bmf-dark-active="true"] {
    color-scheme: dark;
    --bmf-bg: #15161e;
    --bmf-background: #15161e;
    --bmf-page-bg: #15161e;
    --bmf-surface: #23242f;
    --bmf-surface-1: #23242f;
    --bmf-surface-2: #2b2c38;
    --bmf-surface-3: #343442;
    --bmf-card-bg: #23242f;
    --bmf-popover-bg: #282934;
    --bmf-input-bg: #1c1d27;
    --bmf-border: #41414f;
    --bmf-border-subtle: #353542;
    --bmf-text: #f1edf2;
    --bmf-text-primary: #f1edf2;
    --bmf-text-secondary: #c4b9c4;
    --bmf-muted: #b5a9b7;
    --bmf-muted-bg: #343442;
    --bmf-primary: #e887ad;
    --bmf-primary-hover: #f0a0c0;
    --bmf-accent: #e887ad;
    --bmf-accent-hover: #f0a0c0;
    --bmf-success: #8bdcb1;
    --bmf-error: #f6a1a9;
    --bmf-shadow: 0 18px 45px rgba(0, 0, 0, .32);
}

html[data-bmf-dark-active="true"] body {
    background: var(--bmf-bg);
    color: var(--bmf-text);
}

/* Generic UI components used by /ui and the management application. */
html[data-bmf-dark-active="true"] :is(
    .bmf-card,
    .bmf-panel,
    .bmf-section-card,
    .bmf-ui-card,
    .bmf-modal,
    .bmf-modal-content,
    .bmf-dialog,
    .bmf-drawer,
    .bmf-popover,
    .bmf-dropdown-menu,
    .bmf-dropdown__menu,
    .bmf-data-table,
    .bmf-table-scroll,
    .bmf-tabs,
    .bmf-list,
    .bmf-calendar,
    .bmf-metric-card,
    .bmf-notice
) {
    background-color: var(--bmf-surface);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] :is(.bmf-card, .bmf-panel, .bmf-ui-card, .bmf-modal, .bmf-popover) :is(h1,h2,h3,h4,strong) {
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] :is(.bmf-muted, .bmf-help, .bmf-description, .bmf-hint) {
    color: var(--bmf-muted);
}
html[data-bmf-dark-active="true"] :is(.bmf-input, .bmf-select, .bmf-textarea, .bmf-text-input, .bmf-search-input, .bmf-data-table input, .bmf-data-table select) {
    color: var(--bmf-text);
    background: var(--bmf-input-bg);
    border-color: var(--bmf-border);
}
html[data-bmf-dark-active="true"] :is(.bmf-input, .bmf-select, .bmf-textarea, .bmf-text-input, .bmf-search-input) :is(option,optgroup) {
    color: var(--bmf-text);
    background: var(--bmf-input-bg);
}
html[data-bmf-dark-active="true"] :is(input, textarea, select)::placeholder {
    color: #a99cad;
    opacity: 1;
}
html[data-bmf-dark-active="true"] :is(.bmf-table thead, .bmf-data-table__tools, .bmf-data-table__paging, .bmf-table-filter-row) {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] :is(.bmf-table, .bmf-table th, .bmf-table td, .bmf-table-sort, .bmf-data-table strong) {
    color: var(--bmf-text);
    border-color: var(--bmf-border-subtle);
}
html[data-bmf-dark-active="true"] .bmf-table tbody tr:hover {
    background: var(--bmf-surface-3);
}
html[data-bmf-dark-active="true"] :is(.bmf-dropdown-menu, .bmf-dropdown__menu, .bmf-popover, .bmf-modal) button:not([class*="primary"]):hover {
    background: var(--bmf-surface-3);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] :is(.bmf-tabs, .bmf-list, .bmf-data-table) :is(a,button):focus-visible {
    outline: 2px solid var(--bmf-accent);
    outline-offset: 2px;
}

/* Account preference control, available even when the landing is kept light. */
.bmf-theme-control {
    padding: 12px 12px 14px;
    margin-top: 4px;
    border-top: 1px solid #f1e7ec;
}
.bmf-theme-control__label {
    display:block;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #745c69;
}
.bmf-theme-control__choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: 11px;
    background: #f7eff3;
}
.bmf-theme-control__choices button {
    display: block;
    min-height: 34px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 13px;
    color: #6d5362;
    cursor: pointer;
}
.bmf-theme-control__choices button[aria-pressed="true"] {
    background: #fff;
    border-color: #eadce4;
    color: #a84672;
    font-weight: 750;
    box-shadow: 0 2px 5px rgba(86, 54, 69, .08);
}
.bmf-theme-control__choices button:focus-visible { outline:2px solid #b8587d; outline-offset:2px; }
html[data-bmf-dark-active="true"] .bmf-theme-control { border-color: var(--bmf-border); }
html[data-bmf-dark-active="true"] .bmf-theme-control__label { color: var(--bmf-text-secondary); }
html[data-bmf-dark-active="true"] .bmf-theme-control__choices { background: var(--bmf-input-bg); }
html[data-bmf-dark-active="true"] .bmf-theme-control__choices button { color: var(--bmf-text-secondary); }
html[data-bmf-dark-active="true"] .bmf-theme-control__choices button[aria-pressed="true"] {
    background: var(--bmf-surface-3);
    border-color: #6f5469;
    color: #ffb0d1;
    box-shadow: none;
}


/* BookMyFiller UI showcase — dark surface and control coverage, v4.4.3. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] {
    --bmf-bg: #15161e;
    --bmf-surface: #242530;
    --bmf-surface-2: #2d2e3a;
    --bmf-surface-3: #383947;
    --bmf-input-bg: #1c1d27;
    --bmf-border: #484653;
    --bmf-border-subtle: #383944;
    --bmf-text: #f4f0f5;
    --bmf-text-secondary: #d4c9d4;
    --bmf-muted: #bdb1c0;
    --bmf-primary: #e88caf;
    --bmf-primary-hover: #f2a8c6;
    --bmf-focus: rgba(232, 140, 175, .35);
    --bmf-shadow: 0 15px 40px rgba(0,0,0,.36);
    color-scheme: dark;
}

/* The sidebar, page header, marketing previews and cards often have fixed light colors. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] [data-bmf-dark-surface="true"] {
    background-color: var(--bmf-surface) !important;
    border-color: var(--bmf-border) !important;
    box-shadow: 0 8px 22px rgba(0,0,0,.14);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] [data-bmf-dark-surface="true"][data-bmf-dark-elevated="true"] {
    background-color: var(--bmf-surface-2) !important;
    background-image: none !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] [data-bmf-dark-ink="true"] {
    color: var(--bmf-text) !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] [data-bmf-dark-muted="true"] {
    color: var(--bmf-text-secondary) !important;
}

/* Common UI containers, semantic overlays and table internals. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    [role="dialog"], [role="menu"], [role="listbox"],
    [role="tooltip"], [role="grid"],
    .bmf-modal__content, .bmf-modal__panel, .bmf-modal__dialog,
    .bmf-dialog__content, .bmf-drawer__content,
    .bmf-table__container, .bmf-data-table__container,
    .bmf-calendar__popover, .bmf-datepicker__popover,
    .bmf-select__menu, .bmf-autocomplete__menu,
    .bmf-dropdown__panel, .bmf-toast,
    [class$="__popover"], [class$="__dropdown-menu"]
) {
    background-color: var(--bmf-surface) !important;
    border-color: var(--bmf-border) !important;
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    table, thead, tbody, tfoot, tr, th, td,
    [role="row"], [role="columnheader"], [role="cell"],
    .bmf-data-table__head, .bmf-data-table__body,
    .bmf-data-table__footer, .bmf-table-toolbar
) {
    border-color: var(--bmf-border-subtle);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(th, [role="columnheader"], thead tr) {
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    tbody tr:hover, [role="row"]:hover
):not([aria-selected="true"]) {
    background-color: rgba(255,255,255,.035);
}

/* Native and wrapped form fields. Leave color swatches, toggles and semantic indicators intact. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
    textarea, select, [role="textbox"], [role="combobox"],
    [contenteditable="true"], .bmf-input, .bmf-select, .bmf-textarea
) {
    background-color: var(--bmf-input-bg) !important;
    border-color: var(--bmf-border) !important;
    color: var(--bmf-text) !important;
    caret-color: var(--bmf-primary);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(input,textarea,select,[role="textbox"],[role="combobox"])::placeholder {
    color: var(--bmf-muted) !important;
    opacity: 1;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    input, textarea, select, button, a, [tabindex]:not([tabindex="-1"]),
    [role="combobox"], [role="switch"]
):focus-visible {
    outline: 2px solid var(--bmf-primary);
    outline-offset: 2px;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(input[type="checkbox"],input[type="radio"],input[type="range"]) {
    accent-color: var(--bmf-primary);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] input[type="file"] {
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] input[type="file"]::file-selector-button {
    background: var(--bmf-surface-2);
    border: 1px solid var(--bmf-border);
    border-radius: 7px;
    color: var(--bmf-text);
    padding: 7px 12px;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    button:not([class*="primary"]):not([class*="accent"]):not([class*="danger"]):not([class*="success"]),
    [role="button"]:not([class*="primary"]):not([class*="accent"])
)[data-bmf-dark-control="true"] {
    background-color: var(--bmf-surface-2) !important;
    color: var(--bmf-text) !important;
    border-color: var(--bmf-border) !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(button,[role="button"])[data-bmf-dark-control="true"]:hover {
    background-color: var(--bmf-surface-3) !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    button:disabled, input:disabled, select:disabled, textarea:disabled,
    [aria-disabled="true"]
) {
    opacity: .62;
}

/* Consistent contrast for informational panels, pills and muted captions. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    .bmf-helper, .bmf-field-hint, .bmf-form-hint, .bmf-muted,
    .bmf-caption, .bmf-subtitle, small
) { color: var(--bmf-muted); }
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    hr, .bmf-divider, [role="separator"]
) { border-color: var(--bmf-border); }
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] ::selection {
    background-color: #b4517e;
    color: #fff;
}

/* The UI controls remain in contrast even when a modal is portaled to body. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(dialog,dialog[open]) {
    background-color: var(--bmf-surface);
    color: var(--bmf-text);
    border-color: var(--bmf-border);
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(dialog::backdrop, .bmf-modal__backdrop) {
    background-color: rgba(8, 9, 16, .74);
}

/* Semantic feedback uses subdued dark tints rather than bright light panels. */
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    .bmf-alert--success, .bmf-notice--success, .bmf-toast--success,
    .bmf-alert.is-success, .bmf-notice.is-success
) {
    background: #203b30 !important;
    border-color: #426b55 !important;
    color: #b9f0d0 !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    .bmf-alert--warning, .bmf-notice--warning, .bmf-toast--warning,
    .bmf-alert.is-warning, .bmf-notice.is-warning
) {
    background: #443824 !important;
    border-color: #826536 !important;
    color: #ffe5a8 !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    .bmf-alert--danger, .bmf-alert--error, .bmf-notice--error,
    .bmf-toast--error, .bmf-alert.is-error, .bmf-notice.is-error
) {
    background: #472a36 !important;
    border-color: #8c5163 !important;
    color: #ffc2d1 !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(
    .bmf-alert--info, .bmf-notice--info, .bmf-toast--info,
    .bmf-alert.is-info, .bmf-notice.is-info
) {
    background: #24374a !important;
    border-color: #43617d !important;
    color: #c2e0ff !important;
}
html[data-bmf-dark-active="true"][data-bmf-ui-route="true"] :is(aside,header,nav) :is(.bmf-icon,svg:not([class*="logo"])) {
    color: var(--bmf-text-secondary);
}

/* Hide outline on navigation-focused headings; preserve keyboard control focus. */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Icon-only appearance selector in the account dropdown. */
.bmf-account-menu .bmf-theme-control__choices {
    display: flex;
    justify-content: flex-start;
    width: max-content;
    max-width: 100%;
}
.bmf-account-menu .bmf-theme-control__choices button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 39px;
    min-width: 39px;
    height: 36px;
    min-height: 36px;
    padding: 0;
}
.bmf-account-menu .bmf-theme-control__choices button svg {
    display: block;
    width: 18px;
    height: 18px;
    flex: none;
}


/* Dark interaction states: maintain contrast without light-theme pink surfaces. */
html[data-bmf-dark-active="true"] .bmf-grouped-tree__group {
    background: var(--bmf-surface);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__group > summary:hover {
    background: var(--bmf-surface-2);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__group > summary:focus-visible {
    outline: 2px solid var(--bmf-primary);
    outline-offset: -2px;
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__count {
    background: var(--bmf-surface-3);
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__search {
    background: var(--bmf-input-bg);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__search:focus-within {
    border-color: var(--bmf-primary);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__search input {
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__search input::placeholder {
    color: var(--bmf-muted);
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree .bmf-grouped-tree__leaf {
    background: transparent;
    color: var(--bmf-text) !important;
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree .bmf-grouped-tree__leaf[href]:is(:hover, :focus-visible) {
    background: var(--bmf-surface-3);
    color: var(--bmf-text) !important;
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree .bmf-grouped-tree__leaf[href]:focus-visible {
    outline: 2px solid var(--bmf-primary);
    outline-offset: -2px;
}
html[data-bmf-dark-active="true"] .bmf-grouped-tree__leaf > .bmf-icon {
    color: var(--bmf-primary);
}

/* The same palette is used by reusable tree navigation and selection chips. */
html[data-bmf-dark-active="true"] .bmf-tree-nav {
    background: var(--bmf-surface-2);
}
html[data-bmf-dark-active="true"] .bmf-tree-nav :is(.bmf-tree-node__button, .bmf-tree-node__link) {
    color: var(--bmf-text) !important;
}
html[data-bmf-dark-active="true"] .bmf-tree-nav :is(.bmf-tree-node__button, .bmf-tree-node__link):is(:hover, :focus-visible) {
    background: var(--bmf-surface-3);
    color: var(--bmf-text) !important;
}
html[data-bmf-dark-active="true"] .bmf-chip {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-chip:hover {
    background: var(--bmf-surface-3);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-chip.is-selected {
    background: #493343;
    border-color: #8b6176;
    color: #ffe4ef;
}

/* Shared calendar: no white navigation, hover, or selected-day panels. */
html[data-bmf-dark-active="true"] .bmf-calendar {
    background: var(--bmf-surface);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__title {
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__view-picker {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__view-picker button {
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__view-picker button.is-selected {
    background: var(--bmf-surface-3);
    color: var(--bmf-text);
    box-shadow: none;
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__navigation button {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__navigation button:is(:hover, :focus-visible) {
    background: var(--bmf-surface-3);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__navigation button.bmf-calendar__today {
    color: var(--bmf-primary);
}
html[data-bmf-dark-active="true"] .bmf-calendar__day {
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-calendar__day:hover:not(.is-selected) {
    background: var(--bmf-surface-3);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar__day.is-selected {
    background: #73475e;
    color: #fff;
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-day {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-day.is-selected {
    background: #372d3b;
    border-color: #895e76;
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-heading {
    background: var(--bmf-surface-3);
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-heading.is-selected {
    background: #4d3547;
    color: #f9d3e3;
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-content .bmf-calendar__event {
    background: #40313f;
    border-color: #705065;
    border-left-color: var(--bmf-primary);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar .bmf-calendar__schedule-content .bmf-calendar__event strong {
    color: #ffc7df;
}
html[data-bmf-dark-active="true"] .bmf-calendar__agenda button {
    background: var(--bmf-surface-2);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-calendar__agenda button:hover {
    background: var(--bmf-surface-3);
}
html[data-bmf-dark-active="true"] .bmf-slot {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-slot:is(.is-selected, :hover) {
    background: #73475e;
    border-color: #95637c;
    color: #fff;
}

/* Other reusable controls with fixed light backgrounds. */
html[data-bmf-dark-active="true"] .bmf-input-wrap .bmf-suggestion-list {
    background: var(--bmf-surface);
    border-color: var(--bmf-border);
    box-shadow: var(--bmf-shadow);
}
html[data-bmf-dark-active="true"] .bmf-input-wrap .bmf-suggestion-list .bmf-suggestion {
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-input-wrap .bmf-suggestion-list .bmf-suggestion:is(:hover, :focus-visible) {
    background: var(--bmf-surface-3);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-image-upload__preview {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-primary);
}
html[data-bmf-dark-active="true"] .bmf-file-picker__item {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
html[data-bmf-dark-active="true"] .bmf-step span,
html[data-bmf-dark-active="true"] .bmf-treatment__icon {
    background: var(--bmf-surface-3);
    color: var(--bmf-text-secondary);
}
html[data-bmf-dark-active="true"] .bmf-step:is(.is-active, .is-done) span {
    background: #73475e;
    color: #fff;
}
html[data-bmf-dark-active="true"] .bmf-doctor {
    background: var(--bmf-surface-2);
    border-color: var(--bmf-border);
    color: var(--bmf-text);
}
