/* Trader Premium Plus — Interaction & Feedback layer (Cycle 1/4) */

/* Keyboard focus must be obvious without changing the established mouse look. */
html body #MainCanvas .trader-action-control:focus,
html body #MainCanvas .trader-interactive-row:focus,
html body .trader-action-control:focus,
html body .trader-interactive-row:focus {
  outline: 2px solid var(--saas-module-accent, #2563eb) !important;
  outline-offset: 2px !important;
}

html body #MainCanvas .trader-interactive-row,
html body .trader-interactive-row {
  cursor: pointer;
}

html body #MainCanvas .trader-interactive-row:focus > td,
html body .trader-interactive-row:focus > td {
  background-color: color-mix(in srgb, var(--saas-module-accent, #2563eb) 7%, transparent) !important;
}

/* Submit feedback: preserve the button name/value while blocking accidental repeat submits. */
html body form.trader-is-submitting .trader-submit-pending {
  position: relative;
  pointer-events: none !important;
  opacity: .82 !important;
}

html body form.trader-is-submitting .trader-submit-pending::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: trader-premium-spin .72s linear infinite;
}

@keyframes trader-premium-spin {
  to { transform: rotate(360deg); }
}

/* Live-search status. Calm on success, visible on failure, never overlays results. */
html body .trader-live-search-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  margin-top: 8px;
  padding: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--saas-text-tertiary, #64748b);
}

html body .trader-live-search-feedback[hidden] {
  display: none !important;
}

html body .trader-live-search-feedback.is-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid var(--saas-keyline, #cbd5e1);
  border-top-color: var(--saas-module-accent, #2563eb);
  border-radius: 50%;
  animation: trader-premium-spin .72s linear infinite;
}

html body .trader-live-search-feedback.is-error {
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, #dc2626 30%, transparent);
  border-radius: var(--ui-radius-sm, 8px);
  background: color-mix(in srgb, #dc2626 6%, transparent);
  color: #b91c1c;
  font-weight: 700;
}

html[data-theme="dark"] body .trader-live-search-feedback.is-error {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, .32);
  background: rgba(127, 29, 29, .18);
}

html body .trader-live-search-retry {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin-left: 4px;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

/* Unified AJAX/legacy feedback surfaces. Replaces old yellow boxes. */
html body .trader-feedback {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 8px 0 14px;
  padding: 13px 14px;
  border: 1px solid var(--saas-keyline, #dbe3ee);
  border-left-width: 4px;
  border-radius: var(--ui-radius-sm, 10px);
  background: var(--saas-surface-raised, #fff);
  color: var(--saas-text-primary, #172033);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

html body .trader-feedback::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

html body .trader-feedback-error {
  border-left-color: #dc2626;
  background: color-mix(in srgb, #dc2626 4%, var(--saas-surface-raised, #fff));
}

html body .trader-feedback-error::before {
  background: #dc2626;
  color: #fff;
}

html body .trader-feedback-warning,
html body .trader-confirmation-danger {
  border-left-color: #d97706;
  background: color-mix(in srgb, #d97706 4%, var(--saas-surface-raised, #fff));
}

html body .trader-feedback-warning::before,
html body .trader-confirmation-danger::before {
  background: #d97706;
  color: #fff;
}

html body .trader-confirmation-danger {
  margin-bottom: 12px;
}

html body .trader-confirmation-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0 15px 15px;
}

html body .trader-confirmation-actions .btn {
  min-width: 150px;
}

@media (max-width: 640px) {
  html body .trader-confirmation-actions {
    flex-direction: column;
    align-items: stretch;
  }
  html body .trader-confirmation-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body form.trader-is-submitting .trader-submit-pending::after,
  html body .trader-live-search-feedback.is-loading::before {
    animation-duration: 1.6s;
  }
}

html body .trader-feedback-loading {
  border-left-color: var(--saas-module-accent, #2563eb);
  font-weight: 700;
}

html body .trader-feedback-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid var(--saas-keyline, #cbd5e1);
  border-top-color: var(--saas-module-accent, #2563eb);
  background: transparent;
  border-radius: 50%;
  animation: trader-premium-spin .72s linear infinite;
}

html body .trader-confirmation-actions > .col-md-4:empty {
  display: none !important;
}
