/**
 * Enhanced Mermaid Diagram Styling with Pan/Zoom/Fullscreen Controls
 * Custom CSS for interactive Mermaid diagrams in MkDocs
 * Using Lysis.ai Brand Colors
 */

/* Diagram wrapper container */
.diagram-wrapper {
  position: relative;
  margin: 2em 0;
  border: 1px solid #00ACC1;
  border-radius: 0.2rem;
  overflow: hidden;
  background: #E0F7FA;
}

/* Dark mode adjustments */
[data-md-color-scheme="slate"] .diagram-wrapper {
  background: #263238;
  border-color: #B2EBF2;
}

/* Control buttons container */
.diagram-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  display: flex;
  gap: 0.25rem;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.diagram-controls:hover {
  opacity: 1;
}

/* Individual control buttons - Lysis Teal/Cyan */
.diagram-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid #00ACC1;
  border-radius: 0.2rem;
  background: #00838F;
  color: #ffffff;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: 0 2px 4px rgba(0, 131, 143, 0.2);
}

.diagram-btn:hover {
  background: #00ACC1;
  border-color: #B2EBF2;
  transform: scale(1.05);
}

.diagram-btn:active {
  transform: scale(0.95);
  background: #006978;
}

/* Dark mode button adjustments */
[data-md-color-scheme="slate"] .diagram-btn {
  background: #00ACC1;
  border-color: #B2EBF2;
}

[data-md-color-scheme="slate"] .diagram-btn:hover {
  background: #00d4e6;
  border-color: #E0F7FA;
}

/* Mermaid diagram styling */
.diagram-wrapper .mermaid {
  cursor: grab;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.diagram-wrapper.pan-mode .mermaid {
  cursor: grabbing;
}

/* Zoom indicator - Lysis Orange accent */
.zoom-indicator {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  background: #FF6E40;
  color: #ffffff;
  padding: 0.25rem 0.5rem;
  border-radius: 0.2rem;
  border: 1px solid #BF360C;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.9;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(191, 54, 12, 0.2);
}

/* Dark mode zoom indicator */
[data-md-color-scheme="slate"] .zoom-indicator {
  background: #FFCCBC;
  color: #BF360C;
  border-color: #FF6E40;
}

/* Fullscreen mode */
.mermaid-fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 1000;
  margin: 0;
  background: #FAFAFA;
}

/* Dark mode fullscreen */
[data-md-color-scheme="slate"] .mermaid-fullscreen {
  background: #263238;
}

.mermaid-fullscreen .mermaid {
  width: 100%;
  height: calc(100vh - 4rem);
}

/* Responsive design */
@media screen and (max-width: 768px) {
  .diagram-controls {
    top: 0.25rem;
    right: 0.25rem;
    gap: 0.15rem;
  }

  .diagram-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1rem;
  }

  .zoom-indicator {
    bottom: 0.25rem;
    left: 0.25rem;
    font-size: 0.7rem;
  }
}

/* Touch device support */
@media (hover: none) and (pointer: coarse) {
  .diagram-wrapper .mermaid {
    cursor: default;
    touch-action: pan-x pan-y pinch-zoom;
  }

  .diagram-controls {
    opacity: 1;
  }
}

/* ============================================
 * Responsive Tables - Horizontal Scroll
 * Prevents wide tables from being cut off
 * ============================================ */

/* Make the table's parent container scrollable */
.md-typeset__table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1em 0;
}

/* Reset table to auto width - let content determine size */
.md-typeset table:not([class]) {
  width: auto;
  min-width: 0;
  max-width: none;
  display: table;
}

/* Compact table styling for better fit */
.md-typeset table {
  font-size: 0.8rem;
}

.md-typeset table th,
.md-typeset table td {
  padding: 0.4em 0.6em;
  white-space: nowrap;
}

/* Allow wrapping for description columns */
.md-typeset table td:last-child {
  white-space: normal;
  min-width: 150px;
}

/* Style the scrollbar */
.md-typeset__table::-webkit-scrollbar {
  height: 8px;
}

.md-typeset__table::-webkit-scrollbar-track {
  background: #E0F7FA;
  border-radius: 4px;
}

.md-typeset__table::-webkit-scrollbar-thumb {
  background: #00ACC1;
  border-radius: 4px;
}

.md-typeset__table::-webkit-scrollbar-thumb:hover {
  background: #00838F;
}

/* Dark mode scrollbar */
[data-md-color-scheme="slate"] .md-typeset__table::-webkit-scrollbar-track {
  background: #37474F;
}

[data-md-color-scheme="slate"] .md-typeset__table::-webkit-scrollbar-thumb {
  background: #00ACC1;
}

/* Table header styling - darker background */
.md-typeset table th {
  background-color: #00838F !important;
  color: #ffffff !important;
  font-weight: 600;
}

/* Dark mode table header */
[data-md-color-scheme="slate"] .md-typeset table th {
  background-color: #006064 !important;
  color: #E0F7FA !important;
}

/* ============================================
 * Wider Content Area
 * Increase max-width for more space
 * ============================================ */

/* Override MkDocs Material default max-width */
:root {
  --md-content-max-width: 1600px;
}

/* Force wider grid */
.md-grid {
  max-width: 1600px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Ensure content uses available space */
.md-main__inner {
  max-width: none !important;
}

.md-content__inner {
  max-width: none !important;
}

/* Slightly narrower sidebars to give more content space */
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary {
    width: 11rem !important;
  }

  .md-sidebar--secondary {
    width: 11rem !important;
  }
}

/* ============================================
 * Dark Mode Custom Primary Color
 * Using primary: custom in mkdocs.yml for slate scheme
 * ============================================ */

[data-md-color-primary=custom] {
  --md-primary-fg-color: #004d61;
  --md-primary-fg-color--light: #006b7d;
  --md-primary-fg-color--dark: #003d4d;
  --md-primary-bg-color: #fff;
  --md-primary-bg-color--light: #ffffffb3;
}

/* ============================================
 * Darker Navigation Tabs (both light and dark mode)
 * ============================================ */

/* Light mode - darker tabs */
[data-md-color-scheme=default] .md-tabs {
  background-color: #007a6c;
}

/* Dark mode - darker tabs */
[data-md-color-scheme=slate] .md-tabs {
  background-color: #003d4d;
}

/* ============================================
 * Dark Mode Link Colors
 * Brighter links for better visibility
 * ============================================ */

/* Dark mode link colors - bright cyan for visibility */
[data-md-color-scheme="slate"] .md-typeset a {
  color: #4dd0e1;
}

[data-md-color-scheme="slate"] .md-typeset a:hover {
  color: #80deea;
}

[data-md-color-scheme="slate"] .md-typeset a:focus {
  color: #80deea;
}

/* Navigation links in sidebar */
[data-md-color-scheme="slate"] .md-nav__link {
  color: #b2ebf2;
}

[data-md-color-scheme="slate"] .md-nav__link:hover {
  color: #e0f7fa;
}

[data-md-color-scheme="slate"] .md-nav__link--active {
  color: #4dd0e1;
}

/* TOC (Table of Contents) links */
[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link {
  color: #80cbc4;
}

[data-md-color-scheme="slate"] .md-nav--secondary .md-nav__link:hover {
  color: #b2dfdb;
}

/* Footer links */
[data-md-color-scheme="slate"] .md-footer a {
  color: #4dd0e1;
}

[data-md-color-scheme="slate"] .md-footer a:hover {
  color: #80deea;
}
