/* Mosaic shared UI primitives. Page-specific layout stays in the layer files. */
/* Shared control geometry */
.ui-button.is-busy {
  cursor: progress;
}

.ui-button.is-disabled,
.ui-field-control.is-disabled {
  cursor: not-allowed;
}

.ui-field-control:disabled,
.ui-field-control[aria-disabled="true"] {
  opacity: 1;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-subtle);
  -webkit-text-fill-color: var(--text-secondary);
}

.ui-field-control.is-invalid {
  background: var(--state-danger-surface);
}

.search-box,
.sort-select,
.filter-chip,
.filter-trigger,
.theme-toggle,
.sidebar-collapse,
.ui-select-trigger {
  min-height: var(--control-compact);
  height: var(--control-compact);
  border-radius: var(--control-radius);
}

.primary-button,
.secondary-button,
.toolbar-action {
  min-height: var(--control-standard);
  height: var(--control-standard);
  border-radius: var(--control-radius);
}
.toolbar-action {
  min-height: var(--control-compact);
  height: var(--control-compact);
  padding-inline: 10px;
  font-size: 11px;
}

.primary-nav .nav-item {
  min-height: var(--control-compact);
  height: var(--control-compact);
}

.secondary-button.filter-trigger {
  min-height: var(--control-compact);
  height: var(--control-compact);
  padding-inline: 10px;
}

.form-fields input,
.form-fields textarea,
.upload-form-fields input,
.upload-form-fields textarea,
.upload-item-fields input,
.ui-select-trigger {
  font-size: 12px;
}

.form-fields input,
.upload-form-fields input,
.upload-item-fields input,
.form-fields .ui-select-trigger,
.upload-form-fields .ui-select-trigger,
.upload-item-fields .ui-select-trigger {
  min-height: var(--control-standard);
  height: var(--control-standard);
}

.modal-footer .primary-button,
.modal-footer .secondary-button,
.workspace-actions .primary-button,
.workspace-actions .secondary-button {
  min-height: var(--control-standard);
  height: var(--control-standard);
}

.icon-button,
.view-toggle,
.density-step {
  width: var(--control-compact);
  min-width: var(--control-compact);
  height: var(--control-compact);
  min-height: var(--control-compact);
  border-radius: var(--control-radius);
}

.workspace-view-tools .view-toggle {
  width: var(--control-compact);
  height: var(--control-compact);
}

/* A native select remains the form value and compatibility surface only. */
.ui-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ui-select {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
}

.ui-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 92px;
  padding: 0 8px 0 10px;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: var(--surface-subtle);
  text-align: left;
}

.ui-select-trigger:hover {
  background: var(--surface-hover);
}

.ui-select-trigger:focus-visible,
.ui-select-trigger[aria-expanded="true"] {
  background: var(--surface-selected);
}

.ui-select-trigger:disabled {
  color: var(--text-disabled);
  background: var(--surface-disabled);
  cursor: not-allowed;
}

.ui-select-trigger .lucide {
  width: 13px;
  color: var(--text-secondary);
}

.ui-select-menu {
  position: fixed;
  z-index: var(--layer-tooltip);
  display: grid;
  gap: 2px;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--separator);
  border-radius: 7px;
  color: var(--text-primary);
  background: var(--surface-base);
  box-shadow: var(--shadow-menu);
}

.ui-select-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-standard);
  padding: 0 10px;
  border-radius: 5px;
  color: var(--text-primary);
  background: transparent;
  font-size: 12px;
  text-align: left;
}

.ui-select-option:hover,
.ui-select-option:focus-visible {
  outline: 0;
  background: var(--surface-hover);
}

.ui-select-option[aria-selected="true"] {
  background: var(--surface-selected);
  font-weight: 650;
}

.ui-select-option:disabled {
  color: var(--text-disabled);
}

/* Border budget: controls use surface contrast; borders remain for separators and overlays. */
.search-box,
.sort-select,
.filter-chip,
.filter-trigger,
.secondary-button,
.theme-toggle,
.sidebar-collapse,
.workspace-view-tools,
.density-control {
  border-color: transparent;
  box-shadow: none;
}

.search-box,
.sort-select,
.secondary-button,
.sidebar-collapse,
.workspace-view-tools,
.density-control {
  background: var(--surface-subtle);
}
.theme-toggle {
  background: transparent;
}

.search-box:focus-within,
.sort-select:focus-within {
  background: var(--surface-selected);
}

.filter-chip,
.filter-trigger {
  background: transparent;
}

.filter-chip:hover,
.filter-trigger:hover,
.secondary-button:hover,
.sidebar-collapse:hover {
  background: var(--surface-hover);
}
.theme-toggle:hover { background: var(--surface-hover); }

.filter-chip.is-active,
.view-toggle.is-active {
  color: var(--text-primary);
  background: var(--surface-selected);
}

.nav-item,
.side-filter,
.side-link {
  color: var(--text-secondary);
}

