/* ============================================================
   Stocky — Alert-configuration modal (spec 05)
   Shared overlay, injected by alert-modal.js and used from BOTH
   the dashboard and the stock-detail page. Layers on the DS
   .modal / .field / .input / .switch / .segmented / .callout atoms;
   adds only the type-picker cards + the type-aware field rows.
   ============================================================ */

.am-overlay {
  position: absolute; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in oklab, var(--text-primary) 30%, transparent);
  -webkit-backdrop-filter: blur(7px) saturate(1.05); backdrop-filter: blur(7px) saturate(1.05);
}
.am-overlay.open { display: flex; }
.am-modal { max-width: 460px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.am-modal .modal__body { overflow-y: auto; flex: 1; min-height: 0; }

/* ticker chip in the title */
.am-tkr { font-family: var(--font-display); font-weight: 700; color: var(--color-signal); }

/* ----- Type picker: three selectable cards (radio semantics) ----- */
.am-section-k { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
  margin: 0 0 9px; font-family: var(--font-ui); }
.am-types { display: flex; flex-direction: column; gap: 8px; }
.am-type {
  display: grid; grid-template-columns: 30px 1fr 18px; align-items: center; gap: 11px;
  width: 100%; text-align: left; padding: 11px 13px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-primary); font-family: var(--font-ui);
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.am-type:hover { border-color: var(--text-muted); }
.am-type.is-active { border-color: var(--color-signal); background: var(--signal-bg); }
.am-type__ic { width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-muted);
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out); }
.am-type.is-active .am-type__ic { background: color-mix(in srgb, var(--color-signal) 18%, transparent); color: var(--color-signal); }
.am-type__t { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.am-type__d { font-size: 11px; line-height: 1.4; color: var(--text-muted); margin-top: 2px; }
.am-type__radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong);
  justify-self: end; position: relative; transition: border-color var(--dur-base) var(--ease-out); }
.am-type.is-active .am-type__radio { border-color: var(--color-signal); }
.am-type.is-active .am-type__radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--color-signal); }

/* edit mode: type is immutable — show only the chosen card, locked */
.am-types.is-locked .am-type:not(.is-active) { display: none; }
.am-types.is-locked .am-type { cursor: default; opacity: 1; }
.am-type.is-active.is-locked { border-color: var(--border-strong); background: var(--bg-surface); }
.am-lockhint { display: none; font-family: var(--font-ui); font-size: 11px; line-height: 1.45;
  color: var(--text-muted); margin: 8px 0 0; }
.am-lockhint svg { vertical-align: -2px; margin-right: 4px; }
.am-types.is-locked + .am-lockhint { display: block; }

/* ----- Field rows (type-specific) ----- */
.am-fields { display: flex; flex-direction: column; gap: 14px; }
.am-fieldgroup { display: none; flex-direction: column; gap: 14px; }
.am-fieldgroup.is-shown { display: flex; }
.am-row { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-ui); }
.am-label { font-size: 11px; font-weight: 500; letter-spacing: 0.5px; color: var(--text-secondary);
  display: inline-flex; gap: 5px; align-items: center; }
.am-help { font-size: 11px; line-height: 1.45; color: var(--text-muted); }

/* numeric input with a leading/trailing affix ($ / % / ×) */
.am-num { position: relative; display: flex; align-items: stretch; max-width: 220px; }
.am-num .input { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.am-num--prefix .input { padding-left: 26px; }
.am-num--suffix .input { padding-right: 34px; }
.am-affix { position: absolute; top: 0; bottom: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 13px; color: var(--text-muted); pointer-events: none; }
.am-num--prefix .am-affix { left: 11px; }
.am-num--suffix .am-affix { right: 12px; }
.am-err { font-size: 11px; line-height: 1.4; color: var(--data-down); display: none; gap: 5px; align-items: center; }
.am-err.is-shown { display: inline-flex; }
.am-err svg { flex: none; }

/* direction segmented (above / below) */
.am-dir { max-width: 220px; }

/* enabled toggle row */
.am-enable { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0 2px; border-top: 0.5px solid var(--border-default); margin-top: 2px; }
.am-enable__txt { font-family: var(--font-ui); }
.am-enable__t { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.am-enable__d { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* save-error frame (transient) */
.am-saveerr { margin: 2px 0 0; }
.am-saveerr:empty { display: none; }

/* footer: Delete sits left on edit; Cancel + Save right */
.am-foot { display: flex; align-items: center; gap: 8px; }
.am-foot .am-delete { margin-right: auto; display: none; }
.am-modal.is-edit .am-foot .am-delete { display: inline-flex; }

/* nested confirm-delete dialog (DS confirm pattern) */
.am-confirm { position: absolute; inset: 0; z-index: 95; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in oklab, var(--text-primary) 24%, transparent);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.am-confirm.open { display: flex; }
.am-confirm .modal { max-width: 360px; }
.am-confirm .modal__body { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.am-confirm .modal__body b { font-family: var(--font-display); color: var(--text-primary); }

@media (max-width: 600px) {
  .am-overlay { padding: 10px; align-items: flex-end; }
  .am-modal { max-width: none; max-height: 92vh; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .am-num, .am-dir { max-width: none; }
  .am-type { padding: 13px; }
  .am-foot .btn { padding: 11px 16px; }
}
