/* Whatsio design tokens + shared primitives.
   Single source of truth — page templates must not redefine these. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Whatsio brand — Figma gradient: #0599C0 at 41% → #17CAD0 at 100% */
  --brand: #17CAD0;
  --brand-deep: #0599C0;
  --brand-text: #06779B;
  --brand-grad: linear-gradient(135deg, #0599C0 41%, #17CAD0 100%);
  --brand-tint: #e6f8fa;
  --brand-border: rgba(5,153,192,0.20);
  --ink: #0d0d12;
  --text: #1a1a1f;
  --sub: #5a5a6a;
  --muted: #9a9aaa;
  --line: rgba(0,0,0,0.08);
  --surface: #f8f8fa;
  --field: #f4f5f7;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: #fff;
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--brand-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ── shared nav ─────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 72px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark-img {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: block; flex-shrink: 0;
  object-fit: contain;
}
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.nav-links { display: flex; align-items: center; gap: 34px; list-style: none; }
.nav-links a { color: var(--sub); font-size: 14px; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-cta {
  color: #fff !important; font-weight: 600 !important;
  background: var(--brand-grad);
  padding: 12px 24px; border-radius: 100px;
  transition: opacity 0.2s;
}
.nav-cta:hover { opacity: 0.88; }

/* ── shared buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  letter-spacing: 0.03em; padding: 13px 28px;
  border-radius: 100px; border: none; cursor: pointer;
  transition: all 0.2s;
}
.btn-solid { background: var(--brand-grad); color: #fff; }
.btn-solid:hover { opacity: 0.88; }
.btn-outline { background: transparent; color: var(--sub); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--muted); color: var(--text); }

/* ── shared footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--line);
  padding: 28px 40px;
  display: flex; align-items: center; justify-content: space-between;
}
.f-copy { font-size: 11px; font-weight: 300; color: var(--muted); letter-spacing: 0.04em; }

@media (max-width: 860px) {
  nav { padding: 0 20px; height: 64px; }
  .nav-links li:not(:last-child) { display: none; }
  .brand-mark-img { width: 40px; height: 40px; border-radius: 11px; }
  .brand-name { font-size: 18px; }
  footer { padding: 24px 20px; flex-direction: column; gap: 10px; text-align: center; }
}

/* ═══════════════════════════════════════════════════════════════
   APP CHROME — logged-in shell (base_app.html)
   Shared by dashboard, builder, analytics, settings.
   ═══════════════════════════════════════════════════════════════ */

.app-nav {
  position: sticky; top: 0; z-index: 200;
  height: 64px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.app-nav .brand-lockup { gap: 10px; }
.app-nav .brand-mark-img { width: 38px; height: 38px; border-radius: 11px; }
.app-nav .brand-name { font-size: 19px; }

.app-nav-right { display: flex; align-items: center; gap: 30px; }

.app-links { display: flex; align-items: center; gap: 28px; list-style: none; }
.app-links a {
  font-size: 14px; font-weight: 500; color: var(--sub);
  padding: 4px 0; position: relative; transition: color 0.18s;
}
.app-links a:hover { color: var(--text); }
.app-links a.active { color: var(--brand-text); font-weight: 600; }
.app-links a.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -21px;
  height: 2px; background: var(--brand-deep); border-radius: 2px;
}

.app-nav .nav-cta { padding: 9px 20px; font-size: 13px !important; }

.user-menu { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: var(--surface);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--sub);
}
.user-caret { width: 14px; height: 14px; color: var(--muted); }

/* dropdown */
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 190px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(13,13,18,0.10);
  padding: 6px; opacity: 0; visibility: hidden;
  transform: translateY(-4px); transition: all 0.16s;
}
.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--text); transition: background 0.14s;
}
.user-dropdown a:hover { background: var(--surface); }
.user-dropdown hr { border: none; height: 1px; background: var(--line); margin: 5px 0; }
.user-dropdown a.danger { color: #dc2626; }

/* app main area */
.app-main { max-width: 960px; margin: 0 auto; padding: 34px 28px 64px; }

/* slim footer */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 22px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.app-footer .foot-mark-img {
  width: 26px; height: 26px; border-radius: 7px;
  opacity: 0.45; filter: grayscale(1);
}
.app-foot-copy { font-size: 12px; color: var(--muted); margin-left: auto; }
.app-social { display: flex; gap: 16px; }
.app-social a { color: var(--muted); display: flex; transition: color 0.16s; }
.app-social a:hover { color: var(--sub); }
.app-social svg { width: 17px; height: 17px; }

/* floating help button */
.help-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 150;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  transition: transform 0.16s, box-shadow 0.16s;
}
.help-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,0.28); }

