/* components.css — cards, buttons, forms, alerts. */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  padding: .6rem 1.1rem;
  font: inherit; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity .12s ease, background .12s ease;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-link {
  background: transparent; border: none;
  color: var(--primary); padding: .4rem .6rem;
}
.btn-block { display: flex; width: 100%; }

/* Forms */
label { display: block; margin: .4rem 0 .25rem; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], textarea, select {
  width: 100%;
  padding: .55rem .7rem;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
input[inputmode="numeric"] { letter-spacing: .25em; text-align: center; font-size: 1.4rem; }
.field { margin-bottom: .9rem; }
.field-row { display: flex; gap: .5rem; }
.field-row > * { flex: 1; }

/* Alerts */
.alert {
  border-left: 3px solid var(--warning);
  background: var(--surface-alt);
  padding: .75rem 1rem;
}
.alert-error   { border-left-color: var(--danger); }
.alert-success { border-left-color: var(--success); }

/* Login screen */
.auth-wrap {
  max-width: 420px;
  margin: 3rem auto;
  padding: 0 1rem;
}
.auth-wrap h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-wrap .muted { text-align: center; }

/* Role badges */
.badge {
  display: inline-block; padding: .15rem .55rem;
  border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
}

/* Tiny utility classes — used in place of inline styles so the CSP
   `style-src 'self'` rule stays strict. */
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.ml-1 { margin-left: .5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Language switcher (topbar) */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.btn-lang {
  border: none;
  background: var(--surface);
  color: var(--muted);
  padding: .35rem .8rem;
  font: inherit; font-weight: 600;
  cursor: pointer;
  min-width: 2.5rem;
}
.btn-lang[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-lang:not(:last-child) { border-right: 1px solid var(--border); }
.btn-lang:hover { opacity: .9; }

/* Status badges (topics) */
.badge-draft       { background: var(--surface-alt); color: var(--muted); }
.badge-published   { background: var(--success);     color: #fff; }
.badge-review_open { background: var(--warning);     color: #fff; }
.badge-closed      { background: var(--surface-alt); color: var(--muted); }

/* Topic card (lists on instructor / learner dashboards) */
.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.topic-card .title-row {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap;
}
.topic-card h3 { margin: 0; font-size: 1.05rem; }
.topic-card .meta {
  display: flex; gap: 1rem; flex-wrap: wrap;
  font-size: .9em; color: var(--muted);
}
.topic-card .meta > span { white-space: nowrap; }

/* Stat card (admin dashboard) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}
.stat .label { color: var(--muted); font-size: .85em; }
.stat .value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat .breakdown {
  font-size: .85em; color: var(--muted);
  margin-top: .25rem;
}

/* Audit list */
.audit-list {
  list-style: none; padding: 0; margin: 0;
}
.audit-list li {
  display: flex; gap: .75rem; align-items: baseline;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
}
.audit-list li:last-child { border-bottom: none; }
.audit-list .ts { color: var(--muted); white-space: nowrap; }
.audit-list .action { font-weight: 600; }

/* Tile grid (dashboards) */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
}
.tile h3 { margin: .25rem 0; }
.tile .muted { font-size: .85rem; }
