/* ============================================================
   km-shared.css — Lern mit Ben · Konzept-Mapper Shared Styles
   Phase 1: Mode-Navigation, App-Shell, Onboarding, Utilities
   ============================================================ */

/* ─── CSS Reset für km-Komponenten ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Design Tokens (erweitert LMB-Tokens) ─────────────────── */
:root {
  --km-nav-h:        48px;
  --km-toolbar-h:    52px;
  --km-shell-top:    calc(var(--km-nav-h) + var(--km-toolbar-h));

  /* Modus-Farben */
  --km-mindmap:      #8B5CF6;   /* Violet */
  --km-organigramm:  #10B981;   /* Emerald */
  --km-flussdiagramm:#F59E0B;   /* Amber */
  --km-swot:         #6366F1;   /* Indigo */
  --km-konzeptmap:   #6366F1;   /* Indigo (bestehend) */

  /* SWOT-Quadranten */
  --km-swot-s:       #10B981;
  --km-swot-w:       #EF4444;
  --km-swot-o:       #6366F1;
  --km-swot-t:       #F59E0B;

  /* Dot-Grid */
  --km-grid-dot:     rgba(255, 255, 255, 0.055);
  --km-grid-size:    24px;
}

/* ─── Basis-Body für neue Modus-Seiten ─────────────────────── */
body.km-page {
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  background: #0A0F1A;
  color: #F8FAFC;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ─── MODE NAV ──────────────────────────────────────────────── */
#km-mode-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--km-nav-h);
  z-index: 9999;
  background: #141B2D;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
#km-mode-nav::-webkit-scrollbar { display: none; }

.km-nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 36px;
  border-radius: 8px;
  text-decoration: none;
  color: #94A3B8;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  position: relative;
  flex-shrink: 0;
}
.km-nav-tab:hover {
  color: #F8FAFC;
  background: rgba(255,255,255,0.05);
  text-decoration: none;
}
.km-nav-tab.active {
  color: #F8FAFC;
  background: rgba(99,102,241,0.12);
}
.km-nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -7px; left: 8px; right: 8px;
  height: 2px;
  background: #6366F1;
  border-radius: 2px 2px 0 0;
}
.km-nav-tab svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.km-nav-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 100px;
  background: #10B981;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.km-ai-link {
  position: sticky;
  right: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  margin-left: auto;
  border-radius: 9px;
  color: #F8FAFC;
  background: #141B2D;
  opacity: 0.52;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.km-ai-link::before {
  content: '';
  position: absolute;
  top: 0;
  right: 100%;
  width: 18px;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, #141B2D);
}
.km-ai-link img { width: 24px; height: 24px; display: block; }
.km-ai-link:hover,
.km-ai-link:focus-visible {
  opacity: 1;
  background: rgba(255,255,255,0.07);
  transform: translateY(-1px);
}
.km-ai-link:focus-visible {
  outline: 2px solid #A5B4FC;
  outline-offset: -2px;
}

@media print {
  .km-ai-link { display: none !important; }
}

/* Responsive: Labels ausblenden unter 640px */
@media (max-width: 639px) {
  .km-nav-tab { padding: 0 10px; gap: 0; }
  .km-nav-label { display: none; }
  .km-nav-badge { position: absolute; top: 4px; right: 4px; }
}

/* ─── APP TOOLBAR ───────────────────────────────────────────── */
.km-toolbar {
  position: fixed;
  top: var(--km-nav-h); left: 0; right: 0;
  height: var(--km-toolbar-h);
  z-index: 9000;
  background: #0D1421;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}
.km-toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #F8FAFC;
}
.km-toolbar-title svg {
  width: 18px; height: 18px;
  color: var(--km-accent, #6366F1);
}
.km-toolbar-sep {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.08);
  margin: 0 4px;
  flex-shrink: 0;
}
.km-toolbar-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.km-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Toolbar-Buttons */
.km-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 100px;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.km-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}
.km-btn-primary {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.km-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}
.km-btn-outline {
  background: transparent;
  color: #94A3B8;
  border: 1px solid rgba(255,255,255,0.12);
}
.km-btn-outline:hover:not(:disabled) {
  color: #F8FAFC;
  background: rgba(255,255,255,0.05);
}
.km-btn-ghost {
  background: transparent;
  color: #94A3B8;
  padding: 6px 8px;
  border-radius: 8px;
}
.km-btn-ghost:hover:not(:disabled) {
  color: #F8FAFC;
  background: rgba(255,255,255,0.07);
}
.km-btn svg { width: 14px; height: 14px; }

