/* Merten APPS — App-Switcher v5 (Phase 2 "Mutig", 14.10.2026) – Basis v4, Ergänzungen am Ende.
   Rollback: Module wieder auf app-switcher.v4.css zeigen lassen.
   v4: Mockup-Redesign 07.08.2026.
   Chip-basierter Look mit grünem M-Logo-Square + zweizeiligem Textblock. */

.mws-switcher-wrap {
  position: fixed;
  top: 10px; left: 12px;
  z-index: 10500;   /* über Modul-Header/Chip-Bar (10000) und Account-Slot (10001) */
  font-family: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* Der Chip selbst */
.mws-brand {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--mws-brand-bg, rgba(255,255,255,0.94));
  backdrop-filter: blur(10px);
  border: 1px solid var(--mws-brand-border, rgba(15,15,10,0.10));
  border-radius: 12px;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.05);
  color: var(--mws-brand-text, #1b1f17);
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  font-family: inherit;
}
.mws-brand:hover {
  background: var(--mws-brand-bg-hover, #f5f6f2);
  border-color: var(--mws-brand-border-hover, rgba(15,15,10,0.18));
  box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 6px 16px rgba(0,0,0,0.08);
}
.mws-brand:focus-visible {
  outline: 2px solid #6EB221; outline-offset: 2px;
}

/* v4.2: Offizielles PWA-App-Icon (`/icons/icon-192.png`) im Chip — buntes M&M-Icon */
.mws-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  flex: 0 0 auto;
  object-fit: cover;
  display: block;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  user-select: none;
  -webkit-user-drag: none;
}

/* Textblock: Titel + Untertitel */
.mws-brand-text {
  min-width: 0;
  text-align: left;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mws-brand-text h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: inherit;
  letter-spacing: -0.01em;
}
.mws-brand-text p {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--mws-brand-muted, #7a7974);
}

/* Chevron rechts */
.mws-chevron {
  color: var(--mws-brand-muted, #7a7974);
  flex: 0 0 auto;
  transition: transform 200ms ease;
  margin-left: 2px;
}
.mws-brand[aria-expanded="true"] .mws-chevron { transform: rotate(180deg); }

/* Dark-Mode via data-theme (Live-Kalender) UND .dark-Klasse (Legacy-Module) */
html[data-theme="dark"] .mws-switcher-wrap,
.dark .mws-switcher-wrap {
  --mws-brand-bg: rgba(28, 27, 21, 0.94);
  --mws-brand-bg-hover: rgba(38, 37, 31, 1);
  --mws-brand-border: rgba(255, 255, 255, 0.10);
  --mws-brand-border-hover: rgba(255, 255, 255, 0.18);
  --mws-brand-text: #E8E6DC;
  --mws-brand-muted: #8A897E;
}

/* Dropdown-Menu */
.mws-menu {
  position: absolute;
  top: calc(100% + 8px); left: 0;
  min-width: 380px; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--mws-menu-bg, #ffffff);
  border: 1px solid var(--mws-menu-border, rgba(0,0,0,0.08));
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08), 0 12px 32px rgba(0,0,0,0.06);
  padding: 8px;
}
html[data-theme="dark"] .mws-menu,
.dark .mws-menu {
  --mws-menu-bg: #1C1B15;
  --mws-menu-border: rgba(255, 255, 255, 0.10);
}
.mws-menu[hidden] { display: none; }

@media (max-width: 600px) {
  .mws-menu {
    max-height: calc(100dvh - 80px);
  }
}