.nav-item:hover,
.side-filter:hover,
.side-link:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.nav-item.is-active,
.side-filter[aria-pressed="true"],
.side-link[aria-pressed="true"] {
  color: var(--text-primary);
  background: var(--surface-selected);
}

.avatar {
  color: var(--text-primary);
  background: var(--surface-selected);
}

.toast {
  border-color: transparent;
  color: var(--text-primary);
  background: var(--surface-base);
  box-shadow: var(--shadow-toast);
}

.toast.error {
  border-color: transparent;
  color: var(--state-danger-text);
  background: var(--state-danger-surface);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.ui-select-trigger:focus-visible {
  outline: 0;
  background: var(--surface-selected);
}

.modal-backdrop {
  background: var(--overlay-scrim);
}

.primary-button:disabled {
  color: var(--text-disabled);
  background: var(--surface-disabled);
}

html[data-theme="dark"] .primary-button:not(:disabled) {
  color: var(--primary-foreground);
  background: var(--primary-background);
}

html[data-theme="dark"] .primary-button:not(:disabled):hover {
  color: var(--primary-foreground);
  background: var(--primary-hover);
}

html[data-theme="dark"] .search-box,
html[data-theme="dark"] .sort-select,
html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .sidebar-collapse {
  border-color: transparent;
  background: var(--surface-subtle);
}

html[data-theme="dark"] .filter-trigger {
  border-color: transparent;
  background: transparent;
}

html[data-theme="dark"] .filter-trigger.has-filters {
  border-color: transparent;
  background: var(--surface-selected);
}

.empty-state .empty-mark {
  color: var(--text-secondary);
  background: transparent;
  box-shadow: none;
}

/* Filter controls form a compact popover rather than a full-width framed band. */
.filter-popover {
  width: fit-content;
  max-width: calc(100vw - 32px);
  border: 0;
  border-radius: 8px;
  background: var(--surface-base);
  box-shadow: var(--shadow-popover);
}

.filter-popover-grid {
  gap: 8px;
}

html[data-theme="dark"] .filter-popover {
  background: var(--surface-base);
}

/* Semantic status surfaces stay readable in both themes and never borrow route colors. */
.status-badge.processing,
.preview-indicator.preview-checking,
.media-route-state.checking,
.task-state.processing {
  color: var(--state-info-text);
  background: var(--state-info-surface);
}

.preview-indicator.preview-enabled,
.preview-indicator.preview-available {
  color: var(--route-local);
  background: color-mix(in srgb, var(--nas-soft) 76%, transparent);
}

.publish-check.has-blockers,
.status-badge.pending,
.upload-validation.unavailable,
.upload-validation.incomplete {
  color: var(--state-warning-text);
  background: var(--state-warning-surface);
}

.upload-validation.checking {
  color: var(--state-info-text);
}

.task-icon.failed,
.task-state.failed,
.upload-task-row.failed .upload-task-state,
.upload-validation.failed,
.upload-validation.duplicate,
.preview-indicator.preview-unavailable,
.media-route-state.unavailable,
.form-error {
  color: var(--state-danger-text);
}

.task-icon.failed,
.upload-task-row.failed .upload-task-state,
.preview-indicator.preview-unavailable,
.media-route-state.unavailable {
  background: var(--state-danger-surface);
}

.publish-check.is-ready,
.status-badge.ready,
.status-badge.ingesting,
.task-state.success {
  color: var(--state-success-text);
  background: var(--state-success-surface);
}

.task-name,
.task-detail {
  color: var(--text-primary);
}

.task-detail {
  color: var(--text-secondary);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .main-shell {
  background: var(--surface-canvas);
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .inspector,
html[data-theme="dark"] .modal {
  color: var(--text-primary);
  background: var(--surface-chrome);
}

html[data-theme="dark"] .sidebar {
  border-color: var(--separator);
}

html[data-theme="dark"] .nav-item,
html[data-theme="dark"] .side-filter,
html[data-theme="dark"] .side-link,
html[data-theme="dark"] .theme-toggle {
  color: var(--text-secondary);
}

html[data-theme="dark"] .nav-item:hover,
html[data-theme="dark"] .side-filter:hover,
html[data-theme="dark"] .side-link:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

html[data-theme="dark"] .nav-item.is-active,
html[data-theme="dark"] .side-filter[aria-pressed="true"],
html[data-theme="dark"] .side-link[aria-pressed="true"] {
  color: var(--text-primary);
  background: var(--surface-selected);
}

@media (max-width: 640px) {
  .icon-button,
  .view-toggle,
  .density-step,
  .filter-chip,
  .side-filter,
  .side-link,
  .sidebar-collapse,
  .theme-toggle,
  .toolbar-action {
    min-width: var(--control-touch);
    min-height: var(--control-touch);
  }
  .toolbar-action {
    height: var(--control-touch);
  }
  .icon-button,
  .view-toggle,
  .density-step {
    width: var(--control-touch);
    height: var(--control-touch);
  }
  .ui-select-trigger,
  .ui-select-option,
  .primary-button,
  .secondary-button {
    min-height: var(--control-touch);
  }
}
