/* ===== add_user_popup (HTML form, scoped) =====
   Loaded from anvil.yaml native_deps.head_html.

   The root is <div class="ch-add-user-container ch-add-user-popup-root">. Every rule scopes on
   the private class at zero specificity, so no rule changes weight; the root rule is bare on it.
   .ch-form-group ties with theme.css at the same value, so link order does not matter. */

.ch-add-user-popup-root {
  padding: var(--ch-space-md);
  font-family: var(--ch-font-primary);
  min-width: 320px;
}

:where(.ch-add-user-popup-root) .ch-form-group {
  margin-bottom: var(--ch-space-md);
}

:where(.ch-add-user-popup-root) .ch-form-group:last-of-type {
  margin-bottom: var(--ch-space-lg);
}

:where(.ch-add-user-popup-root) .ch-form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ch-text-primary);
  margin-bottom: 6px;
}

:where(.ch-add-user-popup-root) .ch-form-input,
:where(.ch-add-user-popup-root) .ch-form-select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: var(--ch-font-primary);
  color: var(--ch-text-primary);
  background: var(--ch-bg-input);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-md);
  outline: none;
  transition: border-color var(--ch-transition-fast), box-shadow var(--ch-transition-fast);
  box-sizing: border-box;
  min-height: 44px;
}

html[data-theme='light'] :where(.ch-add-user-popup-root) input.ch-form-input[type='email'] {
  color-scheme: light;
}

html[data-theme='dark'] :where(.ch-add-user-popup-root) input.ch-form-input[type='email'] {
  color-scheme: dark;
}

:where(.ch-add-user-popup-root) input.ch-form-input[type='email'] {
  -webkit-text-fill-color: var(--ch-text-primary);
  caret-color: var(--ch-text-primary);
}

:where(.ch-add-user-popup-root) .ch-form-input:focus,
:where(.ch-add-user-popup-root) .ch-form-select:focus {
  border-color: var(--ch-border-focus);
  box-shadow: 0 0 0 3px var(--ch-focus-shadow);
}

/* Shown ONLY when the admin has no live home to add somebody to. The
   text is the estate's deactivation sentence, handed in by Python; the
   element is empty (and display:none) at every other time. */
:where(.ch-add-user-popup-root) .ch-disabled-tooltip {
  display: none;
  font-size: 12px;
  color: var(--ch-text-muted);
  margin-top: 8px;
}

:where(.ch-add-user-popup-root) .ch-form-input::placeholder {
  color: var(--ch-text-muted);
}

:where(.ch-add-user-popup-root) input.ch-form-input[type='email']:-webkit-autofill,
:where(.ch-add-user-popup-root) input.ch-form-input[type='email']:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--ch-text-primary);
  caret-color: var(--ch-text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--ch-bg-input) inset;
  box-shadow: 0 0 0 1000px var(--ch-bg-input) inset;
  border: 1px solid var(--ch-border);
}

:where(.ch-add-user-popup-root) input.ch-form-input[type='email']:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ch-text-primary);
  caret-color: var(--ch-text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--ch-bg-input) inset, 0 0 0 3px var(--ch-focus-shadow);
  box-shadow: 0 0 0 1000px var(--ch-bg-input) inset, 0 0 0 3px var(--ch-focus-shadow);
  border: 1px solid var(--ch-border-focus);
}

:where(.ch-add-user-popup-root) input.ch-form-input[type='email']:-moz-autofill {
  box-shadow: 0 0 0 1000px var(--ch-bg-input) inset;
  -moz-text-fill-color: var(--ch-text-primary);
  caret-color: var(--ch-text-primary);
}

:where(.ch-add-user-popup-root) .ch-form-input.invalid {
  border-color: var(--ch-danger);
}

/* The homes to add the person to: one tick box per live admin home. */
:where(.ch-add-user-popup-root) .au-home-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

:where(.ch-add-user-popup-root) .au-home-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ch-text-primary);
  min-height: 32px;
  cursor: pointer;
}

:where([data-theme="dark"] .ch-add-user-popup-root) .au-home-option input[type="checkbox"] {
  accent-color: var(--ch-accent-primary);
}

/* One block per ticked home, the card's controls (plan d 2.2). */
:where(.ch-add-user-popup-root) .au-home-block {
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-md);
  padding: 12px;
  margin-bottom: var(--ch-space-md);
}

:where(.ch-add-user-popup-root) .au-home-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ch-text-primary);
  margin-bottom: 8px;
}

:where(.ch-add-user-popup-root) .au-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}