/* Section-Header („MODUL WECHSELN") */
.mws-section {
  padding: 6px 10px;
  font-size: 10.5px;
  color: var(--mws-menu-muted, #7a7974);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
html[data-theme="dark"] .mws-section,
.dark .mws-section { color: #8A897E; }

/* Item */
.mws-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--mws-item-text, #1b1f17);
  transition: background-color 120ms ease;
  min-height: 56px;
}
html[data-theme="dark"] .mws-item,
.dark .mws-item { color: #E8E6DC; }

.mws-item:hover { background: rgba(0,0,0,0.04); }
html[data-theme="dark"] .mws-item:hover,
.dark .mws-item:hover { background: rgba(255,255,255,0.04); }

.mws-item:focus-visible { outline: 2px solid #6EB221; outline-offset: -2px; }
.mws-item.is-active { background: rgba(110, 178, 33, 0.10); }

.mws-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex: 0 0 auto;
  background: rgba(110, 178, 33, 0.14); color: #558818;
}
.mws-icon svg { width: 20px; height: 20px; }
.mws-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mws-title { font-size: 14.5px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.mws-desc  {
  font-size: 12px;
  font-weight: 500;
  color: var(--mws-menu-muted, #7a7974);
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
html[data-theme="dark"] .mws-desc,
.dark .mws-desc { color: #8A897E; }
.mws-check { color: #6EB221; font-weight: 700; font-size: 16px; min-width: 16px; text-align: right; }

@media (max-width: 767px) {
  /* v4.7: Chip ist fixed mit hohem z-index; Modul-Topbars/Header müssen padding-top: 56px haben */
  .mws-switcher-wrap {
    top: 8px; left: 8px; right: auto;
    pointer-events: none;
  }
  .mws-switcher-wrap > * { pointer-events: auto; }
  .mws-menu {
    min-width: 0;
    max-width: calc(100vw - 16px);
    left: 0;
  }
  /* v4.4 (07.08.2026): Auf Mobile Icon + Modulname zeigen (statt nur Icon).
     Der Chip fungiert als klarer „Wo bin ich?“-Anzeiger, der eigene Modul-Titel wird
     dadurch überflüssig (und ist über Media-Query in Modulen ausgeblendet). */
  .mws-brand {
    padding: 4px 10px 4px 4px !important;
    min-height: 40px;
    border-radius: 10px;
    gap: 8px;
    max-width: calc(100vw - 190px); /* Platz für Account-Menu + evtl. weitere Buttons rechts */
  }
  /* Untertitel weg, aber Titel zeigen */
  .mws-brand-text { display: block !important; min-width: 0; overflow: hidden; }
  .mws-brand-text p { display: none !important; }
  .mws-brand-text h1 {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 !important;
  }
  /* v4.8 (08.08.2026): Chevron auf Mobile wieder zeigen — signalisiert, dass der Chip öffnet */
  .mws-chevron { display: inline-flex !important; font-size: 12px; opacity: 0.7; margin-left: 2px; flex-shrink: 0; }
  .mws-logo { width: 32px; height: 32px; border-radius: 7px; }
}

/* Kategorie-Header (v3.2 klappbar) */
.mws-cat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 6px;
  margin-top: 4px;
  width: 100%;
  background: none; border: none;
  cursor: pointer; text-align: left;
  border-radius: 8px;
  font-family: inherit;
  transition: background-color 120ms ease;
}
.mws-cat-header:first-of-type { margin-top: 0; }
.mws-cat-header:hover { background: rgba(0,0,0,0.03); }
html[data-theme="dark"] .mws-cat-header:hover,
.dark .mws-cat-header:hover { background: rgba(255,255,255,0.04); }
.mws-cat-header:focus-visible { outline: 2px solid #6EB221; outline-offset: -2px; }

.mws-cat-icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.mws-cat-icon svg { width: 14px; height: 14px; stroke-width: 2.5; }
.mws-cat-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #7a7974;
  flex: 1 1 auto;
}
html[data-theme="dark"] .mws-cat-label,
.dark .mws-cat-label { color: #8A897E; }

.mws-cat-count {
  font-size: 11px; font-weight: 600; color: #8A897E;
  padding: 2px 8px; background: rgba(0,0,0,0.05); border-radius: 999px;
  flex: 0 0 auto;
}
html[data-theme="dark"] .mws-cat-count,
.dark .mws-cat-count { background: rgba(255,255,255,0.06); color: #8A897E; }

.mws-cat-chevron {
  color: #8A897E; flex: 0 0 auto;
  transition: transform 200ms ease;
}
.mws-cat-header.is-collapsed .mws-cat-chevron { transform: rotate(-90deg); }

.mws-cat-group {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 240ms ease, opacity 200ms ease;
}
.mws-cat-group.is-collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .mws-brand, .mws-chevron, .mws-cat-chevron, .mws-cat-group { transition: none; }
}



/* (extern-Variante: globale Modul-Topbar-Anpassungen aus v4.7 bewusst entfernt) */

/* Native iOS-App (12.08.2026): Chip unter die Statusleiste rücken.
   Die Bridge (merten-native.v1.js) setzt html.mk-native-ios; der fixe Chip
   bei top 8-10px würde sonst vom Statusleisten-Scrim übermalt. */
html.mk-native-ios .mws-switcher-wrap { top: calc(env(safe-area-inset-top) + 10px); }
@media (max-width: 767px) {
  html.mk-native-ios .mws-switcher-wrap { top: calc(env(safe-area-inset-top) + 8px); }
}


/* ===================== v5 · Phase 2 „Mutig“ ===================== */
.mws-switcher-wrap { --mws5-g: #6EB221; --mws5-gd: #2E7B12; --mws5-gl: #E8F4D8; --mws5-o: #F07A16; }

/* Chip: CD-Akzent */
.mws-brand { border-radius: 14px; }
.mws-brand:hover { border-color: rgba(110,178,33,.55); box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 8px 20px rgba(46,123,18,.14); }
.mws-brand[aria-expanded="true"] { border-color: var(--mws5-g); box-shadow: 0 0 0 3px rgba(110,178,33,.22); }
.mws-brand-text h1 { font-weight: 800; }

/* Panel (Desktop: Dropdown) */
.mws-menu {
  min-width: 420px; width: 440px;
  border-radius: 20px;
  padding: 0 10px 12px;
  border: 1px solid var(--mws-menu-border, rgba(0,0,0,.08));
  box-shadow: 0 24px 60px -12px rgba(20,40,10,.35), 0 4px 14px rgba(0,0,0,.08);
  animation: mws5-in 180ms cubic-bezier(.2,.8,.2,1);
  transform-origin: top left;
}
@keyframes mws5-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

.mws5-grab { display: none; }
.mws5-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; align-items: center;
  padding: 12px 2px 10px;
  background: var(--mws-menu-bg, #fff);
}
.mws5-search {
  flex: 1 1 auto; display: flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 12px;
  border: 1.5px solid rgba(0,0,0,.10); border-radius: 14px;
  background: rgba(110,178,33,.06); color: #6b6f66;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.mws5-search:focus-within { border-color: var(--mws5-g); box-shadow: 0 0 0 3px rgba(110,178,33,.20); }
.mws5-search input {
  flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; font-weight: 600; color: var(--mws-item-text, #1b1f17);
}
.mws5-search input::-webkit-search-cancel-button { display: none; }
.mws5-kbd {
  font: 700 11px/1 inherit; color: #7a7974;
  border: 1px solid rgba(0,0,0,.14); border-bottom-width: 2px;
  border-radius: 6px; padding: 4px 6px; white-space: nowrap;
}
.mws5-close {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
  border: 0; background: rgba(0,0,0,.05); color: inherit; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.mws5-close:focus-visible, .mws5-rc:focus-visible { outline: 2px solid var(--mws5-g); outline-offset: 2px; }

/* Zuletzt genutzt */
.mws5-recent-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 6px 8px; }
.mws5-rc {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 14px 4px 4px;
  border: 1px solid rgba(0,0,0,.08); border-radius: 999px;
  text-decoration: none; color: var(--mws-item-text, #1b1f17);
  font-size: 13.5px; font-weight: 700; background: var(--mws-menu-bg, #fff);
  transition: border-color 120ms ease, transform 120ms ease, background-color 120ms ease;
}
.mws5-rc:hover { border-color: rgba(110,178,33,.6); background: rgba(110,178,33,.06); transform: translateY(-1px); }
.mws5-rc-ic { width: 34px; height: 34px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.mws5-rc-ic svg { width: 17px; height: 17px; }

/* Abschnittsköpfe + Einträge */
.mws-section { padding: 10px 10px 6px; color: var(--mws5-gd); }
.mws-item { border-radius: 14px; min-height: 58px; transition: background-color 120ms ease, transform 120ms ease; }
.mws-item:hover { background: rgba(110,178,33,.08); }
.mws-item:focus-visible { outline: 2px solid var(--mws5-g); outline-offset: -2px; background: rgba(110,178,33,.08); }
.mws-item.is-active { background: var(--mws5-gl); box-shadow: inset 3px 0 0 var(--mws5-g); }
.mws-icon { border-radius: 12px; }
.mws-desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mws-check { color: var(--mws5-gd); }
.mws-cat-header { min-height: 44px; }
.mws-cat-label { color: var(--mws5-gd); }

/* Suche aktiv: Kategorien aufklappen, Köpfe ausblenden */
.mws-menu.mws5-suche .mws-cat-header,
.mws-menu.mws5-suche .mws5-all { display: none; }
.mws-menu.mws5-suche .mws-cat-group.is-collapsed { max-height: none; opacity: 1; pointer-events: auto; }
.mws5-empty { padding: 26px 12px; text-align: center; color: #7a7974; font-weight: 600; }
.mws5-empty[hidden] { display: none; }

/* Abdunklung */
.mws5-scrim { position: fixed; inset: 0; background: rgba(15,30,8,.18); z-index: -1; animation: mws5-fade 160ms ease; }
.mws5-scrim[hidden] { display: none; }
@keyframes mws5-fade { from { opacity: 0; } to { opacity: 1; } }

/* Dunkelmodus */
html[data-theme="dark"] .mws-switcher-wrap, .dark .mws-switcher-wrap { --mws5-gd: #9BD25C; --mws5-gl: rgba(110,178,33,.18); }
html[data-theme="dark"] .mws5-search, .dark .mws5-search { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: #a9a89e; }
html[data-theme="dark"] .mws5-search input, .dark .mws5-search input,
html[data-theme="dark"] .mws5-rc, .dark .mws5-rc { color: #E8E6DC; }
html[data-theme="dark"] .mws5-rc, .dark .mws5-rc { border-color: rgba(255,255,255,.10); }
html[data-theme="dark"] .mws5-kbd, .dark .mws5-kbd { color: #a9a89e; border-color: rgba(255,255,255,.18); }
html[data-theme="dark"] .mws5-close, .dark .mws5-close { background: rgba(255,255,255,.07); }
html[data-theme="dark"] .mws5-scrim, .dark .mws5-scrim { background: rgba(0,0,0,.45); }
html[data-theme="dark"] .mws-item.is-active, .dark .mws-item.is-active { color: #E8E6DC; }

/* Handy: Blatt von unten */
@media (max-width: 767px) {
  html.mws5-lock, html.mws5-lock body { overflow: hidden !important; }
  .mws-switcher-wrap.mws5-offen { z-index: 10600; }
  .mws-switcher-wrap .mws5-scrim { pointer-events: auto; background: rgba(15,30,8,.40); }
  .mws-switcher-wrap .mws-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; min-width: 0; max-width: none;
    max-height: 88dvh !important;
    border-radius: 24px 24px 0 0; border-bottom: 0;
    padding: 0 12px calc(16px + env(safe-area-inset-bottom));
    animation: mws5-up 240ms cubic-bezier(.2,.8,.2,1);
    transition: transform 120ms ease;
  }
  @keyframes mws5-up { from { transform: translateY(100%); } to { transform: none; } }
  .mws5-grab { display: block; position: sticky; top: 0; z-index: 3; height: 18px; background: var(--mws-menu-bg, #fff); }
  .mws5-grab::after { content: ""; position: absolute; left: 50%; top: 8px; width: 44px; height: 5px; margin-left: -22px; border-radius: 99px; background: rgba(0,0,0,.18); }
  html[data-theme="dark"] .mws5-grab::after, .dark .mws5-grab::after { background: rgba(255,255,255,.22); }
  .mws5-head { top: 18px; padding-top: 4px; }
  .mws5-kbd { display: none; }
  .mws5-close { display: inline-flex; }
  .mws5-rc { font-size: 14px; }
  .mws-item { min-height: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  .mws-menu, .mws5-scrim, .mws5-rc, .mws-item { animation: none !important; transition: none !important; }
}

/* v5 extern (Startseite, Admin Center, Protokoll): eigener Knopf der Seite, kein Chip */
.mws-switcher-wrap.mws5-extern { top: 0; left: 0; width: 0; height: 0; }
.mws-switcher-wrap.mws5-extern > .mws-brand { display: none !important; }
