/* ═══════════════════════════════════════════════════════════════════════════
   KSH — Shared Design Tokens & Base Styles (main.css)
   Extracted from SHub Classroom template. Every page loads this.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --primary: #1E88E5;
  --primary-dark: #1565C0;
  --primary-soft: #E8F2FD;
  --fg: #202227;
  --heading: #22313F;
  --muted: #6B7280;
  --muted-2: #9AA0AB;
  --border: #D8DCF0;
  --border-soft: #EDEFF7;
  --bg: #FFFFFF;
  --bg-soft: #F7F8FC;
  --green: #2BB673;
  --danger: #D32F2F;
  --danger-soft: #FDECEA;
  --success: #2BB673;
  --success-soft: #E6F7EF;
  --radius: 8px;
  --shadow: 0 6px 24px rgba(32,34,39,.12);
  --shadow-sm: 0 2px 8px rgba(32,34,39,.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Icon utility ──────────────────────────────────────────────────── */
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 16px; height: 16px; }

/* ── Shared Components ─────────────────────────────────────────────── */

/* Button — each variant is self-contained (do not require pairing with .btn). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 16px; border-radius: var(--radius); font-size: 15px;
  font-weight: 600; transition: background .15s, opacity .15s;
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff;
  font-weight: 600; font-size: 13px; font-family: inherit; line-height: 1.2;
  cursor: pointer; transition: .15s;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:disabled {
  opacity: 0.55; cursor: not-allowed;
}
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg, #fff);
  font-weight: 600; font-size: 13px; font-family: inherit; line-height: 1.2;
  color: var(--muted); cursor: pointer; transition: .15s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-ghost:disabled {
  opacity: 0.55; cursor: not-allowed;
}
.btn-ghost.icon-only { padding: 8px; }
/* display:inline-flex above beats the UA [hidden] { display:none } rule. */
.btn-primary[hidden],
.btn-ghost[hidden] { display: none !important; }

/* Input / Field */
.field { margin-bottom: 18px; }
.field-label { font-size: 14px; color: var(--fg); margin-bottom: 6px; display: block; font-weight: 500; }
.input-wrap {
  position: relative; display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 8px; transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--primary); }
.input-wrap input, .input-wrap textarea {
  flex: 1; border: none; outline: none; background: none;
  padding: 13px 14px; font-size: 15px; font-family: inherit; color: var(--fg);
}
.input-wrap textarea { resize: vertical; min-height: 80px; }
.input-wrap .toggle-pass { padding: 0 14px; color: var(--muted); display: flex; align-items: center; }

/* Alert / Message */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

/* Card */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden;
}

/* Dropdown Menu */
.menu {
  position: absolute; top: calc(100% + 8px); min-width: 200px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .16s;
}
.menu.right { right: 0; }
.menu.left { left: 0; }
.open > .menu { opacity: 1; visibility: visible; transform: translateY(0); }
.menu-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 8px; font-weight: 500; font-size: 13.5px; color: var(--fg);
  width: 100%; text-align: left; transition: .12s;
}
.menu-item:hover { background: var(--bg-soft); }
.menu-item.danger { color: #EF4444; }
.menu-item.danger:hover { background: #FEF2F2; }
.menu-item .check { margin-left: auto; color: var(--primary); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }
.menu-label { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); }

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg,#7E57C2,#5E35B1);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.avatar-lg { width: 80px; height: 80px; font-size: 28px; }

/* Helper text */
.hint { font-size: 13px; color: var(--muted); margin-top: 18px; line-height: 1.7; }
.hint code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* ── Local toast notifications (window.KshToast) ──────────────────────────── */
.ksh-toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.ksh-toast {
  --toast-accent: var(--primary);
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  color: var(--fg);
  pointer-events: auto;
  animation: ksh-toast-in .18s ease-out both;
}
.ksh-toast::before {
  content: '';
  align-self: stretch;
  background: var(--toast-accent);
}
.ksh-toast.is-success { --toast-accent: var(--success); }
.ksh-toast.is-error { --toast-accent: var(--danger); }
.ksh-toast.is-warning { --toast-accent: #B7791F; }
.ksh-toast-content { min-width: 0; padding: 13px 0; }
.ksh-toast-title { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: var(--heading); }
.ksh-toast-message { margin: 0; overflow-wrap: anywhere; font-size: 13px; color: var(--muted); }
.ksh-toast-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 7px;
  border-radius: 6px;
  color: var(--muted);
}
.ksh-toast-close:hover { background: var(--bg-soft); color: var(--fg); }
.ksh-toast.is-leaving { animation: ksh-toast-out .15s ease-in both; }
@keyframes ksh-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ksh-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-6px); }
}
@media (max-width: 560px) {
  .ksh-toast-stack { top: 12px; right: 12px; width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  .ksh-toast, .ksh-toast.is-leaving { animation: none; }
}

/* ── Confirm modal (window.KshModal.confirm) ───────────────────────── */
/* Global modal styles backing the shared KshModal.confirm helper in app.js.
   Lives in main.css so every page (Members tab, my-classes, admin, ...)
   can use the helper without importing a per-feature stylesheet. */
.ksh-modal {
  border: none;
  padding: 0;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 90%;
  background: var(--bg);
  color: var(--fg);
  /* Native <dialog>[open] from showModal() defaults to top-layer with
     `margin: auto` to center on both axes. Some user-agent stylesheets
     (or our own overrides) collapse this — re-assert auto on all sides. */
  margin: auto;
}
.ksh-modal::backdrop {
  background: rgba(32, 34, 39, .42);
}
.ksh-modal-form {
  padding: 24px 26px;
  margin: 0;
}
.ksh-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--heading);
  margin: 0 0 10px 0;
}
.ksh-modal-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 22px 0;
}
.ksh-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.ksh-modal .btn-ghost,
.ksh-modal .btn-danger {
  padding: 8px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  border: 1px solid var(--border);
}
.ksh-modal .btn-ghost {
  background: var(--bg);
  color: var(--muted);
}
.ksh-modal .btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.ksh-modal .btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.ksh-modal .btn-danger:hover {
  background: #B71C1C;
  border-color: #B71C1C;
}
