/* CaveRenderPro Documentation Stylesheet */

:root {
  --primary-color: #b045f9;
  --secondary-color: #c060ff;
  --accent-color: #f0b0ff;
  --text-dark: #000000;
  --text-light: #333333;
  --bg-light: #ececf0;
  --bg-white: #ffffff;
  --border-color: #b045f9;
}

html.dark-mode {
  --primary-color: #b045f9;
  --secondary-color: #c060ff;
  --accent-color: #9333ea;
  --text-dark: #ffffff;
  --text-light: #e0e0e0;
  --bg-light: #3a3a3a;
  --bg-white: #2e2e2e;
  --border-color: #b045f9;
}

html.dark-mode body {
  background-color: #2e2e2e;
}

html.dark-mode header {
  background: linear-gradient(to bottom, #666666, #444444);
  color: #ffffff;
}

html.dark-mode .nav a,
html.dark-mode .nav a:visited,
html.dark-mode .nav button {
  color: var(--secondary-color) !important;
}

html.dark-mode .sidebar {
  background-color: #333333;
  border-color: #555555;
}

html.dark-mode .sidebar a,
html.dark-mode .sidebar a:visited {
  color: #ffffff;
}

html.dark-mode .sidebar a:hover,
html.dark-mode .sidebar a.active {
  color: var(--secondary-color);
  background-color: #444444;
}

html.dark-mode .content {
  background-color: #2e2e2e;
  border-color: #555555;
}

html.dark-mode .sidebar h3 {
  border-bottom-color: #555555;
}

html.dark-mode .content h1 {
  border-bottom-color: #555555;
}

html.dark-mode .details-box {
  border-color: #555555;
}

html.dark-mode .info-box,
html.dark-mode .warning-box,
html.dark-mode .success-box {
  border-color: #555555;
}

html.dark-mode table {
  border-color: #555555;
}

html.dark-mode table th,
html.dark-mode table td {
  border-bottom-color: #555555;
}

html.dark-mode pre {
  border-color: #555555;
}

html.dark-mode table th {
  background-color: #444444;
  color: #f3f4f6;
}

html.dark-mode table tr:hover {
  background-color: #444444;
}

html.dark-mode footer {
  background: linear-gradient(to bottom, #666666, #444444);
  color: #ffffff;
}

html.dark-mode footer a,
html.dark-mode footer a:visited {
  color: var(--secondary-color);
}

html.dark-mode footer a:hover {
  color: var(--primary-color);
}

html.dark-mode .info-box {
  background-color: #3d2b4d;
}

html.dark-mode .warning-box {
  background-color: #4a3826;
}

html.dark-mode .success-box {
  background-color: #2c3f31;
}

html.dark-mode a {
  color: #c060ff;
}

html.dark-mode a:visited {
  color: #c084fc;
}

html.dark-mode .quick-link-info {
  background-color: #24457f;
}

html.dark-mode .quick-link-success {
  background-color: #1d4630;
}

html.dark-mode .quick-link-warning {
  background-color: #6b2c0a;
}

html.dark-mode .btn.btn-gray {
  background-color: #4b5563;
}

html.dark-mode .btn.btn-gray:hover {
  background-color: #2d3748;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-dark);
  line-height: 1.6;
  background-color: var(--bg-light);
}

/* Header & Navigation */
header {
  background: linear-gradient(to bottom, #f0f0f2, #dcdce2);
  color: #1f2937;
  padding: 0.5rem 0;
  position: sticky;
  top: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
  color: white;
  /* Logo nicht schrumpfen lassen, sonst ueberlappt es die Menuetexte */
  flex-shrink: 0;
}

.nav {
  display: flex;
  gap: 1rem;
  list-style: none;
  align-items: center;
  /* Nicht umbrechen: bei wenig Platz gibt das Suchfeld nach (.nav-search),
     erst unter 1080px wird das Menue bewusst zweizeilig */
  flex-wrap: nowrap;
  /* Den Platz neben dem Logo ganz nutzen, sonst bricht der letzte
     Menuepunkt um, obwohl rechts noch Platz frei ist */
  flex: 1 1 auto;
  justify-content: flex-end;
}

.nav a,
.nav a:visited,
.nav button {
  color: var(--secondary-color) !important;
  text-decoration: underline;
  font-size: 0.95rem;
  transition: color 0.3s;
  font-family: inherit;
}

.nav a:hover,
.nav button:hover,
html.dark-mode .nav a:hover,
html.dark-mode .nav button:hover {
  color: var(--primary-color) !important;
}

/* Main Content */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

main {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 3rem;
  margin: 3rem auto;
  min-height: 70vh;
}

/* Sidebar Navigation */
.sidebar {
  background-color: var(--bg-white);
  padding: 1.5rem;
  border-radius: 8px;
  height: fit-content;
  border: 1px solid #c8c8d0;
}

.sidebar h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  border-bottom: 2px solid #6b7280;
  padding-bottom: 0.5rem;
}

.sidebar ul {
  list-style: none;
}

.sidebar li {
  margin: 0.5rem 0;
}

.sidebar a {
  color: var(--text-dark);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid transparent;
  display: block;
  transition: all 0.3s;
}

.sidebar a:hover,
.sidebar a.active {
  color: var(--secondary-color);
  border-left-color: var(--accent-color);
  background-color: var(--bg-light);
}

/* Content Area */
.content {
  background-color: var(--bg-white);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid #c8c8d0;
  overflow-x: auto;
}

.content h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  border-bottom: 3px solid #6b7280;
  padding-bottom: 1rem;
}

.content h2 {
  font-size: 1.8rem;
  color: var(--primary-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
  scroll-margin-top: 100px;
}

.content h3 {
  font-size: 1.3rem;
  color: var(--primary-color);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 100px;
}

.content h4 {
  font-size: 1.1rem;
  color: var(--primary-color);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 100px;
}

.content p {
  margin-bottom: 1rem;
  color: var(--text-light);
  line-height: 1.8;
}

.content a,
.content a:visited,
html.dark-mode .content a,
html.dark-mode .content a:visited {
  color: var(--secondary-color);
  text-decoration: underline;
  transition: color 0.3s;
}

.content a:hover,
html.dark-mode .content a:hover {
  color: var(--primary-color);
}

.content ul, .content ol {
  margin: 1rem 0 1rem 2rem;
  color: var(--text-light);
}

.content li {
  margin-bottom: 0.5rem;
}

/* Highlight Boxes */
.info-box {
  background-color: #d1e7fd;
  border-left: 4px solid #6b7280;
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: 4px;
}

.info-box strong {
  color: var(--primary-color);
}

.warning-box {
  background-color: #fff3cd;
  border-left: 4px solid #6b7280;
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: 4px;
}

.warning-box strong {
  color: #d97706;
}

.success-box {
  background-color: #d4edda;
  border-left: 4px solid #6b7280;
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: 4px;
}

.success-box strong {
  color: #059669;
}

/* Details/Collapsible Boxes */
.details-box {
  margin: 0.5rem 0;
  padding: 1rem;
  border: 1px solid #6b7280;
  border-radius: 4px;
  background-color: var(--bg-light);
}

.details-box summary {
  cursor: pointer;
  font-weight: bold;
  color: var(--primary-color);
  margin: -1rem -1rem 0 -1rem;
  padding: 1rem;
}

/* Chapter Cards */
.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

.chapter-card {
  background-color: var(--bg-light);
  padding: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
}

.chapter-card.secondary {
  border-left-color: var(--secondary-color);
}

.chapter-card h3 {
  color: var(--primary-color);
  margin-top: 0;
}

/* Quick Links */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.quick-link {
  padding: 1.5rem;
  border-radius: 8px;
}

.quick-link h4 {
  color: var(--primary-color);
}

.quick-link-info {
  background-color: #d1e7fd;
}

.quick-link-info h4 {
  color: var(--primary-color);
}

.quick-link-success {
  background-color: #d4edda;
}

.quick-link-success h4 {
  color: #059669;
}

.quick-link-warning {
  background-color: #fff3cd;
}

.quick-link-warning h4 {
  color: #d97706;
}

/* Code Blocks */
code {
  background-color: var(--bg-light);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-family: 'Monaco', 'Courier New', monospace;
  color: #e83e8c;
}

pre {
  background-color: var(--bg-light);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid #6b7280;
}

pre code {
  background-color: transparent;
  padding: 0;
  color: var(--text-dark);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn:hover {
  background-color: var(--secondary-color);
}

.btn.btn-gray {
  background-color: #9ca3af;
}

.btn.btn-gray:hover {
  background-color: #6b7280;
}

.btn-secondary {
  background-color: var(--accent-color);
  color: white;
}

.btn-secondary:hover {
  background-color: #d97706;
}

.btn-secondary.btn-gray {
  background-color: #9ca3af;
}

.btn-secondary.btn-gray:hover {
  background-color: #6b7280;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

table th,
table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #6b7280;
}

table th {
  background-color: #e5e7eb;
  color: #1f2937;
  font-weight: bold;
}

table tr:hover {
  background-color: var(--bg-light);
}

/* Footer */
footer {
  background: linear-gradient(to bottom, #f0f0f2, #dcdce2);
  color: #1f2937;
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
}

footer a,
footer a:visited {
  color: var(--secondary-color);
  text-decoration: underline;
  transition: color 0.3s;
}

footer a:hover {
  color: var(--primary-color);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .nav {
    gap: 0.75rem;
  }

  .content h1 {
    font-size: 1.8rem;
  }

  .header-container {
    flex-direction: column;
    gap: 1rem;
  }

  /* Breite Tabellen seitlich scrollbar statt abgeschnitten */
  .content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Lange Tastenkuerzel und Dateinamen duerfen umbrechen */
  .content table code {
    overflow-wrap: anywhere;
  }

}

/* Mobile Optimization (Handy < 480px) */
@media (max-width: 480px) {
  .header-container {
    padding: 0 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .container {
    padding: 0 1rem;
  }

  .logo {
    font-size: 1.2rem;
  }

  .logo img {
    height: 40px !important;
  }

  .nav {
    gap: 0.5rem;
    font-size: 0.8rem;
    flex-direction: row;
  }

  .nav a,
  .nav button {
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
    white-space: nowrap;
  }

  main {
    margin: 1.5rem auto;
  }

  .sidebar {
    padding: 1rem;
  }

  .sidebar h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .sidebar a {
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
  }

  .content {
    padding: 1.5rem;
  }

  .content h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.75rem;
  }

  .content h2 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }

  .content h3 {
    font-size: 1.1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .content h4 {
    font-size: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .content p {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
  }

  .content ul,
  .content ol {
    margin: 0.75rem 0 0.75rem 1.5rem;
    font-size: 0.95rem;
  }

  .content li {
    margin-bottom: 0.4rem;
  }

  .btn {
    padding: 0.75rem 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
  }

  .info-box,
  .warning-box,
  .success-box {
    padding: 0.75rem;
    margin: 1rem 0;
    font-size: 0.9rem;
  }

  .details-box {
    padding: 0.75rem;
    margin: 0.5rem 0;
  }

  .details-box summary {
    font-size: 0.95rem;
    margin: -0.75rem -0.75rem 0 -0.75rem;
    padding: 0.75rem;
  }

  table {
    font-size: 0.85rem;
    margin: 1rem 0;
  }

  table th,
  table td {
    padding: 0.5rem;
  }

  code {
    font-size: 0.85rem;
  }

  pre {
    padding: 0.75rem;
    font-size: 0.8rem;
    margin: 0.75rem 0;
  }

  .chapter-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
  }

  .chapter-card {
    padding: 1rem;
  }

  .quick-links {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
  }

  .quick-link {
    padding: 1rem;
  }

  .breadcrumb {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  footer {
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
  }
}

/* Image Hover Zoom */
img[data-hover-zoom] {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-origin: top left;
}

/* Der Zoomfaktor wird in hover-zoom.js berechnet und inline gesetzt */
img[data-hover-zoom].zoomed {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 10;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.lightbox-image {
  width: auto;
  height: auto;
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: -16px;
  right: 40px;
  font-size: 2rem;
  font-weight: bold;
  color: #999;
  cursor: pointer;
  transition: color 0.3s;
  padding: 10px;
  line-height: 1;
}

.lightbox-close:hover {
  color: #555;
}

/* Scroll-to-Top Button */
#scroll-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 99;
}

#scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

#scroll-to-top:hover {
  background-color: var(--secondary-color);
  transform: translateY(-3px);
}

html.dark-mode #scroll-to-top {
  background-color: var(--primary-color);
}

html.dark-mode #scroll-to-top:hover {
  background-color: var(--secondary-color);
}

/* Volltextsuche (search.js) */
.nav-search {
  position: relative;
  /* Das Suchfeld gibt bei Platzmangel nach, damit die Menuetexte nicht
     umbrechen und das Logo nicht ueberlappt wird */
  flex: 0 1 200px;
  min-width: 110px;
}

/* Menuetexte bleiben einzeilig, nur das Suchfeld gibt nach */
.nav > li {
  white-space: nowrap;
}

#doc-search {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.6rem;
  width: 100%;
  border: 1px solid var(--primary-color);
  border-radius: 4px;
  background-color: #ffffff;
  color: #000000;
}

#doc-search:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: 440px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  text-align: left;
  z-index: 200;
}

