/* ─────────────────────────────────────────────────────────────────
   css/smart-templates.css

   Styles for the Smart Templates accordion (Daily Schedule /
   Simple Grid / Social Story) and their shared modal form.

   Lives in its own file because builder.css is at YELLOW threshold —
   keeping each new surface in its own bundle keeps every CSS
   bundle GREEN under the no-monolith rule.

   LABEL: PILOT-READY. Visual polish only; no functional impact
   if the file is missing (the JS module renders unstyled but
   functional cards).
───────────────────────────────────────────────────────────────── */

/* ── Sidebar accordion intro line ───────────────────────────── */
/* Wave 16.B.3 (2026-05-11): the original CSS used dark-mode
   colors (cream text + rgba-white surfaces) designed for a dark
   sidebar — but the actual sidebar background is WHITE. Result:
   the entire SMART TEMPLATES section rendered as ~5% contrast
   cream-on-white and was effectively invisible (Luke flagged
   "I can't read it" with the screenshot). Re-skinned for the
   light sidebar; same warm-amber accent on hover so the section
   still reads as the AI-driven generator surface. */
.smart-tpl-intro {
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--ink-muted, #6b6b78);
  padding: 0 0 0.6rem 0;
  margin-bottom: 0.4rem;
  border-bottom: 1px dashed var(--ink-muted, #e2e2e7);
}

/* ── Sidebar template cards ─────────────────────────────────── */
.smart-tpl-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.4rem;
  border-radius: 10px;
  background: #fafafc;
  border: 1px solid var(--ink-muted, #e2e2e7);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.smart-tpl-card:hover {
  background: #fff7e6;
  border-color: var(--amber, #f0a93a);
  transform: translateY(-1px);
}
.smart-tpl-card:active { transform: translateY(0); }
.smart-tpl-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.smart-tpl-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.smart-tpl-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink, #1f1f23);
}
.smart-tpl-blurb {
  font-size: 0.72rem;
  color: var(--ink-muted, #6b6b78);
  line-height: 1.25;
}

/* ── Modal — outer host IS the overlay (BottomSheet kind:'modal'
        treats the panel itself as the backdrop). Closed by default
        (opacity:0, pointer-events:none) so the just-appended host
        doesn't flash on screen before BottomSheet opens it. The
        primitive toggles .open. Mobile-tokens.css already enforces
        16px font-size on input/select to defeat iOS zoom. ─────── */
.smart-tpl-modal {
  position: fixed;
  inset: 0;
  z-index: 940;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(26, 26, 46, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.smart-tpl-modal.open {
  opacity: 1;
  pointer-events: auto;
}
.smart-tpl-modal-card {
  background: #FFFFFF;
  color: #1A1A2E;
  border-radius: 16px;
  width: min(520px, 92vw);
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.smart-tpl-modal-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
.smart-tpl-modal-icon {
  font-size: 1.4rem;
  line-height: 1;
}
.smart-tpl-modal-head h3 {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #1A1A2E;
}
.smart-tpl-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
}
.smart-tpl-modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #000;
}
.smart-tpl-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}
.smart-tpl-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

/* ── Form rows ──────────────────────────────────────────────── */
.smart-tpl-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.95rem;
}
.smart-tpl-row:last-child { margin-bottom: 0.25rem; }
.smart-tpl-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1A1A2E;
}
.smart-tpl-input,
.smart-tpl-select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #D8D3C7;
  border-radius: 10px;
  background: #FAF8F2;
  color: #1A1A2E;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.smart-tpl-input:focus,
.smart-tpl-select:focus {
  border-color: #E8A838;
  box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.18);
  background: #FFFFFF;
}
.smart-tpl-hint {
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.55);
  line-height: 1.35;
}