@media (max-width: 720px) {
  .app-nav { padding: 0 16px; }
  .app-links { display: none; }
  .app-nav .nav-cta { display: none; }
  .app-main { padding: 24px 16px 48px; }
  .app-footer { flex-wrap: wrap; }
  .help-fab { right: 16px; bottom: 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   COURSE BUILDER — full-bleed three-column workspace
   (base_builder.html). Left: outline. Centre: canvas. Right: preview.
   ═══════════════════════════════════════════════════════════════ */

.builder-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* top bar reuses .app-nav but is not sticky-scrolling a page */
.builder-body .app-nav { flex-shrink: 0; }

.builder-grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr 400px;
  overflow: hidden;
}

/* ── left: course outline ───────────────────────────────────── */
.outline {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto; padding: 22px 18px;
}
.outline-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand-text); margin-bottom: 4px; }
.outline-title { font-family: var(--sans); font-weight: 600; font-size: 18px; color: var(--ink); margin-bottom: 20px; letter-spacing: -0.01em; }

.module {
  border: 1px solid var(--line); border-radius: 11px;
  margin-bottom: 8px; overflow: hidden; background: #fff;
}
.module-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 13px; cursor: pointer; user-select: none;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.module.active .module-head { background: var(--brand-tint); color: var(--brand-text); }
.module-grip { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.module-caret { margin-left: auto; color: var(--muted); width: 15px; height: 15px; transition: transform 0.18s; }
.module.collapsed .module-caret { transform: rotate(-90deg); }
.module-lessons { padding: 2px 0 8px; }
.module.collapsed .module-lessons { display: none; }
.lesson {
  padding: 8px 13px 8px 30px; font-size: 12.5px; color: var(--sub);
  cursor: pointer; border-radius: 7px; margin: 0 6px;
}
.lesson:hover { background: var(--surface); }
.lesson.active { color: var(--brand-text); font-weight: 500; }

.add-module {
  border: 1px dashed rgba(0,0,0,0.16); border-radius: 11px;
  padding: 12px; text-align: center; font-size: 13px; color: var(--sub);
  cursor: pointer; background: none; width: 100%; font-family: var(--sans);
  transition: border-color 0.16s, color 0.16s;
}
.add-module:hover { border-color: var(--brand); color: var(--brand-text); }

/* empty outline */
.outline-empty {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 28px 16px; text-align: center; margin-bottom: 8px;
}
.outline-empty .oe-ico {
  width: 44px; height: 44px; border-radius: 50%; background: var(--surface);
  margin: 0 auto 12px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--muted);
}
.outline-empty h4 { font-size: 13.5px; color: var(--ink); margin-bottom: 5px; }
.outline-empty p { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* magic AI creator card, pinned bottom */
.magic-card {
  margin-top: auto; border: 1px solid var(--brand-border);
  background: var(--brand-tint); border-radius: 12px; padding: 16px;
}
.magic-card h4 { font-size: 13px; color: var(--ink); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.magic-card p { font-size: 11.5px; color: var(--sub); line-height: 1.5; margin-bottom: 12px; }
.magic-btn {
  background: var(--brand-grad); color: #fff; border: none; border-radius: 8px;
  padding: 9px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: var(--sans); width: 100%;
}

/* ── centre: canvas ─────────────────────────────────────────── */
.canvas-col { display: flex; flex-direction: column; overflow: hidden; }
.canvas-bar {
  flex-shrink: 0; height: 54px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 13px; color: var(--muted); position: relative;
}
.canvas-undo { position: absolute; right: 20px; display: flex; gap: 6px; }
.canvas-undo button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--sub); cursor: pointer; font-size: 14px;
}
.canvas-undo button:disabled { opacity: 0.4; cursor: default; }

.canvas {
  flex: 1; overflow-y: auto; padding: 34px 40px 120px;
  max-width: 680px; margin: 0 auto; width: 100%;
}
.course-title-input {
  font-family: var(--sans); font-weight: 700; font-size: 28px; color: var(--ink);
  border: none; outline: none; width: 100%; background: none;
  padding: 6px 0; letter-spacing: -0.02em;
}
.course-title-input::placeholder { color: #c8c8d2; }
.course-desc-input {
  font-size: 14.5px; color: var(--sub); border: none; outline: none;
  width: 100%; background: none; resize: none; padding: 10px 0;
  border-bottom: 1px solid var(--line); margin-bottom: 30px; font-family: var(--sans);
  line-height: 1.6;
}
.course-desc-input::placeholder { color: var(--muted); }

/* a rendered content block on the canvas */
.block { border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; position: relative; }
.block img { width: 100%; border-radius: 9px; display: block; }
.block-q { padding: 20px 22px; }
.block-q-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--brand-text); background: var(--brand-tint); padding: 4px 10px; border-radius: 100px; margin-bottom: 14px; }
.block-q h3 { font-size: 17px; color: var(--ink); font-weight: 600; margin-bottom: 16px; }
.q-option {
  border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px;
  font-size: 14px; color: var(--text); margin-bottom: 9px;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.q-option.selected { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-text); }
