/* ============================================================
   SWAP — COMPONENTS
   LAYER: View
   Button, card, form, modal, alert, badge, table, meter.
   Every value comes from tokens.css. No raw colours below this line.
   ============================================================ */

/* ------------------------------------------------------------
   BUTTON
   ------------------------------------------------------------ */
.SWAPstyles.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--field-height);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #FFFFFF;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.SWAPstyles.btn:hover  { background: var(--color-primary-dark); }
.SWAPstyles.btn:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 2px;
}
.SWAPstyles.btn[disabled],
.SWAPstyles.btn--disabled { opacity: 0.5; cursor: not-allowed; }

.SWAPstyles.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.SWAPstyles.btn--secondary:hover { background: var(--color-bg); }

.SWAPstyles.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.SWAPstyles.btn--ghost:hover { color: var(--color-text); background: var(--color-bg); }

.SWAPstyles.btn--danger  { background: var(--color-danger); }
.SWAPstyles.btn--success { background: var(--color-success); }

.SWAPstyles.btn--sm { min-height: 34px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.SWAPstyles.btn--lg { min-height: 56px; padding: 0 var(--space-6); font-size: var(--text-lg); }
.SWAPstyles.btn--block { width: 100%; }

/* ------------------------------------------------------------
   CARD
   ------------------------------------------------------------ */
.SWAPstyles.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.SWAPstyles.card--highlighted { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.SWAPstyles.card--flat { box-shadow: none; }

.SWAPstyles.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.SWAPstyles.card__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  word-break: break-word;
}

.SWAPstyles.card__meta {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.SWAPstyles.card__body { margin: 0; font-size: var(--text-sm); color: var(--color-text); }

.SWAPstyles.card__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: var(--space-2);
}

/* ------------------------------------------------------------
   FORM
   ------------------------------------------------------------ */
.SWAPstyles.form { display: flex; flex-direction: column; gap: var(--space-4); }

.SWAPstyles.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }

.SWAPstyles.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.SWAPstyles.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }

.SWAPstyles.field__input,
.SWAPstyles.field__select,
.SWAPstyles.field__textarea {
  min-height: var(--field-height);
  padding: var(--field-padding);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-md);
  width: 100%;
}

.SWAPstyles.field__textarea { min-height: 96px; resize: vertical; line-height: var(--leading-normal); }

.SWAPstyles.field__input:focus,
.SWAPstyles.field__select:focus,
.SWAPstyles.field__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.SWAPstyles.field--inline { flex-direction: row; align-items: center; gap: var(--space-2); }

.SWAPstyles.field__row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.SWAPstyles.field__row > .SWAPstyles.field { flex: 1 1 180px; }

/* ------------------------------------------------------------
   ALERT / FLASH
   ------------------------------------------------------------ */
.SWAPstyles.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-info);
  background: var(--color-primary-light);
  color: var(--color-text);
  font-size: var(--text-sm);
  margin: 0;
}

.SWAPstyles.alert--ok      { border-left-color: var(--color-success); background: #ECFDF3; }
.SWAPstyles.alert--warn    { border-left-color: var(--color-warning); background: #FEF6E7; }
.SWAPstyles.alert--danger  { border-left-color: var(--color-danger);  background: #FEF0EE; }

.SWAPstyles.alert__list { margin: var(--space-2) 0 0; padding-left: var(--space-5); }
.SWAPstyles.alert__list li { margin-bottom: var(--space-1); }

/* ------------------------------------------------------------
   BADGE
   ------------------------------------------------------------ */
.SWAPstyles.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.SWAPstyles.badge--tier    { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: transparent; }
.SWAPstyles.badge--live    { background: var(--color-success); color: #FFFFFF; border-color: transparent; }
.SWAPstyles.badge--paused  { background: var(--color-warning); color: #FFFFFF; border-color: transparent; }
.SWAPstyles.badge--closed  { background: var(--color-text-muted); color: #FFFFFF; border-color: transparent; }
.SWAPstyles.badge--pending { background: var(--color-warning); color: #FFFFFF; border-color: transparent; }

/* ------------------------------------------------------------
   TABLE
   ------------------------------------------------------------ */
.SWAPstyles.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.SWAPstyles.table th,
.SWAPstyles.table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.SWAPstyles.table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.SWAPstyles.table tbody tr:hover { background: var(--color-bg); }

.SWAPstyles.mark--correct { color: var(--color-success); font-weight: var(--weight-semibold); }
.SWAPstyles.mark--wrong   { color: var(--color-danger);  font-weight: var(--weight-semibold); }

/* ------------------------------------------------------------
   METER — seats used against the plan allowance
   ------------------------------------------------------------ */
.SWAPstyles.meter { display: flex; flex-direction: column; gap: var(--space-2); }

.SWAPstyles.meter__track {
  height: 10px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.SWAPstyles.meter__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.SWAPstyles.meter__fill--full { background: var(--color-warning); }

.SWAPstyles.meter__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------
   MODAL
   ------------------------------------------------------------ */
.SWAPstyles.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(17, 24, 39, 0.55);
  z-index: 100;
}

.SWAPstyles.modal[open],
.SWAPstyles.modal--open { display: flex; }

.SWAPstyles.modal__panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.SWAPstyles.modal__title { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); }

/* ------------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------------ */
.SWAPstyles.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.SWAPstyles.empty__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

/* ------------------------------------------------------------
   BLOCK CARD — the lesson builder's editable row
   ------------------------------------------------------------ */
.SWAPstyles.blockCard {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
}

.SWAPstyles.blockCard--statement { border-left-color: var(--color-info); }
.SWAPstyles.blockCard--question  { border-left-color: var(--color-primary); }
.SWAPstyles.blockCard--thought   { border-left-color: var(--color-warning); }

.SWAPstyles.blockCard--dragging { opacity: 0.45; }
.SWAPstyles.blockCard--dropTarget { border-top: 3px solid var(--color-primary); }

.SWAPstyles.blockCard__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.SWAPstyles.blockCard__handle {
  cursor: grab;
  padding: var(--space-1) var(--space-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: var(--text-sm);
  user-select: none;
}

.SWAPstyles.blockCard__index {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
}

.SWAPstyles.optionRow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.SWAPstyles.optionRow__value { flex: 1 1 160px; }

/* ------------------------------------------------------------
   DEV BADGE — visible only when DEV_MODE is on
   ------------------------------------------------------------ */
.SWAPstyles.devBadge {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 200;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--color-warning);
  color: #FFFFFF;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
