/*
 * er-lab.css — styles for the ER modelling lab (Chen notation).
 * Uses only the design tokens defined in theme.css. Every class is prefixed with `erl-`.
 */

.erl-root {
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-family: var(--font-sans);
  color: var(--text);
}

/* ---- Grundlagen (collapsible) --------------------------------------------------------- */

.erl-basics {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.erl-basics-toggle {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.erl-basics-toggle:hover {
  background: var(--surface-2);
}

.erl-basics-body {
  padding: 4px 18px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.erl-legend {
  overflow-x: auto;
}

.erl-legend-svg {
  width: 100%;
  max-width: 760px;
  height: auto;
}

.erl-method {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.5;
}

.erl-mini {
  border-top: 1px dashed var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.erl-mini-title {
  font-size: 0.9rem;
  color: var(--text-2);
}

.erl-mini-canvas {
  max-width: 540px;
}

.erl-mini-svg {
  width: 100%;
  height: auto;
  display: block;
}

.erl-mini-feedback {
  font-size: 0.88rem;
  color: var(--text-2);
  min-height: 1.4em;
}

.erl-mini-feedback.erl-mini-ok { color: var(--green-text); }
.erl-mini-feedback.erl-mini-warn { color: var(--amber-text); }

/* ---- layout ----------------------------------------------------------------------------- */

.erl-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.erl-task-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.erl-task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.erl-task-card:hover {
  border-color: var(--border-strong);
}

.erl-task-card-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.erl-task-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.erl-task-card-status {
  font-size: 0.76rem;
  color: var(--text-3);
}

.erl-task-card-solved .erl-task-card-status {
  color: var(--green-text);
}

.erl-workspace {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.erl-scenario {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
}

.erl-scenario h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.erl-scenario-text {
  margin: 0;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.6;
}

.erl-scenario-source-hl {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 3px;
}

/* ---- toolbar ---------------------------------------------------------------------------- */

.erl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.erl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.erl-btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.erl-btn-primary:hover {
  background: var(--accent-hover);
}

.erl-btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}

.erl-btn-secondary:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* Segmented control: the six tools rendered as one continuous strip, active tool highlighted */

.erl-tool-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.erl-tool-btn {
  background: var(--surface);
  color: var(--text-2);
  border: none;
  border-right: 1px solid var(--border);
  padding: 9px 13px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.erl-tool-btn:last-child {
  border-right: none;
}

.erl-tool-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.erl-tool-btn-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.erl-toolbar-secondary {
  display: inline-flex;
  gap: 8px;
}

.erl-shortcut-hint {
  margin: -6px 0 0;
  font-size: 0.78rem;
  color: var(--text-3);
}

.erl-btn:focus-visible,
.erl-tool-btn:focus-visible,
.erl-task-card:focus-visible {
  box-shadow: var(--focus-ring);
}

/* ---- canvas ----------------------------------------------------------------------------- */

.erl-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  min-height: 560px;
}

.erl-canvas {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
  touch-action: none;
}

.erl-canvas-readonly {
  min-width: 0;
}

.erl-canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 320px;
  text-align: center;
  color: var(--text-3);
  font-size: 0.88rem;
  pointer-events: none;
}

.erl-canvas-hint[hidden] {
  display: none;
}

.erl-shape {
  fill: var(--surface);
  stroke: var(--text-2);
  stroke-width: 1.4;
}

.erl-shape-entity { fill: var(--surface-2); }
.erl-shape-relationship { fill: var(--accent-soft); stroke: var(--accent-text); }
.erl-shape-attribute { fill: var(--surface); }

.erl-label {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  pointer-events: none;
  user-select: none;
}

.erl-label-sm {
  fill: var(--text-2);
  font-family: var(--font-sans);
  font-size: 11px;
  pointer-events: none;
}

.erl-el {
  cursor: pointer;
}

.erl-el-selected .erl-shape {
  stroke: var(--accent);
  stroke-width: 2.4;
}

.erl-el-highlight .erl-shape {
  stroke: var(--amber);
  stroke-width: 2.6;
}

.erl-link {
  stroke: var(--border-strong);
  stroke-width: 1.4;
}

.erl-link-selected {
  stroke: var(--accent);
  stroke-width: 2px;
}

/* Recursive relationships only: an invisible, wider line makes the thin visible line reliably
   clickable (for role editing) without changing how it actually looks. */
.erl-link-hit {
  stroke: transparent;
  stroke-width: 16px;
  cursor: pointer;
  pointer-events: stroke;
}

.erl-role-label {
  fill: var(--text-2);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-style: italic;
  pointer-events: none;
  user-select: none;
}

.erl-chip {
  cursor: pointer;
}

.erl-chip-bg {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.2;
}

.erl-chip:hover .erl-chip-bg {
  stroke: var(--accent);
}

.erl-chip-text {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}

.erl-rename-input {
  position: absolute;
  z-index: 5;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.erl-rename-input[hidden] {
  display: none;
}

.erl-transient {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red-text);
  font-size: 0.84rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.erl-transient-visible {
  opacity: 1;
}

.erl-selection-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.erl-selection-panel[hidden] {
  display: none;
}

.erl-selection-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}

.erl-role-input {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 140px;
}

.erl-role-input:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.erl-pk-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---- action buttons (Prüfen, Musterlösung, Zurücksetzen, Vorlesen) ------------------------ */

.erl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---- solution panel ----------------------------------------------------------------------- */

.erl-solution-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: auto;
}

.erl-solution-panel[hidden] {
  display: none;
}

/* ---- feedback ----------------------------------------------------------------------------- */

.erl-feedback-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
}

.erl-feedback-summary {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.erl-feedback-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.erl-feedback-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
  cursor: pointer;
}

.erl-feedback-item:focus-visible {
  box-shadow: var(--focus-ring);
}

.erl-feedback-ok {
  background: var(--green-soft);
  color: var(--green-text);
}

.erl-feedback-error {
  background: var(--red-soft);
  color: var(--red-text);
}

.erl-feedback-hint {
  background: var(--amber-soft);
  color: var(--amber-text);
}

/* ---- sentences ------------------------------------------------------------------------------ */

.erl-sentences {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.erl-sentence {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  color: var(--blue-text);
  font-size: 0.88rem;
}

.erl-empty {
  margin: 0;
  color: var(--text-3);
  font-size: 0.86rem;
}

/* ---- responsive --------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .erl-task-picker {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}