.q-option .check { color: var(--brand); }

/* component toolbar (floating pill) */
.toolbar {
  display: inline-flex; gap: 4px; padding: 7px;
  background: #fff; border: 1px solid var(--line); border-radius: 100px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.10);
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 14px; border-radius: 100px; cursor: pointer;
  font-size: 10px; color: var(--sub); border: none; background: none; font-family: var(--sans);
  transition: background 0.14s;
}
.tool:hover { background: var(--surface); }
.tool-ico {
  width: 30px; height: 30px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.tool-ico.text  { background: var(--brand); }
.tool-ico.media { background: #e8912d; }
.tool-ico.audio { background: #2f7de1; }
.tool-ico.quiz  { background: #8a5cf6; }
.tool-ico.poll  { background: #ec4899; }

/* empty canvas centre */
.canvas-empty { text-align: center; padding: 70px 20px; }
.canvas-empty .ce-ico {
  width: 84px; height: 84px; border-radius: 50%; background: var(--brand-tint);
  margin: 0 auto 20px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; position: relative;
}
.canvas-empty .ce-plus {
  position: absolute; right: -4px; bottom: -4px; width: 30px; height: 30px;
  background: #fff; border: 1px solid var(--line); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--brand-text); font-size: 16px;
}
.canvas-empty h2 { font-size: 22px; font-weight: 600; color: var(--ink); margin-bottom: 12px; }
.canvas-empty p { font-size: 14px; color: var(--sub); line-height: 1.6; max-width: 360px; margin: 0 auto; }

.add-slot {
  border: none; background: none; cursor: pointer; display: flex;
  flex-direction: column; align-items: center; gap: 8px; margin: 8px auto 0;
  color: var(--muted); font-size: 12px; font-family: var(--sans);
}
.add-slot .as-circle {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--sub);
}

/* ── right: live preview ────────────────────────────────────── */
.preview-col {
  border-left: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto; padding: 20px 24px 40px;
}
.preview-tab {
  align-self: stretch; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--brand-text); background: #fff; border: 1px solid var(--line);
  border-radius: 100px; padding: 11px; margin-bottom: 26px;
}

/* whatsapp phone frame */
.wa-phone {
  width: 300px; border-radius: 30px; background: #111;
  padding: 10px; box-shadow: 0 20px 50px rgba(0,0,0,0.22); flex-shrink: 0;
}
.wa-screen { border-radius: 22px; overflow: hidden; background: #f7f8fa; display: flex; flex-direction: column; height: 540px; }
.wa-top {
  background: var(--brand-grad); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.wa-back { font-size: 16px; opacity: 0.9; }
.wa-course-ava { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.wa-top-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.wa-top-sub { font-size: 9px; opacity: 0.8; }
.wa-thread { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.wa-day { align-self: center; background: rgba(255,255,255,0.7); border-radius: 7px; font-size: 9px; color: #555; padding: 3px 9px; }
.wa-bubble { max-width: 82%; padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,0.06); }
.wa-bubble.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.wa-bubble.out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.wa-bubble img { width: 100%; border-radius: 6px; margin-bottom: 5px; display: block; }
.wa-bubble strong { font-weight: 600; }
.wa-reply-btn { background: #fff; border-radius: 7px; text-align: center; font-size: 11.5px; color: var(--brand-deep); padding: 8px; margin-top: 4px; box-shadow: 0 1px 1px rgba(0,0,0,0.06); }
.wa-input-bar { background: #f0f0f0; padding: 8px 10px; display: flex; align-items: center; gap: 8px; }
.wa-input-box { flex: 1; background: #fff; border-radius: 100px; padding: 8px 14px; font-size: 11px; color: var(--muted); }
.wa-send-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }

/* preview empty */
.wa-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--muted); }
.wa-empty-ico { width: 60px; height: 60px; border-radius: 50%; background: rgba(0,0,0,0.06); display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 14px; }
.wa-empty p { font-size: 11.5px; line-height: 1.5; max-width: 160px; }

@media (max-width: 1100px) {
  .builder-grid { grid-template-columns: 220px 1fr 340px; }
  .wa-phone { width: 270px; }
}
@media (max-width: 860px) {
  .builder-grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .outline, .preview-col { display: none; }  /* TODO: drawer toggles on mobile */
}