:where(.ch-add-user-popup-root) .au-field,
:where(.ch-add-user-popup-root) .au-line {
  display: block;
  min-width: 0;
}

:where(.ch-add-user-popup-root) .au-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ch-text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:where(.ch-add-user-popup-root) .au-admin {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  cursor: pointer;
}

:where(.ch-add-user-popup-root) .au-admin input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

:where(.ch-add-user-popup-root) .au-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--ch-border);
  box-shadow: inset 0 0 0 2px var(--ch-text-secondary);
  transition: background-color var(--ch-transition-fast);
}

:where(.ch-add-user-popup-root) .au-switch::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--ch-text-secondary);
  border-radius: 50%;
  transition: transform var(--ch-transition-fast);
}

:where(.ch-add-user-popup-root) .au-admin input:checked + .au-switch {
  background: var(--ch-accent-primary-text);
  box-shadow: none;
}

:where(.ch-add-user-popup-root) .au-admin input:checked + .au-switch::before {
  transform: translateX(16px);
  background: var(--ch-text-inverse);
}

:where(.ch-add-user-popup-root) .au-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

:where(.ch-add-user-popup-root) .au-sel,
:where(.ch-add-user-popup-root) .au-pick {
  padding: 6px 8px;
  min-height: 36px;
  font-size: 13px;
}

:where(.ch-add-user-popup-root) .au-pick[data-level="user"],
:where(.ch-add-user-popup-root) .au-sel[data-level="user"] {
  background: var(--ch-success-bg);
  border-color: var(--ch-success-border);
}

:where(.ch-add-user-popup-root) .au-pick[data-level="viewer"],
:where(.ch-add-user-popup-root) .au-sel[data-level="viewer"] {
  background: var(--ch-warning-bg);
  border-color: var(--ch-warning-border);
}

:where(.ch-add-user-popup-root) .au-pick[data-level="not_allowed"],
:where(.ch-add-user-popup-root) .au-sel[data-level="not_allowed"] {
  background: var(--ch-bg-secondary);
  color: var(--ch-text-muted);
}

:where(.ch-add-user-popup-root) .au-pick:disabled,
:where(.ch-add-user-popup-root) .au-sel:disabled {
  background: var(--px-bg-disabled);
  border-color: var(--px-border-disabled);
  color: var(--px-text-disabled);
}

:where(.ch-add-user-popup-root) .au-home-refusal {
  display: none;
  font-size: 13px;
  color: var(--ch-danger);
  margin-top: 8px;
}

/* Why the server refused the add or an email change. Empty and hidden otherwise. */
:where(.ch-add-user-popup-root) .ch-edit-refusal {
  display: none;
  font-size: 13px;
  color: var(--ch-danger);
  margin-bottom: var(--ch-space-md);
}

:where(.ch-add-user-popup-root) .ch-button-row {
  display: flex;
  gap: var(--ch-space-sm);
  justify-content: flex-end;
}

:where(.ch-add-user-popup-root) .ch-btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--ch-font-primary);
  border: none;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  transition: transform var(--ch-transition-fast), background-color var(--ch-transition-fast), color var(--ch-transition-fast), border-color var(--ch-transition-fast), box-shadow var(--ch-transition-fast);
  min-height: 44px;
}

:where(.ch-add-user-popup-root) .ch-btn:disabled {
  background: var(--px-bg-disabled);
  color: var(--px-text-disabled);
  border-color: var(--px-border-disabled);
  box-shadow: inset 0 0 0 1px var(--px-border-disabled);
  cursor: not-allowed;
}

:where(.ch-add-user-popup-root) .ch-btn-primary {
  background: var(--ch-accent-primary);
  color: var(--px-ink-on-bright);
}

:where(.ch-add-user-popup-root) .ch-btn-primary:hover:not(:disabled) {
  background: var(--ch-accent-primary-hover);
}

:where(.ch-add-user-popup-root) .ch-btn-secondary {
  background: var(--ch-bg-secondary);
  color: var(--ch-text-primary);
  border: 1px solid var(--ch-border);
}

:where(.ch-add-user-popup-root) .ch-btn-secondary:hover:not(:disabled) {
  background: var(--ch-border);
}

@media (max-width: 480px) {
  .ch-add-user-popup-root {
    min-width: auto;
  }

  :where(.ch-add-user-popup-root) .au-lines {
    grid-template-columns: minmax(0, 1fr);
  }

  :where(.ch-add-user-popup-root) .ch-button-row {
    flex-direction: column;
  }

  :where(.ch-add-user-popup-root) .ch-btn {
    width: 100%;
  }
}
