[data-md-color-scheme="default"] {
  --md-primary-fg-color:        #009260;
  --md-primary-bg-color:        #eeeeee;
  --md-primary-bg-color-light:  #00ffff;
  --md-typeset-a-color:         #009260;
  --md-typeset-fg-color:        #009260;
  --md-accent-fg-color:         #009260;
  --md-accent-bg-color:         #eeeeee;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color:        #009260;
  /* m2 Teal 600 */
  --md-typeset-a-color:         #00897B;
  --md-typeset-fg-color:        #009260;
  --md-accent-fg-color:         #009260;

  img {
    filter: brightness(.66);
  }
}

.md-typeset h1 {
  font-size: 24px;
}

.md-typeset h2 {
  font-size: 20px;
}

.md-typeset h3 {
  font-size: 18px;
}

.md-typeset {
  font-size: 16px;
}

.md-typeset a:hover {
  text-decoration: underline;
}

.md.top:hover {
  color: var(--md-accent-fg-color);
}

.md-nav .md-nav__link:hover {
  color: var(--md-typeset-a-color);
}

.md-footer {
  background-color: var(--md-primary-fg-color-light);
  color: var(--md-typeset-color);
}

.md-footer__link {
  border: 1px solid #dedede;
  border-radius: 5px;
  margin-left: 10px;
  margin-right: 10px;
  padding-top: 5px;
  padding-bottom: 5px;
  transition: border-color .2s ease-in-out;
}

.md-footer__link:hover {
  border-color: var(--md-primary-fg-color);
}

main img {
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}

.md-typeset img {
  max-width: 95%;
  margin: 0 2.5%;
}

img.no-shadow {
  box-shadow: none;
  margin: 0;
  max-width: 100%;
}

/* ADMONITIONS */

.md-typeset .admonition,
.md-typeset details {
  font-size: 14px;
}

.md-typeset details.question {
  /* m2 Green 400 */
  border-color: #66BB6A;
}

.md-typeset .question > summary::before,
.md-typeset .question > summary::after {
  /* m2 Green 400 */
  background-color: #66BB6A;
}

/* PDF Download Button */
.pdf-download-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.pdf-download-btn {
  font-size: 0.75rem !important;
  padding: 0.4rem 0.8rem !important;
  cursor: pointer;
}

/* Print Styles */
@media print {
  /* Hide navigation, header, footer, and UI elements */
  .md-header,
  .md-tabs,
  .md-sidebar,
  .md-footer,
  .md-top,
  .md-search,
  .pdf-download-bar,
  .md-dialog,
  .md-banner,
  .headerlink,
  .md-source,
  .md-content__button,
  nav[aria-label="Seitenleiste"],
  nav[aria-label="Fußzeile"] {
    display: none !important;
  }

  /* Full width content */
  .md-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .md-main__inner {
    margin: 0 !important;
    padding: 0 !important;
  }

  .md-grid {
    max-width: 100% !important;
    margin: 0 !important;
  }

  /* Remove image shadows for print */
  main img {
    box-shadow: none !important;
  }

  /* Ensure images are visible (undo dark mode filter) */
  img {
    filter: none !important;
  }

  /* Page break control */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  table, figure, img {
    page-break-inside: avoid;
  }

  /* Clean typography */
  .md-typeset {
    font-size: 12pt;
    color: #000 !important;
  }

  .md-typeset a {
    color: #000 !important;
    text-decoration: underline;
  }

  /* Show link URLs after links */
  .md-typeset a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  /* Don't show URLs for internal/anchor links */
  .md-typeset a[href^="#"]::after,
  .md-typeset a[href^="/"]::after {
    content: none;
  }

  /* Background colors for admonitions */
  .md-typeset .admonition,
  .md-typeset details {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }

  body {
    background: white !important;
  }
}

/* ── Chatbot Widget ─────────────────────────────────────────── */
#hisqis-chat {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: var(--md-text-font-family, Roboto, sans-serif);
  font-size: 0.875rem;
  line-height: 1.5;
}

#hisqis-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #009260;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transition: background 0.15s;
}
#hisqis-toggle:hover { background: #007a4f; }

#hisqis-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: 64px;
  right: 0;
  width: 320px;
  height: 430px;
  background: var(--md-default-bg-color, #fff);
  border: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.16);
  overflow: hidden;
}
#hisqis-panel.hisqis-open { display: flex; }

#hisqis-header {
  background: #009260;
  color: #fff;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  font-size: 0.9rem;
  flex-shrink: 0;
}
#hisqis-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  opacity: 0.85;
}
#hisqis-close:hover { opacity: 1; }

