/* UI primitives
   Single visual standard layer (buttons/cards/inputs/chips/icon-buttons).
   Use these classes in markup and keep feature files for layout only. */

:root {
  --ui-radius-control: 14px;
  --ui-radius-pill: 999px;
  --ui-radius-card: 16px;
  --ui-control-height: 40px;
  --ui-control-height-sm: 36px;
}

body.theme-material .ui-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--ui-radius-card);
  box-shadow: var(--shadow-1);
}

body.theme-material .ui-input,
body.theme-material .ui-select,
body.theme-material .ui-textarea {
  width: 100%;
  min-height: var(--ui-control-height);
  border: 1px solid var(--color-border-default);
  border-radius: var(--ui-radius-control);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  padding: 0 12px;
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

body.theme-material .ui-textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

body.theme-material .ui-input:focus-visible,
body.theme-material .ui-select:focus-visible,
body.theme-material .ui-textarea:focus-visible {
  outline: none;
  border-color: var(--color-focus-border);
  box-shadow: 0 0 0 2px var(--color-focus-ring);
}

body.theme-material .ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ui-control-height);
  padding: 0 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--ui-radius-pill);
  background: var(--color-bg-surface-alt);
  color: var(--color-text-primary);
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

body.theme-material .ui-btn:hover {
  border-color: var(--color-focus-border);
  background: var(--color-bg-hover);
  transform: translateY(-1px);
}

body.theme-material .ui-btn:focus-visible {
  outline: 2px solid var(--color-focus-border);
  outline-offset: 2px;
}

body.theme-material .ui-btn-primary {
  border-color: var(--color-brand-primary);
  background: var(--color-brand-primary);
  color: var(--color-brand-primary-foreground);
}

/* Semantic aliases for repeated actions.
   Use these classes in markup instead of per-feature button styles. */
body.theme-material .ui-btn-apply,
body.theme-material .ui-btn-save,
body.theme-material .ui-btn-confirm {
  border-color: var(--color-brand-primary);
  background: var(--color-brand-primary);
  color: var(--color-brand-primary-foreground);
}

body.theme-material .ui-btn-primary:hover {
  border-color: var(--color-brand-primary-hover);
  background: var(--color-brand-primary-hover);
  color: var(--color-brand-primary-foreground);
}

body.theme-material .ui-btn-apply:hover,
body.theme-material .ui-btn-save:hover,
body.theme-material .ui-btn-confirm:hover {
  border-color: var(--color-brand-primary-hover);
  background: var(--color-brand-primary-hover);
  color: var(--color-brand-primary-foreground);
}

body.theme-material .ui-btn-reset,
body.theme-material .ui-btn-cancel,
body.theme-material .ui-btn-dismiss,
body.theme-material .ui-btn-back {
  border-color: var(--color-border-strong);
  background: var(--color-bg-surface-alt);
  color: var(--color-text-secondary);
}

body.theme-material .ui-btn-reset:hover,
body.theme-material .ui-btn-cancel:hover,
body.theme-material .ui-btn-dismiss:hover,
body.theme-material .ui-btn-back:hover {
  border-color: var(--color-focus-border);
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

body.theme-material .ui-btn-delete,
body.theme-material .ui-btn-danger {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
  color: var(--color-text-primary);
}

body.theme-material .ui-btn-delete:hover,
body.theme-material .ui-btn-danger:hover {
  border-color: var(--color-danger);
  background: var(--color-danger);
  color: var(--color-brand-primary-foreground);
}

body.theme-material .ui-btn-close {
  width: var(--ui-control-height);
  min-width: var(--ui-control-height);
  height: var(--ui-control-height);
  padding: 0;
  border-radius: 50%;
}

body.theme-material .ui-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

body.theme-material .ui-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-text-secondary);
}

