/* Custom form controls — Apple-style checkboxes & menus */

/* ── Checkboxes ───────────────────────────────────────────── */
.app-shell input[type="checkbox"]:not(.ui-native),
body:not(.app-shell) input[type="checkbox"]:not(.ui-native) {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.app-shell input[type="checkbox"]:not(.ui-native):hover,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):hover {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.09);
}

.app-shell input[type="checkbox"]:not(.ui-native):checked,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):checked {
  background: var(--gradient-accent);
  border-color: var(--accent);
}

.app-shell input[type="checkbox"]:not(.ui-native):checked::after,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.app-shell input[type="checkbox"]:not(.ui-native):indeterminate,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):indeterminate {
  background: var(--gradient-accent);
  border-color: var(--accent);
}

.app-shell input[type="checkbox"]:not(.ui-native):indeterminate::after,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 7px;
  width: 10px;
  height: 2px;
  background: var(--bg);
  border: none;
  border-radius: 1px;
  transform: none;
}

.app-shell input[type="checkbox"]:not(.ui-native):focus-visible,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.app-shell input[type="checkbox"]:not(.ui-native):disabled,
body:not(.app-shell) input[type="checkbox"]:not(.ui-native):disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Custom menu (select enhancement) ─────────────────────── */
.select-wrap.ui-menu-wrap {
  display: block;
  width: 100%;
  position: relative;
}

.select-wrap.ui-menu-wrap::after {
  display: none;
}

.ui-menu {
  position: relative;
  width: 100%;
  min-width: 0;
}

.ui-menu__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ui-menu__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  height: var(--ui-menu-h, 32px);
  padding: 0 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.ui-menu__trigger:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

.ui-menu.is-open .ui-menu__trigger {
  border-color: var(--accent-muted);
  box-shadow: var(--focus-ring);
}

.ui-menu__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-menu__chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 200ms ease, color 150ms ease;
}

.ui-menu.is-open .ui-menu__chevron {
  transform: rotate(180deg);
  color: var(--text-secondary);
}

.ui-menu__panel {
  position: fixed;
  z-index: 1200;
  min-width: 120px;
  max-height: 280px;
  overflow: auto;
  padding: 4px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transform-origin: top center;
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.ui-menu.is-open .ui-menu__panel,
.ui-menu__panel--portaled.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ui-menu__panel[data-placement="up"] {
  top: auto;
  bottom: calc(100% + 6px);
  transform-origin: bottom center;
  transform: translateY(2px);
}

.ui-menu.is-open .ui-menu__panel[data-placement="up"],
.ui-menu__panel--portaled.is-open[data-placement="up"] {
  transform: translateY(0);
}

.ui-menu__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.25;
  color: var(--text-secondary);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.ui-menu__option:hover,
.ui-menu__option.is-focused {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.ui-menu__option.is-selected {
  color: var(--accent-hover);
}

.ui-menu__option.is-selected::after {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3'%3E%3Cpath d='M5 12l4 4L19 6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3'%3E%3Cpath d='M5 12l4 4L19 6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ui-menu__option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Compact variant for toolbar */
.ui-menu--sm .ui-menu__trigger {
  height: 30px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.ui-menu--sm .ui-menu__option {
  min-height: 28px;
  font-size: 0.75rem;
}

.ui-menu--drawer .ui-menu__trigger {
  height: 36px;
  font-size: 0.8125rem;
  border-radius: 8px;
  border-color: var(--border-strong);
}

.ui-menu__panel--portaled {
  z-index: 1300;
}

/* Override align.css native sizing */
.app-shell .check-label input[type="checkbox"]:not(.ui-native),
.app-shell .data-viewport__table .col-check input[type="checkbox"]:not(.ui-native),
.app-shell .runs-star-toggle input[type="checkbox"]:not(.ui-native) {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: unset;
}

.app-shell .select-wrap.ui-menu-wrap select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.app-shell .select-wrap.ui-menu-wrap {
  min-height: var(--ui-menu-h, 32px);
}
