/* ==========================================================================
   JuBase — Fachanwendung im Frontend

   Ergaenzt jubase-admin.css. Dort stehen Farben, Schriften und alle
   Bausteine; hier nur, was es im Backend nicht gibt: die Seitenleiste,
   der Inhaltsrahmen und die Anmeldung.

   Die Seitenleiste ist die aus dem Oberflaechenentwurf. Genau deshalb gibt
   es dieses Frontend: im wp-admin war sie nicht unterzubringen.
   ========================================================================== */

html, body.jubase-app {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body.jubase-app {
  background: var(--paper);
  display: flex;
  min-height: 100vh;
}

/* Die Korrektur fuer die wp-admin-Umgebung gilt hier nicht. */
body.jubase-app { margin-left: 0; }
body.jubase-app .jubase { margin: 0; min-height: 0; background: transparent; }
body.jubase-app .jubase::before { display: none; }

/* --------------------------------------------------------- Seitenleiste */

.jubase-side {
  width: 244px;
  flex: 0 0 244px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.jubase-side__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--line-2);
  text-decoration: none;
}

.jubase-side__mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
}
.jubase-side__mark svg{ display: block; }

.jubase-side__name {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}

.jubase-side__nav {
  padding: 12px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.jubase-side__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}

.jubase-side__item:hover { background: var(--paper-2); color: var(--ink); }

.jubase-side__item.is-active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}

.jubase-side__item .jubase-ic { width: 17px; height: 17px; flex: 0 0 17px; opacity: .78; }
.jubase-side__item.is-active .jubase-ic { opacity: 1; }

.jubase-side__foot {
  border-top: 1px solid var(--line-2);
  padding: 14px 16px 16px;
}

.jubase-side__user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.jubase-side__uname {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rueckweg ins WordPress-Backend. Nur fuer die technische Verwaltung
   sichtbar - bewusst zurueckhaltend, es ist kein Fachbereich. */
.jubase-side__backend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.jubase-side__backend:hover {
  background: var(--paper-2);
  border-color: var(--faint);
  color: var(--ink);
}
.jubase-side__backend .jubase-ic { width: 15px; height: 15px; flex: 0 0 15px; opacity: .7; }

/* Laufende Fassung. Bewusst unauffaellig - sie soll ablesbar sein, wenn
   jemand danach sucht, und sonst nicht stoeren. */
.jubase-side__version {
  margin-top: 8px;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: .02em;
}

.jubase-side__logout {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}
.jubase-side__logout:hover { color: var(--rose); text-decoration: underline; }

/* ------------------------------------------------------------- Inhalt */

.jubase-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  position: relative;
}

/* Feine Papierkoernung wie im Entwurf — Waerme ohne Ablenkung. */
.jubase-main::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.jubase-main > * { position: relative; z-index: 1; }
.jubase-main--bare { padding: 0 24px; }

/* --------------------------------------------------------- Anmeldung */

body.jubase-app--login {
  display: block;
  background: var(--paper);
}

.jubase-login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.jubase-login__box {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 32px 30px 26px;
}

.jubase-login__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.jubase-login__org {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 22px !important;
}

.jubase-login__label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 14px 0 5px;
}

.jubase-login .jubase-input { width: 100%; }

.jubase-login__remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 20px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

.jubase-login__submit {
  width: 100%;
  justify-content: center;
}

.jubase-login__hint {
  margin-top: 18px !important;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
}

.jubase-login__legal {
  margin-top: 22px !important;
  max-width: 372px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--faint);
}

/* ----------------------------------------------------------- Schmal */

@media (max-width: 860px) {
  body.jubase-app { display: block; }

  .jubase-side {
    width: auto;
    height: auto;
    position: static;
    flex: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .jubase-side__nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px;
  }

  .jubase-side__item { white-space: nowrap; }
  .jubase-side__item span { display: none; }
  .jubase-side__item.is-active span { display: inline; }

  .jubase-side__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
  }

  .jubase-side__user { margin-bottom: 0; }

  /* In der Zeile darf der Rueckweg keinen Abstand nach unten ziehen; die
     Beschriftung entfaellt, das Symbol genuegt. */
  .jubase-side__backend { margin-bottom: 0; padding: 6px 8px; }
  .jubase-side__backend span { display: none; }
  .jubase-side__version { margin-top: 0; }
}