.search-results[hidden] {
  display: none;
}

a.search-hit,
a.search-hit:visited {
  display: block;
  /* .nav a setzt auf Handys nowrap - in der Trefferliste muss umbrochen werden */
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--bg-light);
  text-decoration: none !important;
  color: var(--text-dark) !important;
}

a.search-hit:last-child {
  border-bottom: none;
}

a.search-hit.active,
a.search-hit:hover {
  background-color: var(--bg-light);
}

.search-crumb {
  display: block;
  font-size: 0.72rem;
  color: var(--text-light);
  margin-bottom: 0.1rem;
}

.search-title {
  display: block;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--primary-color);
  margin-bottom: 0.15rem;
}

.search-snippet {
  display: block;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-light);
}

.search-empty {
  padding: 0.8rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.search-results mark {
  background-color: var(--accent-color);
  color: #000000;
  padding: 0 1px;
  border-radius: 2px;
}

/* Hervorhebung der Suchbegriffe auf der Zielseite */
mark.search-target {
  background-color: var(--accent-color);
  color: #000000;
  padding: 0 1px;
  border-radius: 2px;
}

html.dark-mode #doc-search {
  background-color: #555555;
  color: #ffffff;
  border-color: var(--secondary-color);
}

html.dark-mode #doc-search::placeholder {
  color: #d0d0d0;
  opacity: 1;
}