#hisqis-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hisqis-msg {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  max-width: 90%;
  word-break: break-word;
}
.hisqis-bot {
  background: var(--md-code-bg-color, #f4f4f4);
  color: var(--md-default-fg-color, #333);
  align-self: flex-start;
}
.hisqis-bot a {
  color: #009260;
  text-decoration: underline;
}
.hisqis-user {
  background: #009260;
  color: #fff;
  align-self: flex-end;
}
.hisqis-loading {
  opacity: 0.55;
  animation: hisqis-pulse 1.2s ease-in-out infinite;
}
@keyframes hisqis-pulse {
  0%, 100% { opacity: 0.55; }
  50%       { opacity: 0.2;  }
}

#hisqis-input-row {
  display: flex;
  padding: 0.5rem;
  gap: 0.4rem;
  border-top: 1px solid var(--md-default-fg-color--lightest, #e0e0e0);
  flex-shrink: 0;
}
#hisqis-input {
  flex: 1;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--md-default-fg-color--lighter, #ccc);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--md-default-bg-color, #fff);
  color: var(--md-default-fg-color, #333);
  outline: none;
}
#hisqis-input:focus { border-color: #009260; }
#hisqis-send {
  padding: 0.4rem 0.65rem;
  background: #009260;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#hisqis-send:hover { background: #007a4f; }
#hisqis-send:disabled { opacity: 0.45; cursor: default; }

@media print {
  #hisqis-chat { display: none !important; }
}

/* ── Kostenstellenstruktur Diagramm ──────────────────────────── */
.kost-diagram { margin: 1.5rem 0; font-size: 0.9rem; }

.kost-top-layout { display: flex; gap: 1.25rem; align-items: stretch; }
.kost-flow { flex: 1; display: flex; flex-direction: column; }

.kost-level-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--md-code-bg-color);
  border-left: 3px solid #009260;
  border-radius: 0 6px 6px 0;
  align-items: center;
}
.kost-level-name { font-weight: 600; line-height: 1.3; }
.kost-level-name em { font-weight: 400; font-style: normal; color: var(--md-default-fg-color--light); }
.kost-level-size {
  display: block; font-weight: 400; font-size: 0.78rem;
  color: var(--md-default-fg-color--light); font-style: italic; margin-top: 0.1rem;
}
.kost-level-content { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; align-items: center; }
.kost-item { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.35rem; }

.kost-connector {
  color: #009260; font-size: 1.25rem; line-height: 1.8;
  padding-left: calc(200px / 2 + 0.9rem - 0.35rem);
}
.kost-connector--branch { padding-left: 0.9rem; font-size: 0.9rem; color: var(--md-default-fg-color--light); }

.kost-badge {
  display: inline-block; padding: 0.1rem 0.45rem;
  border: 1px solid #009260; border-radius: 4px;
  font-family: var(--md-code-font-family); font-size: 0.82rem; background: transparent;
}

.kost-note {
  flex: 0 0 190px; border: 2px solid #009260; border-radius: 8px;
  padding: 0.7rem 0.9rem; font-size: 0.83rem; font-weight: 500;
  text-align: center; line-height: 1.5;
  display: flex; flex-direction: column; justify-content: center;
}
.kost-note strong { color: var(--md-default-fg-color); margin-top: 0.3rem; }

.kost-branch-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.kost-branch-table th,
.kost-branch-table td {
  padding: 0.5rem 0.6rem; text-align: center; vertical-align: middle;
  border: 1px solid var(--md-default-fg-color--lightest);
}
.kost-branch-table th {
  text-align: left; font-weight: 600; background: var(--md-code-bg-color);
  border-left: 3px solid #009260; width: 200px; vertical-align: top; padding-top: 0.6rem;
}
.kost-branch-table th small {
  display: block; font-weight: 400; font-size: 0.74rem;
  color: var(--md-default-fg-color--light); font-style: italic; margin-top: 0.2rem;
}
.kost-branch-table th em { font-style: normal; color: var(--md-default-fg-color--light); font-weight: 400; }
.kost-arrow-row td { border-top: none; border-bottom: none; padding: 0.1rem; color: #009260; font-size: 1.1rem; }
.kost-arrow-row th { border-top: none; border-bottom: none; background: transparent; }
.kost-diagram code { font-size: 0.82rem; background: transparent; padding: 0; }

@media (max-width: 600px) {
  .kost-top-layout { flex-direction: column; }
  .kost-note { flex: none; }
  .kost-level-row { grid-template-columns: 130px 1fr; }
  .kost-connector { padding-left: calc(130px / 2 + 0.9rem - 0.35rem); }
  .kost-branch-table th { width: 130px; font-size: 0.78rem; }
  .kost-branch-table td { font-size: 0.78rem; padding: 0.4rem 0.3rem; }
}

@media print {
  .kost-level-row, .kost-branch-table th { border-left-color: #009260 !important; background: #f5f5f5 !important; }
  .kost-note { border-color: #009260 !important; }
}