/* ── Buttons ────────────────────────────────────────────────── */
.smart-tpl-cancel,
.smart-tpl-go {
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.smart-tpl-cancel {
  background: transparent;
  color: rgba(0, 0, 0, 0.7);
  border-color: rgba(0, 0, 0, 0.12);
}
.smart-tpl-cancel:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #1A1A2E;
}
.smart-tpl-go {
  background: #E8A838;
  color: #FFF;
  border-color: #E8A838;
}
.smart-tpl-go:hover:not([disabled]) {
  background: #D69426;
  border-color: #D69426;
  transform: translateY(-1px);
}
.smart-tpl-go[disabled] {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

/* ── Super-category row — Wave 16.B.8 owns this now ─────────
   The legacy Wave 2 pill-style super-chip CSS that used to live
   here was deleted on 2026-05-11. Luke called out the duplicate
   pill background as visual noise; the no-pill icon-over-label
   design defined further down (Wave 16.B.8 section) is the
   single source of truth now. */

/* ── Mobile tightens spacing ────────────────────────────────── */
@media (max-width: 480px) {
  .smart-tpl-modal-card { border-radius: 12px; }
  .smart-tpl-modal-head { padding: 0.7rem 0.8rem; }
  .smart-tpl-modal-body { padding: 0.8rem; }
  .smart-tpl-modal-foot { padding: 0.6rem 0.8rem; }
  .smart-tpl-row { margin-bottom: 0.75rem; }
}

/* ─────────────────────────────────────────────────────────────
   Wave 16.B (2026-05-11) — Sidebar templates NN/g polish.
   Apple-style pill chips, single active state, soft hover,
   tightened spacing so the right rail breathes.
   ───────────────────────────────────────────────────────────── */

/* Search input — lifted to top, prominent enough to be the
   first thing the eye lands on. */
.sidebar-acc-body .template-search {
  width: calc(100% - 1rem);
  margin: 0 0.5rem 0.6rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--ink-muted, #d4d4dd);
  border-radius: 999px;
  font-size: 13px;
  background: #fff;
  color: var(--ink, #1f1f23);
}
.sidebar-acc-body .template-search:focus {
  outline: none;
  border-color: #7c5cff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

/* Wave 16.B.8 (2026-05-11) — chip pill-shape removed per Luke:
   "just the icon then the words under it, no pills." Replaces
   the pill background + horizontal layout with a stacked icon-
   over-label cell. No background fill, no border. The active
   state is communicated by a primary-ink color shift on the
   label + a subtle accent dot under the icon — readable without
   shouting. Aligns visually with iOS-style icon nav grids. */
.template-super-bar {
  padding: 0 0.5rem 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 0.35rem 0.15rem;
}
.template-super-chip {
  /* Stacked layout — icon on top, label centered below. */
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.15rem;
  padding: 0.45rem 0.25rem 0.35rem;
  border: none;
  background: transparent;
  color: var(--ink-muted, #6b6b78);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.12s, background 0.12s;
  text-align: center;
  line-height: 1.15;
  min-height: 56px;
}
.template-super-chip:hover {
  color: var(--ink, #1f1f23);
  background: rgba(0, 0, 0, 0.03);
}
.template-super-chip.active {
  color: var(--ink, #1f1f23);
  /* Subtle dot accent below the icon so the active state is
     visible without a pill background. */
  background: transparent;
  position: relative;
}
.template-super-chip.active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: var(--ink, #1f1f23);
}
.template-super-chip-icon {
  font-size: 18px;
  line-height: 1;
}
.template-super-chip-label {
  font-weight: 600;
  font-size: 11px;
  line-height: 1.2;
}
.template-super-chip-count {
  font-size: 10px;
  color: var(--ink-muted, #6b6b78);
  font-weight: 500;
  opacity: 0.75;
}
.template-super-chip.active .template-super-chip-count {
  color: var(--ink-muted, #6b6b78);
}

/* Sub-category row — visible only when a super-cat is engaged.
   Same no-pill philosophy: tiny inline-stacked items with a
   thin underline-style active accent. */
.template-cat-bar {
  border-top: 1px dashed var(--ink-muted, #e2e2e7);
  margin: 0 0.5rem 0.4rem;
  padding: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
}
.template-cat-chip {
  background: transparent;
  border: none;
  padding: 0.2rem 0.05rem 0.3rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted, #6b6b78);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.12s, border-color 0.12s;
  line-height: 1.2;
}
.template-cat-chip:hover {
  color: var(--ink, #1f1f23);
}
.template-cat-chip.active {
  color: var(--ink, #1f1f23);
  border-bottom-color: #7c5cff;
  background: transparent;
}
.template-cat-chip.active .template-cat-chip-count {
  color: var(--ink-muted, #6b6b78);
}

/* ─────────────────────────────────────────────────────────────
   Wave 16.B.4 (2026-05-11) — sidebar-item delete affordance.

   Wave 16.B.10 update (2026-05-11): Luke asked for an
   always-visible "garbage symbol in a square box" — no
   hover-reveal. Each My Boards row now shows a clearly-bordered
   🗑 button at the right edge so deletion is one obvious tap,
   not a discovery hunt.
   ───────────────────────────────────────────────────────────── */
.sidebar-item { position: relative; }
.sidebar-item-del {
  /* Always-visible square button — fixed size, bordered box,
     subtle base state, hover/focus turn red. */
  background: #fff;
  border: 1px solid var(--ink-muted, #d4d4dd);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-muted, #6b6b78);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
  margin-left: 0.4rem;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
.sidebar-item-del:hover,
.sidebar-item-del:focus-visible {
  background: #fef2f2;
  border-color: #dc2626;
  color: #b91c1c;
  outline: none;
}
.sidebar-item-del:active {
  transform: scale(0.95);
}
/* The row's active (selected) state inverts the button so it
   stays readable against the row's highlight tint. */
.sidebar-item.active .sidebar-item-del {
  background: rgba(255, 255, 255, 0.85);
}

/* ─────────────────────────────────────────────────────────────
   Wave 16.B.6 (2026-05-11) — topbar dropdowns + auto-mounted
   pill hides. Per Luke: collapse the 11-pill horizontal soup
   into 👥 Students ▾ + 📱 Device ▾ + standalones. Save / Select
   / Lock removed.
   ───────────────────────────────────────────────────────────── */

/* Container holds the trigger button + the panel that pops below. */
.topbar-dropdown { position: relative; display: inline-flex; }

/* Trigger button — visually identical to other topbar pills so
   the dropdown reads as a single affordance, with a chevron that
   rotates when open. */
.topbar-dropdown-trigger { display: inline-flex; align-items: center; gap: 0.3rem; }
.topbar-dropdown-chev {
  font-size: 0.7em;
  line-height: 1;
  transition: transform 0.15s ease;
}
.topbar-dropdown-trigger[aria-expanded="true"] .topbar-dropdown-chev {
  transform: rotate(180deg);
}

/* Panel — pops below the trigger. Hidden by default via the
   `hidden` attribute on the element itself; this rule adds the
   visual style when it IS shown. */
.topbar-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9000;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--ink-muted, #e2e2e7);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
/* `hidden` on the element wins; the panel doesn't render at all
   when collapsed. The .open class is purely additive for
   future-anim hooks. */
.topbar-dropdown-panel[hidden] { display: none; }

.topbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink, #1f1f23);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  min-height: 40px;
}
.topbar-dropdown-item:hover,
.topbar-dropdown-item:focus-visible {
  background: #f4f4f6;
  outline: none;
}
.topbar-dropdown-item:focus-visible {
  border-color: #7c5cff;
  box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.18);
}

/* Hide the auto-mounted Select and Lock pills — Luke removed
   those affordances from the topbar entirely. Bulk-edit and
   board-lock modules still work via keyboard shortcuts /
   programmatic API; just no longer occupy topbar real estate. */
#topbarBulkBtn, #topbarLockBtn { display: none !important; }

/* Auto-mounted pills that are now subsumed by the Students
   dropdown — hide their standalone topbar versions so they
   don't double up. Their open() functions are called by the
   dropdown items instead. */
#sessionLogPill,
#teacherRosterPill,
#teacherSchedulePill,
#pushClassBtn,
/* Wave 16.B.8: Saved Boards pill in topbar is redundant — the
   sidebar already has its own Saved Boards section. */
#topbarLibraryBtn {
  display: none !important;
}

/* ─────────────────────────────────────────────────────────────
   Wave 16.B.11 (2026-05-11) — Smart Templates moved to the LEFT
   rail (Board Assistant), sized for that narrower column.
   Luke: "we know this goes first, then we talk to the AI under
   it." Tighter padding, smaller blurb font, more compact cards.
   ───────────────────────────────────────────────────────────── */

/* Wrap the section once it's inside .ai-helper-body so the
   accordion takes the rail's full width and respects its
   horizontal padding. */
.ai-helper-body .ai-helper-smart-templates {
  margin: 0.4rem 0.5rem 0.8rem;
  border-bottom: 1px solid var(--ink-muted, #e2e2e7);
  padding-bottom: 0.6rem;
}

/* Tighten the cards for the narrower rail. */
.ai-helper-body .smart-tpl-card {
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.3rem;
}
.ai-helper-body .smart-tpl-icon { font-size: 1.3rem; }
.ai-helper-body .smart-tpl-name { font-size: 0.85rem; }
.ai-helper-body .smart-tpl-blurb {
  font-size: 0.7rem;
  line-height: 1.2;
}
.ai-helper-body .smart-tpl-intro {
  font-size: 0.72rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.5rem;
}

/* ─────────────────────────────────────────────────────────────
   Wave 16.B.12 (2026-05-11) — Symbol Library picker modal.
   The 🎨 Symbols button in the toolbar now opens this modal so
   the user can apply a single library across every tile on the
   board (not per-tile single-swap).
   ───────────────────────────────────────────────────────────── */
.symlib-modal { max-width: 540px; }
.symlib-intro {
  font-size: 0.9rem;
  color: var(--ink-muted, #6b6b78);
  line-height: 1.4;
  margin-bottom: 0.85rem;
}
.symlib-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
.symlib-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--ink-muted, #e2e2e7);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.symlib-card:hover {
  border-color: #7c5cff;
  background: #f9f7ff;
}
.symlib-card.selected {
  border-color: #7c5cff;
  background: #f3efff;
  box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.15);
}
.symlib-card:active { transform: scale(0.99); }
.symlib-icon {
  font-size: 1.7rem;
  line-height: 1;
  align-self: center;
}
.symlib-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.symlib-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink, #1f1f23);
}
.symlib-desc {
  font-size: 0.8rem;
  color: var(--ink-muted, #6b6b78);
  line-height: 1.3;
}
.symlib-progress {
  margin-top: 0.85rem;
  padding: 0.6rem 0.75rem;
  background: #f4f4f6;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--ink, #1f1f23);
  text-align: center;
}
