/* ============================================================
   calm.css — Calm Topbar design system for the v2 portal redesign.
   Shared shell chrome + hub + login overlay + viewAs banner.
   Ported from design-handoff/{calm-shells.jsx, topbar-home.jsx}.
   Tokens come from ft-tokens.css (--ft-*); this file adds the
   Calm "top" variant (--calm-*) + the components.
   Load order: ft-tokens.css → calm.css → (page-specific css).
   ============================================================ */

/* ─── Calm "top" variant tokens (from VARIANT_TOKENS.top) ─── */
.calm-root {
  --calm-bg:       #fbfaf6;
  --calm-card-bg:  #ffffff;
  --calm-card-br:  #ebe7dc;
  --calm-card-rad: 14px;
  --calm-gap:      24px;
  --calm-h1-size:  34px;

  min-height: 100vh;
  background: var(--calm-bg);
  color: #2d3436;
  font-family: var(--ft-font-sans), system-ui, sans-serif;
}
.calm-root * { box-sizing: border-box; }
.calm-root a { color: inherit; text-decoration: none; }

html, body { margin: 0; padding: 0; }
body { background: var(--calm-bg); }

/* ─── Shell III · Topbar (no sidebar) ─── */
.calm-shell-top { display: flex; flex-direction: column; min-height: 100vh; }
.calm-topbar { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 40px; border-bottom: 1px solid #ececea;
  background: var(--calm-bg); position: sticky; top: 0; z-index: 50; }
