/* setup-grader.css -- Setup Grader widget */

/* ── Widget handle / header ─────────────────────────────────────────────── */
.sg-handle { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.5rem 0.4rem 0.75rem; cursor: grab; flex-shrink: 0; user-select: none; border-bottom: 1px solid var(--border-sub); }
.sg-handle:active { cursor: grabbing; }
.sg-title { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-title-select { font-size: 0.875rem; font-weight: 600; color: var(--text-secondary); min-width: 0; width: auto; background: var(--bg-surface); border: 1px solid transparent; border-radius: var(--rm); outline: none; cursor: pointer; padding: 0 0.4rem; line-height: 1.2; transition: border-color 0.15s; display: flex; align-items: center; }
.sg-title-select:hover { border-color: var(--border); }

/* Custom dropdown for setup tag selection */
.sg-title-dropdown { position: fixed; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r); z-index: 40; box-shadow: var(--shadow-md); padding: 0.25rem 0; min-width: 10rem; max-height: 16rem; overflow-y: auto; }
.sg-title-dropdown-item { padding: 0.4rem 0.75rem; font-size: 0.8125rem; color: var(--text-secondary); cursor: pointer; transition: background 0.1s; }
.sg-title-dropdown-item:hover { background: var(--bg-surface); }
.sg-title-dropdown-item--active { color: var(--green); }
.sg-title-dropdown-item--add { border-top: 1px dashed var(--border-sub); color: var(--text-muted); font-style: italic; }
.sg-title-dropdown-item--add:hover { color: var(--text-primary); background: var(--bg-surface); }
.sg-title-dropdown .sg-title-add-input {
  display: block;
  width: 100%;
  background: var(--input-bg);
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  padding: 0.3rem 0.5rem;
  border-radius: var(--rm);
  outline: none;
  font-style: normal;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  caret-color: var(--text-primary);
}
.sg-title-dropdown .sg-title-add-input::placeholder { color: var(--text-ph); }
.sg-title-dropdown .sg-title-add-input:focus {
  border-color: var(--input-border);
  background-color: var(--input-bg);
}
.sg-title-dropdown .sg-title-add-input:-webkit-autofill,
.sg-title-dropdown .sg-title-add-input:-webkit-autofill:hover,
.sg-title-dropdown .sg-title-add-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  caret-color: var(--text-primary);
}
.sg-header-left { display: flex; align-items: center; gap: 0.4rem; min-width: 0; flex: 1; }
.sg-header-right { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.sg-grade { font-size: 0.9375rem; font-weight: 700; min-width: 1.75rem; text-align: center; line-height: 1; flex-shrink: 0; }
.sg-reset-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 0.15rem 0.35rem; border-radius: var(--rm); line-height: 1; transition: color 0.15s, background 0.15s; }
.sg-reset-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }

/* ── Widget body ─────────────────────────────────────────────────────────── */
.sg-body { flex: 1; min-height: 0; padding: 0.5rem 0.75rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }

/* ── Tag dropdown ────────────────────────────────────────────────────────── */
.sg-dropdown-wrap { flex-shrink: 0; margin-bottom: 0.35rem; }
.sg-tag-select { width: 100%; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.875rem; padding: 0.35rem 0.5rem; border-radius: var(--rm); outline: none; cursor: pointer; }
.sg-tag-select:focus { border-color: var(--green); }
body.light .sg-tag-select { background: var(--bg-surface); }

/* ── Placeholder text ────────────────────────────────────────────────────── */
.sg-placeholder { font-size: 0.875rem; color: var(--text-faint); text-align: center; padding: 0.75rem 0.25rem; line-height: 1.5; }

/* ── Param list ──────────────────────────────────────────────────────────── */
.sg-param-list { display: flex; flex-direction: column; gap: 0.125rem; }
.sg-param-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.25rem; border-radius: var(--rm); transition: background 0.1s; cursor: grab; }
.sg-param-row:hover { background: rgba(255,255,255,0.03); }
body.light .sg-param-row:hover { background: rgba(0,0,0,0.03); }
.sg-param-checkbox { -webkit-appearance: none; appearance: none; width: 1rem; height: 1rem; flex-shrink: 0; cursor: pointer; margin: 0; border: 1.5px solid var(--text-faint); border-radius: 0.2rem; background: transparent; position: relative; transition: border-color 0.15s, background 0.15s; }
.sg-param-checkbox:checked { background: var(--green); border-color: var(--green); }
.sg-param-checkbox:checked::after { content: ''; position: absolute; top: 50%; left: 50%; width: 5px; height: 9px; border: solid var(--bg-surface); border-width: 0 2.5px 2.5px 0; transform: translate(-50%, -60%) rotate(45deg); }
.sg-param-label { font-size: 0.9375rem; color: var(--text-secondary); cursor: pointer; flex: 1; line-height: 1.35; }

