/* Mind Map module styles. Scoped under .mindmap-page so they don't leak
   into the rest of Easylife's app shell. The strat-* class prefix comes from
   the original Claude Design handoff (Strategize workspace). */

.mindmap-page #mindmap-root,
.mindmap-page #mindmap-root *,
.mindmap-page #mindmap-root *::before,
.mindmap-page #mindmap-root *::after {
  box-sizing: border-box;
}

.mindmap-page {
  background: #090d13;
  color: rgba(220, 225, 235, 0.92);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
}
/* When the artboard runs in light theme we mirror a class onto <body>
   so the page-level (mindmap-main, body safe-area) backgrounds also flip. */
.mindmap-page.mindmap-theme-light { color: oklch(0.14 0.015 265); }

.mindmap-page #mindmap-root {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.strat-artboard {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--bg, #090d13);
}

/* Glass surfaces */
.strat-glass {
  background: var(--surface, rgba(18, 24, 34, 0.72));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  backdrop-filter: blur(18px);
}
.strat-glass-light {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  border-radius: 10px;
}
.theme-light .strat-glass-light { background: rgba(0, 0, 0, 0.04); }

/* Tabs */
.strat-tab {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-m, rgba(200, 210, 225, 0.6));
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}
.strat-tab:hover { color: rgba(220, 225, 235, 0.9); background: rgba(255, 255, 255, 0.05); }
.strat-tab.active {
  background: rgba(128, 128, 128, 0.12);
  color: var(--text, rgba(240, 245, 255, 0.95));
}

/* Chips */
.strat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(128, 128, 128, 0.07);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.09));
  color: var(--text-m, rgba(200, 210, 225, 0.75));
}

/* Buttons */
.strat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  height: 30px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(128, 128, 128, 0.06);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  color: var(--text, rgba(220, 225, 235, 0.88));
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.strat-btn:hover { background: rgba(128, 128, 128, 0.12); }
.strat-btn.sq { width: 30px; padding: 0; justify-content: center; }
.strat-btn.primary {
  background: rgba(180, 150, 255, 0.18);
  border-color: rgba(200, 170, 255, 0.3);
  color: #e0d4ff;
}
.strat-btn.primary:hover { background: rgba(180, 150, 255, 0.26); }

/* Rail icon button */
.strat-rail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-m, rgba(200, 210, 225, 0.65));
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.strat-rail-icon:hover { background: rgba(128, 128, 128, 0.08); color: var(--text, rgba(230, 235, 245, 0.95)); }

/* AI pill */
.strat-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: linear-gradient(135deg, rgba(180, 140, 255, 0.18), rgba(120, 160, 255, 0.12));
  border: 1px solid rgba(180, 150, 255, 0.28);
  color: #d9caff;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.14s;
}
.strat-ai-pill:hover {
  background: linear-gradient(135deg, rgba(180, 140, 255, 0.28), rgba(120, 160, 255, 0.2));
}

/* Editable inline */
.strat-editable { outline: none; border-radius: 4px; transition: background 0.1s; }
.strat-editable:focus {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 1px rgba(180, 150, 255, 0.35);
}

/* Sticky note */
.strat-sticky {
  padding: 14px 14px 16px;
  border-radius: 3px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  font-family: -apple-system, sans-serif;
}

/* Todo row */
.strat-todo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 6px;
}
.strat-todo:hover { background: rgba(255, 255, 255, 0.04); }
.strat-todo .check {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1.5px solid rgba(200, 210, 225, 0.3);
  background: transparent;
}

/* Pulse dot */
.strat-pulse { display: inline-block; animation: stratPulse 2.5s ease-in-out infinite; }
@keyframes stratPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.3); }
}