/* Gruppenueberschriften der Seitenleiste - zugleich Schalter zum Einklappen */
.jubase-side__gruppe{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 16px 11px 6px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.jubase-side__gruppe:hover{ color: var(--ink-2); }

.jubase-side__pfeil{
  width: 13px; height: 13px; flex: 0 0 13px;
  opacity: .6;
  transition: transform .15s ease;
}
.jubase-side__block:not(.is-open) .jubase-side__pfeil{ transform: rotate(-90deg); }
.jubase-side__block:not(.is-open) .jubase-side__items{ display: none; }

/* Zaehler. Nur dort, wo die Zahl eine Handlung nahelegt. */
.jubase-side__zahl{
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
}
.jubase-side__item.is-active .jubase-side__zahl{
  background: var(--primary-100);
  color: var(--primary-700);
}

@media (max-width: 860px){
  .jubase-side__gruppe{display:none}
  .jubase-side__zahl{display:none}

  /* In der waagerechten Leiste gibt es keine Gruppen und keine Schalter.
     Die Umhuellungen muessen deshalb durchsichtig werden (display:contents),
     damit die Eintraege selbst im Flex-Fluss der Leiste landen - und sie
     muessen IMMER sichtbar sein, auch wenn die Gruppe am grossen Bildschirm
     eingeklappt war. Sonst waeren einzelne Seiten auf dem Telefon
     unerreichbar, ohne dass man den Grund saehe. */
  .jubase-side__block,
  .jubase-side__block .jubase-side__items{ display: contents !important; }
}

/* ------------------------------------------------------- Kopfzeile */
.jubase-top{
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 15px 26px 13px;
  border-bottom: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.jubase-top__datum{
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -.005em;
}
.jubase-top__ort{
  margin-left: auto;
  font-size: 12px;
  color: var(--faint);
  letter-spacing: .02em;
}

/* Inhalt beginnt unter der Kopfzeile ohne doppelten Abstand. */
.jubase-app .jubase-shell{ padding-top: 22px; }

/* ------------------------------------------- Einblendung beim Laden

   Eine Bewegung, nicht fünf. Die Seitenleiste steht sofort, der Inhalt
   kommt eine Spur später — das liest sich als "geladen", nicht als
   Animation. Wer Bewegung abgestellt hat, bekommt keine.               */
@media (prefers-reduced-motion: no-preference){
  .jubase-main > .jubase{
    animation: jubase-auf .34s cubic-bezier(.22,.61,.36,1) both;
    animation-delay: .04s;
  }
  @keyframes jubase-auf{
    from{ opacity:0; transform: translateY(7px); }
    to  { opacity:1; transform: none; }
  }
}

/* --------------------------------------------------- Tastaturfuehrung

   Im Dienst wird viel getippt und wenig gezielt geklickt. Ein sichtbarer
   Fokus ist hier kein Zugestaendnis an die Barrierefreiheit, sondern
   Arbeitsgeraet. :focus-visible, damit die Maus keine Ringe hinterlaesst. */
.jubase-app a:focus-visible,
.jubase-app button:focus-visible,
.jubase-app input:focus-visible,
.jubase-app select:focus-visible,
.jubase-app textarea:focus-visible,
.jubase-app summary:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.jubase-side__item:focus-visible{ background: var(--paper-2); }

/* Sprungmarke: mit der Tastatur direkt in den Inhalt. */
.jubase-skip{
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 0 0 var(--r-sm) 0;
  font-size: 13px;
  font-weight: 600;
}
.jubase-skip:focus{ left: 0; color: #fff; }

@media (max-width: 860px){
  .jubase-top{ padding: 11px 16px; position: static; }
  .jubase-top__ort{ display: none; }
}

/* Drucken aus der Fachanwendung (z.B. Notfallblatt): nur der Inhalt, keine
   Navigation. Die einzelne Seite blendet ihre eigenen Bedienelemente
   zusaetzlich selbst aus (siehe .jubase-notfall-druck__ausblenden). */
@media print{
  .jubase-side,
  .jubase-top,
  .jubase-skip,
  .jubase-toc-fab{ display: none !important; }
  body.jubase-app{ display: block; }
  .jubase-main{ padding: 0; }
}