/* ── Inline add param input ──────────────────────────────────────────────── */
.sg-param-add-row { padding: 0.25rem 0.25rem; }
.sg-param-input { background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 0.9375rem; padding: 0.2rem 0; outline: none; flex: 1; width: 100%; }
/* :focus rule omitted -- caret signals focus per STYLE-GUIDE §7. */

/* ── Param context menu ──────────────────────────────────────────────────── */
.sg-ctx-menu { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r); padding: 0.35rem 0; min-width: 9rem; box-shadow: var(--shadow-md); }
.sg-ctx-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--text-secondary); cursor: pointer; transition: background 0.1s; white-space: nowrap; border: none; background: none; width: 100%; text-align: left; }
.sg-ctx-item:hover { background: var(--bg-surface); }
.sg-ctx-danger { color: var(--red); }
.sg-ctx-danger:hover { background: var(--red-bg); }
.sg-ctx-separator { height: 1px; background: var(--border); margin: 0.25rem 0; }

/* ── Settings button ────────────────────────────────────────────────────── */
.sg-settings-btn { background: none; border: none; padding: 2px; cursor: pointer; color: var(--text-faint); display: flex; align-items: center; border-radius: 3px; line-height: 1; transition: color 0.15s, background 0.15s; }
.sg-settings-btn:hover { color: var(--text-secondary); background: var(--bg-elevated); }

/* ── Settings dropdown ──────────────────────────────────────────────────── */
.sg-settings-dropdown { position: fixed; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 6px; min-width: 180px; z-index: 40; box-shadow: var(--shadow-sm); padding: 4px 0; }
.sg-settings-title { font-size: 0.75rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px 4px; }
.sg-settings-option { display: block; width: 100%; text-align: left; background: none; border: none; padding: 6px 10px; font-size: 0.8125rem; color: var(--text-secondary); cursor: pointer; transition: background 0.1s; }
.sg-settings-option:hover { background: var(--bg-surface); }
.sg-settings-option.active { color: var(--green); }

/* ── Body grade (large, above params) ───────────────────────────────────── */
.sg-grade-body { font-size: 1.75rem; font-weight: 700; line-height: 1; padding: 0.25rem 0 0.5rem; flex-shrink: 0; }

/* ── Settings separator + label inputs ──────────────────────────────────── */
.sg-settings-sep { height: 1px; background: var(--border); margin: 4px 0; }
.sg-settings-label-row { padding: 3px 10px; display: flex; align-items: center; gap: 6px; }
.sg-settings-label-prefix { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); min-width: 1.5rem; flex-shrink: 0; }
.sg-settings-label-input { width: 100%; background: var(--input-bg); border: 1px solid var(--input-border); color: var(--input-text); font-size: 0.8125rem; padding: 4px 6px; border-radius: var(--rm); outline: none; }
/* :focus rule omitted -- caret signals focus per STYLE-GUIDE §7. */
.sg-settings-reset { color: var(--text-secondary); font-size: 0.8125rem; }

/* Instances button */
.sg-instances-btn { background: none; border: none; padding: 2px; cursor: pointer; color: var(--text-faint); display: flex; align-items: center; border-radius: 3px; line-height: 1; transition: color 0.15s, background 0.15s; position: relative; }
.sg-instances-btn:hover { color: var(--text-secondary); background: var(--bg-elevated); }

/* Badge */
.sg-badge { position: absolute; top: -4px; right: -4px; min-width: 0.875rem; height: 0.875rem; background: var(--green); color: var(--bg-surface); font-size: 0.5625rem; font-weight: 700; border-radius: 999px; display: none; align-items: center; justify-content: center; padding: 0 0.15rem; line-height: 1; }

