/* ===== edit_tab_html (HTML form, scoped) =====
   Loaded eagerly from anvil.yaml native_deps.head_html. Anvil's server strips a
   <style> block out of an HTML template, so the form's rules live here.

   ROOT RULE. `.et-shell` stays a bare class so it outranks the scoped reset. It
   takes `position: relative` and nothing else: this form is a section inside a
   classic panel, not a screen root in the layout's scroller, and it declares no
   `min-height`, `height` or `overflow`.

   SCOPING. Every other rule is `:where(.et-shell)`-prefixed, which adds zero
   specificity, so no rule can change which declaration wins on that account.
   Three rules stay BARE because the root itself is their ancestor with a second
   class - `.et-shell.archived .et-required-row` and the two
   `.et-shell.archived .et-actions ...` rules. Wrapped as
   `:where(.et-shell) .et-shell.archived ...` they would never match, since the
   root cannot be a descendant of itself.

   THE SELECT TIE, and it is why `.et-field` is TRIPLED below.
   `training_authoring`'s `.ta-root select`
   is the one selector in this section whose subject carries no form prefix, so
   it reaches this form's cooldown unit (`<select id="et-f-cooldown-unit">`).
   `.ta-root select` and `.et-field select` are both (0,1,1) and collide on
   padding, border-radius, background, color and font-size. `.et-field select`
   must win - the field renders with no chevron, `padding: 8px 12px` and
   `color: #0f172a`. As a head link this sheet is EARLIER than
   `training_authoring.css` (alphabetical order), which also writes
   `.ta-root.ta-root select` at (0,2,1). A doubled class here would tie that
   and lose on order, so the three colliding rules are written with a TRIPLED
   class at (0,3,1) and win on weight in either order.

   The triple carries to this sheet's own `:focus` and `[disabled]` rules, or
   the bump would silently reorder ties INSIDE this file:
     - `.et-field input:focus` (0,2,1) would lose to a tripled base (0,3,1) and
       the focus border/outline would stop applying;
     - `.et-field input[disabled]` (0,2,1) likewise, and the disabled fill would
       revert to white.
   Each is lifted to the same weight and sits after its base rule, so both
   pairs resolve as intended. `.et-cooldown-row select` is
   tripled for the same reason as the base rule.
   The `.et-invalid` type selectors are NOT tripled - they carry no `.et-field`
   ancestor and would reach `question_editor_html`'s fields. They keep their own
   weight and a separate `.et-field`-anchored rule restores the tie; see the
   comment on that rule below.
   `.et-field textarea { resize; min-height }`, `.et-cooldown-row input` and
   `[data-violation-field].et-invalid` declare nothing the tripled rules
   declare, so they are left alone.

   THE BANNER HOST. There is no `.et-banner-host:empty` rule: `__init__` puts
   `banner_panel` into the `et-banner` slot and `_dismiss_banner` clears the
   PANEL, not the host, so the host always holds an element child and never
   matches `:empty`. It is a zero-height flex item of `.et-shell { gap: 20px }`
   that consumes one gap whether a banner is showing or not. It keeps
   `display: block` and its box, so that gap survives; `display: contents`
   here would delete it.

   THE ARCHIVED BANNER. Inline attribute styles are banned in an HTML template,
   so the base rule hides it and `.is-archived` reveals it; the module toggles
   the class. No designer gate is needed: the canvas shows it hidden, which is
   its initial state.

   OTHER TIES AUDITED, none live. This form applies no `.px-*` class, so the
   dependency's runtime theme injection reaches nothing here. Anvil's own
   `theme.css` styles form controls only through `.anvil-component` /
   `.anvil-role-*` selectors, and every control in this template is raw markup
   inside an HtmlComponent, so it carries neither. `et-` appears in no other
   template or asset. No @keyframes in this form. */

.et-shell {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0f172a;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 14px;
  position: relative;
}

/* Banner slot — race-rejection / freshness conflict / dirty-state-restore */
:where(.et-shell) .et-banner-host { display: block; }

/* Archived read-only banner */
:where(.et-shell) .et-archived-banner {
  padding: 12px 16px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
:where(.et-shell) .et-archived-banner.is-archived { display: flex; }
:where(.et-shell) .et-archived-banner-msg { flex: 1; font-size: 14px; }
:where(.et-shell) .et-archived-banner-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  background: #b45309;
  color: #ffffff;
  border: 1px solid #92400e;
  cursor: pointer;
  min-height: 32px;
}
:where(.et-shell) .et-archived-banner-btn:hover { background: #92400e; }

/* Top-line grid */
:where(.et-shell) .et-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
:where(.et-shell) .et-field { display: flex; flex-direction: column; gap: 4px; }
:where(.et-shell) .et-field label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
:where(.et-shell) .et-field.et-field.et-field input,
:where(.et-shell) .et-field.et-field.et-field textarea,
:where(.et-shell) .et-field.et-field.et-field select {
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-sizing: border-box;
  color: #0f172a;
}
:where(.et-shell) .et-field.et-field.et-field input:focus,
:where(.et-shell) .et-field.et-field.et-field textarea:focus,
:where(.et-shell) .et-field.et-field.et-field select:focus {
  outline: none;
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225,29,72,0.1);
}
:where(.et-shell) .et-field textarea { resize: vertical; min-height: 60px; }
:where(.et-shell) .et-field.et-field.et-field input[disabled],
:where(.et-shell) .et-field.et-field.et-field textarea[disabled],
:where(.et-shell) .et-field.et-field.et-field select[disabled] {
  background: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}