/* Tooltip */
.strat-tip { position: relative; }
.strat-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  background: rgba(30, 36, 50, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(220, 225, 235, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9000;
}
.strat-tip[data-tip-wide]::after {
  content: attr(data-tip-wide);
  white-space: normal;
  width: 200px;
  text-align: center;
}
.strat-tip:hover::after { opacity: 1; }

/* Right-side tooltip — used by left toolbar buttons so tips appear over canvas */
.strat-tip[data-tip-right]::after {
  content: attr(data-tip-right);
  bottom: auto;
  top: 50%;
  left: calc(100% + 9px);
  transform: translateY(-50%);
  white-space: nowrap;
  z-index: 9000;
}
.strat-tip[data-tip-wide-right]::after {
  content: attr(data-tip-wide-right);
  bottom: auto;
  top: 50%;
  left: calc(100% + 9px);
  transform: translateY(-50%);
  white-space: normal;
  width: 200px;
  text-align: left;
  z-index: 9000;
}

/* Theme variables — scoped to the page so they don't shadow app-shell vars */
.mindmap-page {
  --bg: #090d13;
  --surface: rgba(18, 24, 34, 0.72);
  --surface-s: #0d1119;
  --border: rgba(255, 255, 255, 0.08);
  --border-l: rgba(255, 255, 255, 0.05);
  --text: rgba(220, 225, 235, 0.92);
  --text-m: rgba(200, 210, 225, 0.55);
  --text-f: rgba(200, 210, 225, 0.35);
  --topbar: rgba(10, 14, 20, 0.35);
  --rail: rgba(8, 11, 17, 0.6);
  --panel: rgba(12, 16, 22, 0.55);
  --card: #141922;
  --card-alt: #12181f;
  --accent: #b088ff;
  --glow: rgba(180, 150, 255, 0.08);
}
.theme-light {
  /* Inherit a true-black-on-white text color so labels, dates, etc. inside
     non-themed wrappers also become black instead of the page-level light
     gray. */
  color: oklch(0.14 0.015 265);
  --bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-s: #ffffff;
  --border: rgba(18, 20, 40, 0.09);
  --border-l: rgba(18, 20, 40, 0.055);
  --text: oklch(0.14 0.015 265);
  --text-m: oklch(0.14 0.015 265 / 0.48);
  --text-f: oklch(0.14 0.015 265 / 0.28);
  --topbar: rgba(255, 255, 255, 0.96);
  --rail: #f5f6fa;
  --panel: rgba(255, 255, 255, 0.95);
  --card: #ffffff;
  --card-alt: #f9fafc;
  --accent: oklch(0.52 0.22 285);
  --glow: oklch(0.52 0.22 285 / 0.07);
  --insp-row-bg: rgba(18, 20, 40, 0.03);
  --insp-row-bd: rgba(18, 20, 40, 0.07);
  --insp-btn-bg: rgba(18, 20, 40, 0.05);
  --insp-input-bg: rgba(18, 20, 40, 0.04);
}
.mindmap-page .strat-artboard { background: var(--bg); }
.theme-light .strat-rail-icon { color: oklch(0.14 0.015 265 / 0.38); }
.theme-light .strat-rail-icon:hover {
  background: oklch(0.14 0.015 265 / 0.06);
  color: oklch(0.14 0.015 265 / 0.9);
}
.theme-light .strat-rail-icon[style*='c8b3ff'] {
  color: var(--accent) !important;
  background: oklch(0.52 0.22 285 / 0.1) !important;
}
.theme-light .strat-sticky {
  box-shadow: 0 2px 8px rgba(18, 20, 40, 0.1), 0 0 0 1px rgba(18, 20, 40, 0.07);
}
.theme-light .strat-todo:hover { background: rgba(18, 20, 40, 0.04); }
.theme-light .strat-todo .check { border-color: oklch(0.14 0.015 265 / 0.25); }
.theme-light .strat-ai-pill {
  background: linear-gradient(
    135deg,
    oklch(0.52 0.22 285 / 0.1),
    oklch(0.58 0.18 260 / 0.07)
  );
  border-color: oklch(0.52 0.22 285 / 0.22);
  color: oklch(0.40 0.20 285);
}
.theme-light .strat-chip {
  background: rgba(18, 20, 40, 0.05);
  border-color: rgba(18, 20, 40, 0.09);
  color: oklch(0.14 0.015 265 / 0.58);
}
.theme-light .strat-btn {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(18, 20, 40, 0.12);
  color: oklch(0.14 0.015 265 / 0.85);
  box-shadow: 0 1px 3px rgba(18, 20, 40, 0.06);
}
.theme-light .strat-btn:hover {
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(18, 20, 40, 0.1);
}
.theme-light .strat-btn.primary {
  background: oklch(0.52 0.22 285);
  border-color: oklch(0.45 0.22 285);
  color: #ffffff;
  box-shadow: 0 2px 8px oklch(0.52 0.22 285 / 0.3);
}
.theme-light .strat-btn.primary:hover { background: oklch(0.47 0.22 285); }
.theme-light .strat-tab.active {
  background: rgba(18, 20, 40, 0.07);
  color: oklch(0.14 0.015 265 / 0.92);
}
.theme-light .strat-glass {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(18, 20, 40, 0.09);
  box-shadow: 0 4px 24px rgba(18, 20, 40, 0.08);
}
.theme-light .strat-glass-light {
  background: rgba(18, 20, 40, 0.03);
  border-color: rgba(18, 20, 40, 0.07);
}
.theme-light ::-webkit-scrollbar-thumb { background: rgba(18, 20, 40, 0.15); }
.theme-light .strat-tip::after {
  background: oklch(0.18 0.02 265 / 0.96);
  border-color: rgba(18, 20, 40, 0.12);
  color: #fff;
}
.theme-light .cluster-card {
  background: #ffffff !important;
  border-color: rgba(18, 20, 40, 0.09) !important;
  box-shadow: 0 1px 4px rgba(18, 20, 40, 0.07), 0 4px 16px rgba(18, 20, 40, 0.05) !important;
}
.theme-light .main-card {
  background: #ffffff !important;
  box-shadow: 0 1px 4px rgba(18, 20, 40, 0.07), 0 4px 20px rgba(18, 20, 40, 0.06) !important;
}
.theme-light .medium-card {
  background: #f7f8fc !important;
  border-color: rgba(18, 20, 40, 0.09) !important;
}
.theme-light .deadline-card {
  background: linear-gradient(135deg, oklch(0.65 0.18 25 / 0.07), #ffffff) !important;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0 }
  to   { transform: none;             opacity: 1 }
}

.mindmap-page #mindmap-root ::-webkit-scrollbar { width: 5px; }
.mindmap-page #mindmap-root ::-webkit-scrollbar-track { background: transparent; }
.mindmap-page #mindmap-root ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.linking-mode [contenteditable='true'] { pointer-events: none !important; }
.mindmap-page [contenteditable][data-placeholder]:empty:before {
  content: attr(data-placeholder);
  opacity: 0.4;
  pointer-events: none;
}
.mindmap-page input[type='date'] {
  color-scheme: dark;
  font-family: ui-monospace, monospace;
}
.theme-light input[type='date'] { color-scheme: light; }
.mindmap-page input[type='date']::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
  filter: invert(0.8);
}
.theme-light input[type='date']::-webkit-calendar-picker-indicator { filter: none; }

/* Override the generic app-shell black background so the home-indicator safe
   area (PWA / standalone mode) shows the mindmap's dark canvas colour, not
   pure black. */
body.app-shell.mindmap-page {
  background: #090d13;
}
body.app-shell.mindmap-page.mindmap-theme-light {
  background: #ffffff;
}

/* Layout: tuck the sidebar to the side and let the canvas fill the rest */
.mindmap-page {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.mindmap-main {
  flex: 1;
  margin-left: var(--sidebar-collapsed-width);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #090d13;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}
.mindmap-page.mindmap-theme-light .mindmap-main { background: #ffffff; }
/* Shift canvas when the Easylife sidebar expands */
.app-shell .sidebar:hover ~ .mindmap-main,
.app-shell .sidebar:focus-within ~ .mindmap-main {
  margin-left: var(--sidebar-expanded-width);
}

/* Loading splash — shown until React mounts and hydration completes */
.mindmap-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(220, 225, 235, 0.6);
  font-size: 13px;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.mindmap-loading[hidden] { display: none; }

/* ── Mobile layout ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  /* On mobile the app-shell is flex-column (sidebar on top as horizontal nav).
     The mindmap page must flow accordingly. */
  .mindmap-page {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* Remove the left-margin reservation that was for the desktop sidebar. */
  .mindmap-main {
    margin-left: 0 !important;
    flex: 1;
    height: 0; /* flex:1 + min-height:0 governs the actual height */
    min-height: 0;
    /* Create an isolated stacking context so the topbar's z-index:100 doesn't
       compete with the Easylife sidebar's z-index:30 at the page level. */
    isolation: isolate;
    /* Extend the canvas background into the home-indicator / safe area at the
       bottom so a black bar doesn't show when the app is used as a PWA. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
  }

  /* Prevent the desktop sidebar-hover rule from re-adding margin on mobile. */
  .app-shell .sidebar:hover ~ .mindmap-main,
  .app-shell .sidebar:focus-within ~ .mindmap-main {
    margin-left: 0 !important;
  }

  /* Let the mindmap root fill its parent flex cell, not 100vh. */
  .mindmap-page #mindmap-root {
    height: 100%;
  }
}