/* Log popover */
.sg-log-popover { position: fixed; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 6px; min-width: 260px; max-width: 320px; z-index: 40; box-shadow: var(--shadow-md); display: flex; flex-direction: column; max-height: 400px; }
.sg-log-popover-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 6px; border-bottom: 1px solid var(--border-sub); flex-shrink: 0; }
.sg-log-popover-title { font-size: 0.75rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.sg-log-clear-linked { font-size: 0.75rem; color: var(--text-faint); background: none; border: none; cursor: pointer; padding: 2px 6px; border-radius: 3px; }
.sg-log-clear-linked:hover { color: var(--text-secondary); background: var(--bg-surface); }
.sg-log-popover-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.sg-log-empty { font-size: 0.8125rem; color: var(--text-faint); padding: 12px 10px; text-align: center; }

/* Instance rows */
.sg-log-instance-row { display: flex; align-items: center; gap: 6px; padding: 5px 10px; cursor: default; }
.sg-log-instance-row:hover { background: var(--bg-surface); }
.sg-log-instance-expand { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 0; display: flex; align-items: center; flex-shrink: 0; }
.sg-log-instance-expand:hover { color: var(--text-secondary); }
.sg-log-ts { font-size: 0.75rem; color: var(--text-faint); flex-shrink: 0; min-width: 4.5rem; }
.sg-log-grade { font-size: 0.8125rem; font-weight: 700; flex-shrink: 0; min-width: 1.5rem; }
.sg-log-tag { font-size: 0.8125rem; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-log-linked-indicator { font-size: 0.625rem; color: var(--text-faint); background: var(--bg-surface); padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
.sg-log-delete { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 1px 3px; border-radius: 3px; display: flex; align-items: center; flex-shrink: 0; }
.sg-log-delete:hover { color: var(--red); }

/* Instance detail (expanded params) */
.sg-log-instance-detail { padding: 4px 10px 6px 32px; display: flex; flex-direction: column; gap: 2px; }
.sg-log-param-item { font-size: 0.8125rem; }
.sg-log-param-item--checked { color: var(--text-secondary); }
.sg-log-param-item--unchecked { color: var(--text-faint); }

/* ── Labeled switch for "Grade this setup" ───────────────────────────────── */
.sg-switch-group { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.sg-switch-label { font-size: 0.75rem; color: var(--text-muted); user-select: none; }
.sg-switch { width: 2rem; height: 1.125rem; border-radius: 999px; background: var(--bg-base); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background 0.15s, border-color 0.15s; flex-shrink: 0; padding: 0; }
.sg-switch::after { content: ''; position: absolute; top: 1px; left: 1px; width: 0.875rem; height: 0.875rem; border-radius: 50%; background: var(--text-faint); transition: transform 0.15s, background 0.15s; }
.sg-switch.on { background: var(--green-tint); border-color: var(--green); }
.sg-switch.on::after { transform: translateX(0.875rem); background: var(--green); }

/* ── Bigger grade letter + X/Y meta in card head ────────────────────────── */
.sg-add-card-grade { font-size: 1.25rem; font-weight: 700; min-width: 1.75rem; text-align: center; line-height: 1; }
.sg-add-card-grade.muted { color: var(--text-faint); }

/* ── Criterion row hover reveals edit/delete ─────────────────────────────── */
.sg-crit-actions { display: flex; gap: 0.15rem; margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.sg-trade-inline-param-row:hover .sg-crit-actions { opacity: 1; }
.sg-crit-edit-btn, .sg-crit-del-btn { width: 1.35rem; height: 1.35rem; border: none; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: var(--rm); display: inline-flex; align-items: center; justify-content: center; }
.sg-crit-edit-btn:hover { color: var(--text-primary); background: var(--bg-surface); }
.sg-crit-del-btn:hover { color: var(--red); background: var(--red-bg); }

/* ── Inline rename input inside a criterion row ──────────────────────────── */
.sg-crit-input { flex: 1; background: var(--bg-base); border: 1px solid var(--green); color: var(--text-primary); font-size: 0.875rem; padding: 0.25rem 0.5rem; border-radius: var(--rm); outline: none; font-family: inherit; }

/* ── Trade review panel Setup Grade section ─────────────────────────────── */
.sg-trade-grade-empty { font-size: 0.8125rem; color: var(--text-faint); }
.sg-trade-linked-grade { display: flex; align-items: center; gap: 0.625rem; padding: 0.35rem 0; }
.sg-trade-grade-letter { font-size: 1.125rem; font-weight: 700; flex-shrink: 0; }
.sg-trade-grade-ts { font-size: 0.8125rem; color: var(--text-faint); flex-shrink: 0; }
.sg-trade-grade-params { font-size: 0.8125rem; color: var(--text-secondary); flex: 1; }
.sg-trade-unlink-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 2px 6px; border-radius: 3px; font-size: 0.75rem; }
.sg-trade-unlink-btn:hover { color: var(--red); background: rgba(239,68,68,0.08); }
.sg-trade-instance-list { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.sg-trade-instance-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border-sub); }
.sg-trade-instance-row:last-child { border-bottom: none; }
.sg-trade-instance-ts { font-size: 0.8125rem; color: var(--text-faint); flex-shrink: 0; min-width: 4.5rem; }
.sg-trade-instance-params-summary { font-size: 0.8125rem; color: var(--text-faint); flex: 1; }
.sg-trade-assign-btn { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.8125rem; padding: 3px 10px; border-radius: var(--rm); cursor: pointer; flex-shrink: 0; }
.sg-trade-assign-btn:hover { background: var(--bg-surface); border-color: var(--green); color: var(--green); }
.sg-trade-inline-grade { display: flex; flex-direction: column; gap: 6px; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border-sub); }
.sg-trade-inline-hint { font-size: 0.8125rem; color: var(--text-faint); margin: 0; }
.sg-trade-inline-grade-header { display: flex; align-items: center; gap: 8px; }
.sg-trade-inline-params { display: flex; flex-direction: column; gap: 2px; }
.sg-trade-inline-param-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.sg-trade-log-and-assign-btn { align-self: flex-start; margin-top: 4px; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.8125rem; padding: 5px 12px; border-radius: var(--rm); cursor: pointer; }
.sg-trade-log-and-assign-btn:hover { border-color: var(--green); color: var(--green); }
