/* CrewDeck button states: selection uses fill/text, never a blue outer ring.
   Keep text-field focus and domain/status colors in their owning components.
   The important layer also contains late-injected module and UA focus styles. */
@layer cd-control-states {
  :where(button, a[href], select, [role="button"], [role="tab"],
    [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"],
    input:is([type="button"],[type="submit"],[type="reset"],[type="image"],[type="checkbox"],[type="radio"]),
    [tabindex]:not(input):not(textarea):not(select):not([contenteditable="true"])):not(.pui-ringed) {
    --tw-ring-shadow: 0 0 #0000 !important;
    --tw-ring-offset-shadow: 0 0 #0000 !important;
  }

  :where(button, a[href], select, [role="button"], [role="tab"],
    [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"],
    input:is([type="button"],[type="submit"],[type="reset"],[type="image"],[type="checkbox"],[type="radio"]),
    [tabindex]:not(input):not(textarea):not(select):not([contenteditable="true"])):not(.pui-ringed):focus {
    outline: none !important;
  }

  /* Active choices retain their owning fill/text shade. No focus ring or underline. */
  :where(button, a[href], select, [role="button"], [role="tab"],
    [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"],
    input:is([type="button"],[type="submit"],[type="reset"],[type="image"],[type="checkbox"],[type="radio"]),
    [tabindex]:not(input):not(textarea):not(select):not([contenteditable="true"])):not(.pui-ringed):focus-visible {
    outline: none !important;
    box-shadow: none !important;
  }

  /* Audited outline-style selections. Filled labels/checkmarks stay intact. */
  .proj-view-btn.active,
  .view-toggle-btn.active,
  .timeline-tab.active:not(.status-today):not(.status-future):not(.status-past),
  .permission-action-btn.is-active,
  .btn-ai-toggle.active,
  .dcs-type-pill.active,
  .pv-btn.active,
  .recip-dept-row.selected,
  .recip-pos-pill.selected,
  .cdob-channel-btn.selected,
  .pui-pill.selected,
  #overage-group-toggle.active,
  .pcm-root #pc-toolbar #pc-project-switcher-btn:active,
  .pcm-root .pc-wave-item-actions button:not(.danger):active,
  .pcm-root .pc-pay-actions button:active {
    border-color: transparent !important;
  }

  .pcm-root #send-form-overlay .sf-channel-btn.active {
    box-shadow: none !important;
  }

  .sheets-root .share-chip-perm:focus,
  .sheets-root .share-perm-select:focus {
    border-color: transparent !important;
  }
  .sheets-root .share-chip-perm:focus:not(:focus-visible),
  .sheets-root .share-perm-select:focus:not(:focus-visible) {
    box-shadow: none !important;
  }

  /* Dropdown triggers display the chosen value without an active treatment.
     Actual tabs, toggle buttons and menu options keep their selected shades. */
  .cd-chip:is([aria-haspopup="menu"], [aria-haspopup="listbox"]):not(.cdpj-source-switch),
  .cdpj-filter-chip {
    background: var(--bg3, #eef0f4) !important;
    color: var(--text2, #4b5563) !important;
    border-color: transparent !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    transform: none !important;
  }
  html.dark .cd-chip:is([aria-haspopup="menu"], [aria-haspopup="listbox"]):not(.cdpj-source-switch),
  html.dark .cdpj-filter-chip {
    background: var(--bg3, #1e2535) !important;
    color: var(--text2, #94a3b8) !important;
  }
  .cdpj-source-switch {
    background: var(--bg3, #f0f2f7) !important;
    color: var(--text-secondary, #586174) !important;
    border-color: var(--border-color, #dfe3ec) !important;
    box-shadow: none !important;
    transform: none !important;
  }
  html.dark .cdpj-source-switch {
    background: #242a38 !important;
    color: #bac3d6 !important;
    border-color: #303543 !important;
  }
  #cd-page-header :is(.cd-pghdr-chip, .cd-pghdr-accessory) {
    background: var(--bg-white, #fff) !important;
    color: var(--text-dark, #374151) !important;
    border-color: var(--border-color, #e5e7eb) !important;
    box-shadow: none !important;
    transform: none !important;
  }
  html.dark #cd-page-header :is(.cd-pghdr-chip, .cd-pghdr-accessory) {
    background: var(--bg-white, #181b24) !important;
    color: var(--text-dark, #e5e7eb) !important;
    border-color: var(--border-color, #2d3343) !important;
  }
  /* The Project filter keeps a 44px hit target, but only its inner pill is
     painted. Do not fill the enlarged rectangular button behind that pill. */
  html.cd-native:not(.cd-pghdr-module) #cd-page-header.cd-has-accessory .cd-pghdr-accessory:has([data-cdpj-filter]),
  html.cd-native #cd-page-header[data-cd-module-row] .cd-project-filter-trigger {
    background: transparent !important;
    border-color: transparent !important;
  }
  .bpg-version-selector {
    background: var(--bpg-bg2) !important;
    color: var(--bpg-text2) !important;
    border-color: var(--bpg-border) !important;
    box-shadow: none !important;
    transform: none !important;
  }

  /* Filter chips retain their normal appearance after a selection. */
  .workspace-tab.active {
    background: transparent !important;
    color: #6b7280 !important;
    box-shadow: none !important;
  }
  html.dark .workspace-tab.active { color: #9ca3af !important; }
  .pp-seg.active {
    background: #fff !important;
    color: #374151 !important;
    border-color: #e5e7eb !important;
  }
  .pp-seg.active .pp-seg-count {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
  }
  .pp-seg.active .pp-seg-dot { box-shadow: none !important; }
  html.dark .pp-seg.active {
    background: #1a1d29 !important;
    color: #cbd5e1 !important;
    border-color: #2d3148 !important;
  }
  html.dark .pp-seg.active .pp-seg-count {
    background: #252840 !important;
    color: #9ca3af !important;
  }
  .prm-root .pr-filter-chip.active {
    background: var(--bg3) !important;
    color: var(--text2) !important;
    border-color: var(--border) !important;
  }
  .cdpj-filters .cdpj-btn[aria-pressed="true"] {
    background: var(--pj-bg) !important;
    color: var(--pj-text) !important;
    border-color: var(--pj-line) !important;
  }
  .set-root .tx-filter-chip.tx-filter-active {
    background: transparent !important;
    color: #4b5563 !important;
    border-color: #d1d5db !important;
  }
  html.dark .set-root .tx-filter-chip.tx-filter-active {
    color: #d1d5db !important;
    border-color: #4b5563 !important;
  }

  @media (forced-colors: active) {
    :where(button, [role="button"], [role="tab"], [role="menuitem"],
      [role="checkbox"], [role="switch"], [tabindex]):not(.pui-ringed):focus-visible {
      outline-color: ButtonText !important;
      outline-style: solid !important;
      outline-width: 2px !important;
      outline-offset: 2px !important;
    }
  }
}