body.theme-material .ui-btn-ghost:hover {
  border-color: transparent;
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

/* Top-center controls: Фильтр / Сортировка / Выбрать / Новая задача */
body.theme-material .ui-btn-toolbar-ghost,
body.theme-material .ui-btn-toolbar-primary {
  min-height: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  box-shadow: none;
}

body.theme-material .ui-btn-toolbar-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

body.theme-material .ui-btn-toolbar-ghost:hover {
  background: var(--color-brand-primary-soft);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

body.theme-material .ui-btn-toolbar-ghost.is-active {
  background: var(--color-brand-primary-soft);
  color: var(--color-text-primary);
}

body.theme-material .ui-btn-toolbar-primary {
  background: var(--color-brand-primary-soft);
  color: var(--color-brand-primary-hover);
}

body.theme-material .ui-btn-toolbar-primary:hover {
  background: var(--color-brand-primary);
  color: var(--color-brand-primary-foreground);
  transform: translateY(-1px);
}

body.theme-material.dark-theme .ui-btn-toolbar-ghost {
  color: var(--color-text-primary);
}

body.theme-material.dark-theme .ui-btn-toolbar-ghost:hover,
body.theme-material.dark-theme .ui-btn-toolbar-ghost.is-active {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

body.theme-material.dark-theme .ui-btn-toolbar-primary {
  background: var(--color-brand-primary-soft);
  color: var(--color-brand-primary-foreground);
}

body.theme-material.dark-theme .ui-btn-toolbar-primary:hover {
  background: var(--color-brand-primary);
  color: var(--color-brand-primary-foreground);
}

/* Backward-compatible binding for existing center toolbar IDs */
body.theme-material :is(#main-filter-btn, #main-sort-btn, #bulk-select-btn) {
  min-height: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

body.theme-material :is(#main-filter-btn, #main-sort-btn, #bulk-select-btn):hover {
  background: var(--color-brand-primary-soft);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

body.theme-material #add-task-btn {
  min-height: 44px;
  height: 44px;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: #ffffff;
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

body.theme-material #add-task-btn:hover {
  background: #2563eb;
  color: #ffffff;
  transform: translateY(-1px);
}

body.theme-material.dark-theme :is(#main-filter-btn, #main-sort-btn, #bulk-select-btn) {
  color: var(--color-text-primary);
}

body.theme-material.dark-theme :is(#main-filter-btn, #main-sort-btn, #bulk-select-btn):hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

body.theme-material.dark-theme #add-task-btn {
  background: #3b82f6;
  color: #ffffff;
}

body.theme-material.dark-theme #add-task-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Bottom selection bar buttons: Выполнить / Удалить / Отмена */
body.theme-material .ui-btn-bulk,
body.theme-material .bulk-action-btn {
  border: none;
  background: var(--color-bg-muted);
  color: var(--color-text-secondary);
  border-radius: 999px;
  min-height: 40px;
  height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

body.theme-material .ui-btn-bulk:hover,
body.theme-material .bulk-action-btn:hover {
  background: var(--color-brand-primary-soft);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}

body.theme-material.dark-theme .ui-btn-bulk,
body.theme-material.dark-theme .bulk-action-btn {
  border: none;
  background: var(--color-bg-muted);
  color: var(--color-text-primary);
}

body.theme-material.dark-theme .ui-btn-bulk:hover,
body.theme-material.dark-theme .bulk-action-btn:hover {
  background: var(--color-brand-primary-soft);
  color: var(--color-text-primary);
}

body.theme-material .ui-icon-btn {
  width: var(--ui-control-height);
  min-width: var(--ui-control-height);
  height: var(--ui-control-height);
  padding: 0;
  border-radius: 50%;
}

body.theme-material .ui-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--color-brand-accent-soft);
  background: var(--color-brand-primary-soft);
  color: var(--color-brand-primary);
}

body.theme-material .ui-chip-muted {
  border-color: var(--color-border-default);
  background: var(--color-bg-muted);
  color: var(--color-text-secondary);
}

@media (max-width: 900px) {
  body.theme-material .ui-btn,
  body.theme-material .ui-input,
  body.theme-material .ui-select {
    min-height: 42px;
  }

  body.theme-material .ui-icon-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }
}