.calm-topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.calm-topbar .brand .mark { width: 32px; height: 32px; border-radius: 8px; background: #1e2526;
  color: #00cec9; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; font-family: var(--ft-font-display); flex: 0 0 auto; }
.calm-topbar .brand .name { font-weight: 600; font-size: 15px; color: #1e2526; }
.calm-topbar .brand .role { color: #888; font-weight: 400; font-size: 13.5px; margin-left: 4px; }
.calm-topbar .tabs { display: flex; align-items: center; gap: 4px; padding: 4px;
  background: #f0ede4; border-radius: 10px; }
.calm-topbar .tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 7px; font-size: 13.5px; color: #6d6d6d; font-weight: 500;
  transition: background 0.15s, color 0.15s; cursor: pointer; }
.calm-topbar .tabs a:hover { color: #2d3436; }
.calm-topbar .tabs a.active { background: #fff; color: #1e2526; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.calm-topbar .tabs a .b { display: inline-block; background: #00cec9; color: #1e2526; font-size: 11px;
  font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.calm-topbar .right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.calm-topbar .right .ibtn { width: 34px; height: 34px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; color: #6d6d6d; transition: background 0.15s;
  cursor: pointer; border: none; background: transparent; }
.calm-topbar .right .ibtn:hover { background: #f0ede4; color: #2d3436; }
.calm-topbar-main { flex: 1; min-height: 0; }

/* ─── Mobile bottom tab bar (hidden on desktop) ───
   At ≤720px the segmented topbar nav is replaced by a fixed bottom tab bar.
   Both are emitted from the same `tabs` data (shell-v3.js); CSS toggles which
   shows. Ported from design-handoff/calm-shells.jsx. */
.mobile-tabs { display: none; }

/* ─── Hub (home) ─── (from topbar-home.jsx hubCss) */
.hub { padding: 36px 56px 56px; max-width: 1280px; margin: 0 auto; }
.hub .head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 28px; }
.hub .head h1 { font-family: var(--ft-font-sans); font-weight: 600;
  font-size: var(--calm-h1-size, 32px); line-height: 1.15;
  letter-spacing: -0.02em; margin: 0; color: #1e2526; }
.hub .head .sub { color: #6d6d6d; font-size: 15px; }

.hub-grid { display: grid; gap: 18px; }
.hub-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.hub-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.hub-card { position: relative; background: var(--calm-card-bg, #fff);
  border: 1px solid var(--calm-card-br, #ebe7dc);
  border-radius: var(--calm-card-rad, 14px);
  padding: 22px 24px 20px; display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; min-height: 240px; }
.hub-card:hover { border-color: #c8c1ad; transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.04); }
.hub-card:hover .hub-arr { opacity: 1; transform: translate(0,0); color: #00b3ae; }

/* Stretched-link pattern: the title anchor's ::before overlays the whole card. */
.hub-card .hub-card-link { color: inherit; text-decoration: none; }
.hub-card .hub-card-link::before { content: ''; position: absolute; inset: 0;
  z-index: 1; border-radius: inherit; }

.hub-card .hub-arr { position: absolute; top: 22px; right: 22px; color: #c8c1ad;
  opacity: 0; transform: translate(-4px, 4px); transition: opacity 0.15s, transform 0.18s, color 0.15s; }

.hub-card .top { display: flex; gap: 14px; align-items: flex-start; padding-right: 30px; }
.hub-card .icw { width: 40px; height: 40px; border-radius: 10px;
  background: rgba(0,206,201,0.10); color: #00b3ae;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.hub-card .titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hub-card h3 { font-family: var(--ft-font-sans); font-weight: 600; font-size: 16px;
  margin: 0; color: #1e2526; letter-spacing: -0.01em; line-height: 1.3; }
.hub-card .desc { font-size: 13.5px; color: #6d6d6d; line-height: 1.45; text-wrap: pretty; }

/* Preview block. */
.hub-pv { display: flex; flex-direction: column; gap: 10px; margin-top: 2px;
  padding-top: 14px; border-top: 1px dashed #ece8dc; }
.hub-pv .sum { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px;
  font-weight: 600; color: #6d6d6d; }
.hub-pv .sum .dotpx { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.hub-pv .sum.warn { color: #c2410c; }
.hub-pv .sum.info { color: #6d28d9; }
.hub-pv .sum.ok   { color: #00867f; }
.hub-pv .muted { font-size: 12.5px; color: #9c9786; font-style: italic; }

/* Generic list preview — recent items as stacked name (.pt) + subtitle (.ps).
   Used by the tutor Home cards (Students / Assignments / Q&A). */
.hub-pv ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hub-pv li { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hub-pv li .pt { font-size: 13.5px; color: #2d3436; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-pv li .ps { font-size: 12px; color: #888; }

/* Key-value preview (stat-heavy cards). */
.hub-pv .kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13px; }
.hub-pv .kv dt { color: #888; }
.hub-pv .kv dd { margin: 0; color: #2d3436; font-weight: 500; font-variant-numeric: tabular-nums lining-nums; }
.hub-pv .kv dd.warn { color: #c2410c; }
.hub-pv .kv dd.ok   { color: #00867f; }

/* Single-line "last viewed / last staged" pointer — Question Browser card. */
.hub-pv .ptr { font-size: 13px; color: #6d6d6d; line-height: 1.45; }
.hub-pv .ptr strong { color: #2d3436; font-weight: 500; }

/* Subject pills — Learning card. z-index:2 so they sit above the stretched link. */
.hub-pv .subj { display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 2; }
.hub-pv .subj .sj { display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 3px 9px; border-radius: 50px;
  background: rgba(0,206,201,0.10); color: #00867f; font-weight: 500;
  text-decoration: none; transition: background 0.15s, color 0.15s; }
.hub-pv .subj a.sj:hover { background: rgba(0,206,201,0.18); color: #006661; }
.hub-pv .subj .sj .bd { color: #888; font-weight: 400; }

.hub-pv .lastlesson { font-size: 13px; color: #6d6d6d; line-height: 1.5; }
.hub-pv .lastlesson .when { color: #2d3436; font-weight: 500; }

/* Assignment row with progress bar. */
.hub-pv .asg { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hub-pv .asg .ln { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.hub-pv .asg .ln .t { font-size: 13.5px; color: #2d3436; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hub-pv .asg .sub { font-size: 11.5px; color: #888; margin-top: -2px; }
.hub-pv .bar { display: flex; height: 4px; width: 100%; background: #ece8dc;
  border-radius: 2px; overflow: hidden; }
.hub-pv .bar .seg-correct { background: #00cec9; }
.hub-pv .bar .seg-submitted { background: rgba(230,126,34,0.55); }

/* Q&A row with status dot. */
.hub-pv .qa { display: grid; grid-template-columns: 9px 1fr; gap: 9px; align-items: start; padding: 1px 0; }
.hub-pv .qa .sdot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px;
  background: #c2410c; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(194,65,12,0.12); }
.hub-pv .qa .sdot.answered { background: #00867f; box-shadow: 0 0 0 3px rgba(0,206,201,0.18); }
.hub-pv .qa .sdot.followup { background: #6d28d9; box-shadow: 0 0 0 3px rgba(124,58,237,0.16); }
.hub-pv .qa .body { min-width: 0; }
.hub-pv .qa .body .q { font-size: 13.5px; color: #2d3436; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-pv .qa .body .q.image-only { display: inline-flex; align-items: center; gap: 6px;
  color: #6d6d6d; font-weight: 500; }
.hub-pv .qa .body .q.image-only em { font-style: normal; }
.hub-pv .qa .body .m { font-size: 11.5px; color: #888; }
.hub-pv .qa .body .m .stl { font-weight: 500; }
.hub-pv .qa .body .m .stl.waiting { color: #c2410c; }
.hub-pv .qa .body .m .stl.answered { color: #00867f; }
.hub-pv .qa .body .m .stl.followup { color: #6d28d9; }

/* ─── Login overlay (calm restyle of the v1 markup; same IDs) ─── */
.login-overlay { position: fixed; inset: 0; z-index: 1000; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: var(--calm-bg, #fbfaf6); }
.login-box { background: #fff; border: 1px solid var(--calm-card-br, #ebe7dc);
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.08);
  padding: 36px 32px; width: 100%; max-width: 380px; text-align: center; }
.login-box .login-logo { width: 64px; height: auto; margin-bottom: 12px; }
.login-box h2 { font-family: var(--ft-font-sans); font-weight: 600; font-size: 22px;
  color: #1e2526; margin: 0 0 4px; letter-spacing: -0.01em; }
.login-box .login-subtitle { color: #888; font-size: 13.5px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input { width: 100%; padding: 11px 13px; font-size: 16px;
  border: 1px solid var(--calm-card-br, #ebe7dc); border-radius: 9px;
  font-family: inherit; color: #2d3436; background: #fcfbf7; transition: border-color 0.15s; }
.login-form input:focus { outline: none; border-color: #00cec9;
  box-shadow: 0 0 0 3px rgba(0,206,201,0.12); }
.login-form button { width: 100%; padding: 11px; font-size: 15px; font-weight: 600;
  color: #1e2526; background: #00cec9; border: none; border-radius: 9px; cursor: pointer;
  transition: background 0.15s; margin-top: 4px; }
.login-form button:hover { background: #00b3ae; }
.login-form button:disabled { opacity: 0.6; cursor: default; }
.login-error { color: #cf1322; font-size: 13px; min-height: 18px; }

/* ─── viewAs banner (admin preview) ─── */
.calm-viewas { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; max-width: 1280px; margin: 16px auto 0; padding: 10px 18px;
  background: rgba(244,180,0,0.10); border: 1px solid rgba(244,180,0,0.45);
  border-radius: 10px; font-size: 14px; color: #8a6d00; }
.calm-viewas a { color: #8a6d00; font-weight: 600; text-decoration: underline; font-size: 13px; }
.calm-viewas-actions { display: flex; align-items: center; gap: 16px; }

/* ─── Shared small states for previews ─── */
.calm-loading, .calm-error, .calm-empty { font-size: 13px; color: #888; }
.calm-error { color: #cf1322; }

/* ─── Admin shell (ShellV3.bootAdminPage) — persistent left SIDEBAR ───
   Admin has ~10 sections — too many for the segmented top nav the student /
   tutor portals use — so the admin shell is a fixed left sidebar instead of a
   topbar: a brand header (links Home), a vertical nav of every section, and a
   footer (Tutor-portal jump / Settings / Sign out / identity). On ≤720px it
   collapses to a hamburger-toggled drawer (see the @media block below). Scoped
   to .calm-admin-sb so the shared .calm-topbar styles are untouched. */
.calm-admin-sb .calm-shell-side { display: flex; align-items: stretch; min-height: 100vh; }
.calm-sidebar { position: sticky; top: 0; align-self: flex-start; height: 100vh;
  width: 236px; flex: 0 0 236px; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 14px; background: #fff; border-right: 1px solid var(--calm-card-br, #ebe7dc); }
.calm-sidebar .sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.calm-sidebar .sb-brand .mark { width: 34px; height: 34px; border-radius: 9px; background: #1e2526;
  color: #00cec9; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; font-family: var(--ft-font-display); flex: 0 0 auto; }
.calm-sidebar .sb-brand-txt { display: flex; flex-direction: column; min-width: 0; }
.calm-sidebar .sb-brand-txt .name { font-weight: 600; font-size: 15px; color: #1e2526; line-height: 1.2; }
.calm-sidebar .sb-brand-txt .role { font-size: 12.5px; color: #9c9786; }
.calm-sidebar .sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.calm-sidebar .sb-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: 9px; font-size: 14px; color: #6d6d6d; font-weight: 500;
  transition: background 0.15s, color 0.15s; }
.calm-sidebar .sb-nav a:hover { background: #f4f1e8; color: #2d3436; }
.calm-sidebar .sb-nav a.active { background: #eafaf9; color: #00867f; font-weight: 600; }
.calm-sidebar .sb-nav a.active svg { color: #00b3ae; }
.calm-sidebar .sb-foot { display: flex; flex-direction: column; gap: 2px;
  padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--calm-card-br, #ebe7dc); }
.calm-sidebar .sb-link { display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: 9px; font-size: 13.5px; color: #6d6d6d; font-weight: 500; cursor: pointer;
  background: none; border: none; width: 100%; text-align: left; font-family: inherit; }
.calm-sidebar .sb-link:hover { background: #f4f1e8; color: #2d3436; }
.calm-sidebar .sb-user { display: flex; align-items: center; gap: 9px; padding: 12px 9px 2px;
  font-size: 13px; color: #6d6d6d; min-width: 0; }
.calm-sidebar .sb-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calm-side-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.calm-side-main .sb-topbar { display: none; }   /* the slim bar is mobile-only */
.calm-admin-sb .sb-scrim { display: none; }

/* ═══ Mobile (≤720px) — single breakpoint per MOBILE_RESPONSIVE_HANDOFF.md ═══
   Topbar compacts (π only, segmented nav + desktop-only icons hidden); a fixed
   bottom tab bar appears; the hub stacks single-column. Per-page bodies append
   their own ≤720px rules to this file (or their own stylesheet) as they ship. */
@media (max-width: 720px) {
  /* Topbar compaction */
  .calm-shell-top { padding-bottom: env(safe-area-inset-bottom); }
  .calm-topbar { padding: 12px 16px; }
  .calm-topbar .brand .name { display: none; }
  .calm-topbar .brand .role { display: none; }
  .calm-topbar .tabs { display: none; }
  .calm-topbar .right { gap: 6px; }
  .calm-topbar .right .ibtn.desktop-only { display: none; }
  /* Reserve bottom-tab clearance ONLY on shells that render a populated
     .mobile-tabs bar (student/tutor + the employee Home/Browser nav). Settings/
     admin shells have no bottom tab bar, so they get no dead space. */
  .calm-topbar-main { padding-bottom: 0; }
  .calm-shell-top:has(.mobile-tabs a) .calm-topbar-main { padding-bottom: 76px; }

  /* Fixed bottom tab bar */
  .mobile-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 50; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,0.92); backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border-top: 1px solid #ebe7dc; box-shadow: 0 -2px 12px rgba(0,0,0,0.04); }
  .mobile-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 3px; padding: 6px 4px; border-radius: 10px; color: #888;
    font-size: 11px; font-weight: 500; transition: color 0.15s, background 0.15s;
    position: relative; min-width: 0; text-decoration: none; }
  .mobile-tabs a:hover { color: #2d3436; }
  .mobile-tabs a.active { color: #00867f; }
  .mobile-tabs a.active::before { content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 24px; height: 2px; background: #00cec9;
    border-radius: 2px; }
  .mobile-tabs a .lbl { white-space: nowrap; }
  .mobile-tabs a .b { position: absolute; top: 4px; right: 18%; min-width: 16px; height: 16px;
    padding: 0 4px; line-height: 16px; text-align: center;
    background: #c2410c; color: #fff; border-radius: 8px;
    font-size: 10px; font-weight: 700; box-shadow: 0 0 0 2px #fff; }

  /* Hub (home) stacks single-column */
  .hub { padding: 20px 16px 28px; }
  .hub .head { margin-bottom: 18px; }
  .hub .head h1 { font-size: 24px; letter-spacing: -0.015em; }
  .hub .head .sub { font-size: 13.5px; }
  .hub-grid.cols-2, .hub-grid.cols-3 { grid-template-columns: 1fr; gap: 12px; }
  .hub-card { padding: 18px 18px 16px; min-height: 0; }
  .hub-card .top { padding-right: 18px; }
  .hub-card h3 { font-size: 15.5px; }
  .hub-card .desc { font-size: 13px; max-width: none; }
  .hub-card .hub-arr { top: 16px; right: 16px; }
  .hub-pv { padding-top: 10px; }
  .hub-pv .kv { grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; }

  /* viewAs banner full-bleed */
  .calm-viewas { margin: 12px 16px 0; }

  /* Admin sidebar → off-canvas drawer at ≤720px. A slim top bar (sb-topbar)
     carries the hamburger + active-section title; the sidebar slides in over a
     scrim. The admin shell renders no .mobile-tabs bar — the drawer replaces it,
     so the 76px bottom clearance the topbar shells reserve isn't needed here. */
  .calm-admin-sb .calm-shell-side { display: block; }
  .calm-admin-sb .calm-topbar-main { padding-bottom: 0; }
  .calm-admin-sb .calm-sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100%;
    width: 264px; flex-basis: 264px; z-index: 60; transform: translateX(-100%);
    transition: transform 0.22s ease; box-shadow: 0 0 40px rgba(0,0,0,0.18); }
  .calm-admin-sb.sb-open .calm-sidebar { transform: translateX(0); }
  .calm-admin-sb .calm-side-main .sb-topbar { display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; background: var(--calm-bg); border-bottom: 1px solid #ececea;
    position: sticky; top: 0; z-index: 20; }
  .sb-burger { width: 38px; height: 38px; border-radius: 9px; flex: 0 0 auto;
    border: 1px solid var(--calm-card-br, #ebe7dc); background: #fff; color: #2d3436;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
  .sb-topbar-title { font-weight: 600; font-size: 15px; color: #1e2526; }
  .calm-admin-sb .sb-scrim { display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(20,22,22,0.34); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .calm-admin-sb.sb-open .sb-scrim { opacity: 1; pointer-events: auto; }

  /* Modal form inputs: 16px prevents iOS auto-zoom on focus.
     calm-modals.js injects its CSS at runtime (after calm.css), so this
     override uses !important to win the cascade. */
  .qa-field input[type="text"],
  .qa-field select,
  .qa-field textarea { font-size: 16px !important; }
}