:where(.et-shell) .et-field-full { grid-column: 1 / -1; }
:where(.et-shell) .et-cooldown-row { display: flex; gap: 8px; align-items: center; }
:where(.et-shell) .et-cooldown-row input { flex: 0 0 96px; max-width: 96px; min-width: 0; }
:where(.et-shell) .et-cooldown-row.et-cooldown-row.et-cooldown-row select { flex: 0 0 auto; }
:where(.et-shell) .et-invalid,
:where(.et-shell) input.et-invalid,
:where(.et-shell) textarea.et-invalid,
:where(.et-shell) select.et-invalid {
  border-color: #dc2626 !important;
  background: #fef2f2;
}
/* `.et-field`'s base rule is tripled, so the (0,1,1) type selectors
   above do not tie it. The tie is restored HERE rather than by tripling
   them, because a tripled type selector carries no `.et-field` ancestor and so
   reaches `question_editor_html`'s own fields, which sit inside `.et-shell` and
   are the main consumers of `.et-invalid`: at (0,3,1) it would beat
   `:where(.qe-root) .qe-ans-text:focus` (0,2,0) and leave a flagged answer box
   pink while focused instead of white. Doubled - not tripled - so this rule
   sits exactly two classes above the (0,1,1) type selectors, mirroring the
   base rule's own +2, so the cascade inside `.et-field` holds in full: it
   ties the tripled base (0,3,1) and wins on order, and it still LOSES to
   `:focus` and `[disabled]` at (0,4,1). */
:where(.et-shell) .et-field.et-field input.et-invalid,
:where(.et-shell) .et-field.et-field textarea.et-invalid,
:where(.et-shell) .et-field.et-field select.et-invalid {
  border-color: #dc2626 !important;
  background: #fef2f2;
}
:where(.et-shell) [data-violation-field].et-invalid { outline: 2px solid #dc2626; }

/* Required toggle (rendered as a pill switch — Optional ↔ Required) */
:where(.et-shell) .et-required-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  min-height: 38px;
}
.et-shell.archived .et-required-row { opacity: 0.5; cursor: not-allowed; }
:where(.et-shell) .et-req-toggle-label {
  font-weight: 600;
  font-size: 14px;
  color: #64748b;
  user-select: none;
  transition: color 160ms ease;
}
:where(.et-shell) .et-req-toggle-label.active { color: #1e293b; }
:where(.et-shell) .et-req-toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #cbd5e1;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 160ms ease, border-color 160ms ease;
}
:where(.et-shell) .et-req-toggle-switch[aria-checked="true"] {
  background: #e11d48;
  border-color: #be123c;
}
:where(.et-shell) .et-req-toggle-switch:focus-visible {
  outline: 2px solid #e11d48;
  outline-offset: 2px;
}
:where(.et-shell) .et-req-toggle-switch:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
:where(.et-shell) .et-req-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15,23,42,0.25);
  transition: transform 160ms ease;
}
:where(.et-shell) .et-req-toggle-switch[aria-checked="true"] .et-req-toggle-knob {
  transform: translateX(18px);
}
:where(.et-shell) .et-required-hint {
  flex: 1 1 auto;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

/* Question editor mount */
:where(.et-shell) .et-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}

/* Action footer */
:where(.et-shell) .et-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
:where(.et-shell) .et-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
}
:where(.et-shell) .et-btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
:where(.et-shell) .et-btn-secondary:hover:not(:disabled) { background: #e2e8f0; }
:where(.et-shell) .et-btn-primary {
  background: #e11d48;
  color: #ffffff;
  border: 1px solid #be123c;
}
:where(.et-shell) .et-btn-primary:hover:not(:disabled) { background: #be123c; }
:where(.et-shell) .et-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.et-shell.archived .et-actions .et-btn-primary { display: none; }
:where(.et-shell) .et-btn-add-question { margin-right: auto; }
.et-shell.archived .et-actions .et-btn-add-question { display: none; }
:where(.et-shell) .et-actions-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-right: auto;
}

@media (max-width: 768px) {
  .et-shell {
    padding: 16px 12px;
    gap: 16px;
  }
  :where(.et-shell) .et-required-row {
    flex-wrap: wrap;
  }
  :where(.et-shell) .et-required-hint {
    flex: 1 1 100%;
    flex-basis: 100%;
    padding-top: 4px;
  }
  :where(.et-shell) .et-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }
  :where(.et-shell) .et-actions .et-btn {
    flex: 1 1 0;
  }
}