html.dark-mode .search-results {
  background-color: #333333;
  border-color: #555555;
}

html.dark-mode a.search-hit,
html.dark-mode a.search-hit:visited {
  color: #ffffff !important;
  border-bottom-color: #444444;
}

html.dark-mode a.search-hit.active,
html.dark-mode a.search-hit:hover {
  background-color: #444444;
}

html.dark-mode .search-title {
  color: var(--secondary-color);
}

html.dark-mode .search-results mark,
html.dark-mode mark.search-target {
  background-color: #9333ea;
  color: #ffffff;
}

/* Ab hier reicht der Platz neben dem Logo nicht mehr fuer eine Zeile:
   Menuetexte in der ersten Zeile, Suchfeld in voller Breite darunter */
@media (max-width: 1080px) {
  .nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 0.5rem;
  }

  .nav-search {
    flex-basis: 100%;
    order: 1;
    /* Eigene Zeile, das Feld darin aber nicht breiter als am Desktop */
    display: flex;
    justify-content: flex-end;
  }

  #doc-search {
    max-width: 200px;
  }
}

@media (max-width: 900px) {
  /* Trefferliste ueber die ganze Breite der Suchzeile, damit sie nicht
     seitlich herauslaeuft */
  .search-results {
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  #doc-search {
    font-size: 0.85rem;
  }
}

/* Print Styles */
@media print {
  header, footer, .sidebar {
    display: none;
  }

  main {
    grid-template-columns: 1fr;
  }

  .content {
    border: none;
    padding: 0;
  }
}