/* ─── CANVAS WRAPPER ────────────────────────────────────────── */
.km-canvas-wrapper {
  position: fixed;
  top: var(--km-shell-top);
  left: 0; right: 0;
  bottom: 0;
  overflow: hidden;
  background-color: #070C16;
  background-image: radial-gradient(circle, var(--km-grid-dot) 1px, transparent 1px);
  background-size: var(--km-grid-size) var(--km-grid-size);
}

/* ─── ONBOARDING ────────────────────────────────────────────── */
.km-onboarding {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}
.km-onboarding-card {
  background: #141B2D;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 2.5rem 3rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}
.km-onboarding-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
  margin-bottom: 1.25rem;
}
.km-onboarding-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--km-accent, #6366F1);
  margin-bottom: 0.6rem;
}
.km-onboarding h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}
.km-onboarding p {
  color: #94A3B8;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0 0 1.75rem;
}
.km-onboarding-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.km-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 100px;
  padding: 10px 18px;
  color: #F8FAFC;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.km-input::placeholder { color: rgba(255,255,255,0.25); }
.km-input:focus { border-color: #6366F1; }

/* ─── EMPTY STATE (nach "Starten", noch kein Inhalt) ────────── */
.km-empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.45;
  gap: 12px;
}
.km-empty-hint svg { width: 48px; height: 48px; color: #475569; }
.km-empty-hint p { margin: 0; color: #475569; font-size: 0.85rem; font-weight: 500; }

/* ─── TOAST / NOTIFICATIONS ─────────────────────────────────── */
#km-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.km-toast {
  background: #1E293B;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #F8FAFC;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: km-toast-in 0.2s ease, km-toast-out 0.2s ease 2.6s forwards;
  pointer-events: auto;
}
@keyframes km-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes km-toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ─── SWOT-LAYOUT ───────────────────────────────────────────── */
.km-swot-wrapper {
  position: fixed;
  top: var(--km-shell-top);
  left: 0; right: 0; bottom: 0;
  overflow: auto;
  padding: 16px;
  background: #070C16;
}
.km-swot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.km-swot-title-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(255,255,255,0.08);
  padding: 6px 2px;
  color: #F8FAFC;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.km-swot-title-input:focus { border-bottom-color: #6366F1; }
.km-swot-title-input::placeholder { color: rgba(255,255,255,0.2); }

.km-swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: calc(100vh - var(--km-shell-top) - 80px);
}
.km-swot-quadrant {
  background: #141B2D;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 200px;
}
.km-swot-q-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.km-swot-q-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.km-swot-q-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}
.km-swot-q-abbr {
  font-size: 1.4rem;
  font-weight: 800;
  opacity: 0.15;
  line-height: 1;
}
.km-swot-q-body {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

/* SWOT-Karte */
.km-swot-card {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s;
}
.km-swot-card:hover { border-color: rgba(255,255,255,0.12); }
.km-swot-card.priority {
  border-left-width: 3px;
}
.km-swot-card-text {
  flex: 1;
  background: transparent;
  border: none;
  color: #F8FAFC;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  outline: none;
  resize: none;
  min-height: 20px;
  overflow: hidden;
  padding: 0;
}
.km-swot-card-text::placeholder { color: rgba(255,255,255,0.2); }
.km-swot-card-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.km-swot-card:hover .km-swot-card-actions,
.km-swot-card:focus-within .km-swot-card-actions { opacity: 1; }
.km-swot-card-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: #64748B;
  border-radius: 4px;
  line-height: 1;
  font-size: 0.75rem;
  transition: color 0.12s, background 0.12s;
}
.km-swot-card-btn:hover { color: #F8FAFC; background: rgba(255,255,255,0.08); }
.km-swot-card-btn.active { color: #F59E0B; }

.km-swot-add-btn {
  background: none;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px;
  color: #475569;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.km-swot-add-btn:hover {
  border-color: rgba(255,255,255,0.22);
  color: #94A3B8;
}

/* SWOT Quadrant-Farben */
.km-swot-quadrant[data-q="staerken"] .km-swot-q-dot     { background: var(--km-swot-s); }
.km-swot-quadrant[data-q="staerken"] .km-swot-q-label   { color: var(--km-swot-s); }
.km-swot-quadrant[data-q="staerken"] .km-swot-card.priority { border-left-color: var(--km-swot-s); }

.km-swot-quadrant[data-q="schwaechen"] .km-swot-q-dot   { background: var(--km-swot-w); }
.km-swot-quadrant[data-q="schwaechen"] .km-swot-q-label { color: var(--km-swot-w); }
.km-swot-quadrant[data-q="schwaechen"] .km-swot-card.priority { border-left-color: var(--km-swot-w); }

.km-swot-quadrant[data-q="chancen"] .km-swot-q-dot      { background: var(--km-swot-o); }
.km-swot-quadrant[data-q="chancen"] .km-swot-q-label    { color: var(--km-swot-o); }
.km-swot-quadrant[data-q="chancen"] .km-swot-card.priority { border-left-color: var(--km-swot-o); }

.km-swot-quadrant[data-q="risiken"] .km-swot-q-dot      { background: var(--km-swot-t); }
.km-swot-quadrant[data-q="risiken"] .km-swot-q-label    { color: var(--km-swot-t); }
.km-swot-quadrant[data-q="risiken"] .km-swot-card.priority { border-left-color: var(--km-swot-t); }

/* ─── MODAL ──────────────────────────────────────────────────── */
.km-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.km-modal {
  background: #141B2D;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}
.km-modal h3 { margin: 0 0 1rem; font-size: 1.15rem; font-weight: 700; }
.km-modal p  { color: #94A3B8; font-size: 0.875rem; margin: 0 0 1.5rem; line-height: 1.6; }
.km-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── SHORTCUT-OVERLAY ───────────────────────────────────────── */
#km-shortcut-overlay {
  position: fixed;
  bottom: 16px; right: 16px;
  background: #141B2D;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 14px 18px;
  z-index: 9500;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 0.78rem;
}
#km-shortcut-overlay h4 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}
.km-shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  color: #94A3B8;
}
.km-shortcut-row kbd {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #F8FAFC;
  white-space: nowrap;
}

/* ─── OpenDyslexic-Bubble (Phase 6) ────────────────────────────── */
.km-dyslexia-toggle {
  position: fixed;
  bottom: 1.5rem; right: 2rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--lmb-bg-surface, #141B2D);
  border: 2px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: bold; cursor: pointer;
  color: #94A3B8;
  font-family: 'OpenDyslexic', 'Outfit', sans-serif;
  z-index: 9998;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.km-dyslexia-toggle:hover {
  transform: translateY(-3px) scale(1.05);
  background: #6366F1; border-color: #6366F1; color: #fff;
  box-shadow: 0 8px 25px rgba(99,102,241,0.4);
}
.km-dyslexia-toggle.active {
  background: #6366F1; border-color: #6366F1; color: #fff;
  box-shadow: 0 0 20px rgba(99,102,241,0.4);
}
body.font-dyslexic,
body.font-dyslexic input,
body.font-dyslexic textarea,
body.font-dyslexic button { font-family: 'OpenDyslexic', sans-serif !important; }

/* ─── Kontextmenü ───────────────────────────────────────────────── */
#km-ctx-menu {
  background: #141B2D;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 4px;
  min-width: 190px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  font-family: 'Outfit', sans-serif;
  font-size: 0.83rem;
}
.km-ctx-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 7px 10px;
  border: none; border-radius: 6px;
  background: none; cursor: pointer;
  color: #F8FAFC;
  font-family: inherit; font-size: inherit;
  transition: background 0.1s;
}
.km-ctx-item:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
.km-ctx-item:disabled { opacity: 0.4; cursor: default; }
.km-ctx-item.danger { color: #EF4444; }
.km-ctx-item.danger:hover:not(:disabled) { background: rgba(239,68,68,0.1); }
.km-ctx-icon { font-size: 0.85em; opacity: 0.8; flex-shrink: 0; width: 16px; text-align: center; }
.km-ctx-label { flex: 1; }
.km-ctx-kbd {
  font-size: 0.7rem; color: #475569; font-family: monospace;
  background: rgba(255,255,255,0.07); border-radius: 3px;
  padding: 1px 5px; margin-left: 4px; flex-shrink: 0;
}
.km-ctx-sep {
  height: 1px; background: rgba(255,255,255,0.08);
  margin: 4px 6px;
}

/* ─── Shortcut-Hilfe Button ────────────────────────────────────── */
.km-btn-help {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: none; color: #475569;
  font-size: .85rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color .12s, border-color .12s;
  flex-shrink: 0;
}
.km-btn-help:hover { color: #F8FAFC; border-color: rgba(255,255,255,0.25); }

/* ─── Druck-CSS für Canvas-Apps ─────────────────────────────────── */
@media print {
  #km-mode-nav, .km-toolbar, .km-dyslexia-toggle { display: none !important; }
  body.km-page { overflow: auto !important; height: auto !important; }
  .km-canvas-wrapper {
    position: static !important; overflow: visible !important;
    height: auto !important; left: 0 !important;
  }
  #km-svg { min-height: 90vh; }
  .km-shape-palette { display: none !important; }
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .km-swot-grid { grid-template-columns: 1fr; grid-template-rows: unset; }
  .km-swot-wrapper { padding: 8px; }
  .km-onboarding-card { padding: 1.75rem 1.5rem; }
  .km-onboarding-input-row { flex-direction: column; }
  .km-toolbar { padding: 0 10px; gap: 6px; }
}
