/* Modern Styles for Fordocs */

/* Fix navbar spacing for fixed navbar */
body {
  padding-top: 70px;
}

/* Enhanced badge styling */
.badge {
  font-size: 0.875em;
}

/* Style original HTML tree diagrams as fallback */
ul[class^='class-diagram'] {
  background-color: var(--bs-light);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 1rem;
  margin: 1rem 0;
}

[data-bs-theme="dark"] ul[class^='class-diagram'] {
  background-color: var(--bs-dark);
}

/* Hide HTML tree diagrams only after JavaScript processes them */
ul[class^='class-diagram'].processed {
  display: none;
}

/* Style for Cytoscape diagram containers */
div[class^='diagram-container'] {
  width: 100%;
  height: 500px;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  margin: 0.5rem 0;
  background-color: var(--bs-body-bg);
  position: relative;
}

[data-bs-theme="dark"] div[class^='diagram-container'] {
  border-color: var(--bs-border-color);
  background-color: var(--bs-dark);
}

/* Modern tree diagram containers */
.tree-diagram-container {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  transition: all 0.15s ease-in-out;
  position: relative;
  overflow: hidden;
}

.tree-diagram-container:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Tree controls styling */
.tree-controls {
  z-index: 10;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.tree-controls:hover {
  opacity: 1;
}

/* Arguments styling */
.arguments {
  background-color: var(--bs-light);
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color);
  margin: 1rem 0;
}

[data-bs-theme="dark"] .arguments {
  background-color: var(--bs-dark);
  border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .arguments .bg-light {
  background-color: var(--bs-gray-800) !important;
  color: var(--bs-light);
}

/* Fix badge colors in dark theme */
[data-bs-theme="dark"] .badge.bg-light {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-light) !important;
  border-color: var(--bs-gray-600) !important;
}

/* Fix card backgrounds in dark theme */
[data-bs-theme="dark"] .card {
  background-color: var(--bs-dark);
  border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .card-header {
  background-color: var(--bs-gray-800);
  border-color: var(--bs-border-color);
}

/* Fix alert styling in dark theme */
[data-bs-theme="dark"] .alert-light {
  background-color: var(--bs-gray-800);
  border-color: var(--bs-gray-700);
  color: var(--bs-light);
}

/* Ensure proper text colors in all contexts */
[data-bs-theme="dark"] .text-muted {
  color: #adb5bd !important;
}

[data-bs-theme="dark"] .text-dark {
  color: #f8f9fa !important;
}

/* Fix badge contrast in dark theme */
[data-bs-theme="dark"] .badge.bg-warning {
  color: #000 !important;
}

/* Improve function return type visibility */
.return_type {
  font-weight: 600 !important;
}

/* Fix comment sections in templates */
[data-bs-theme="dark"] .alert-light .text-muted {
  color: #ced4da !important;
}

/* Subroutines and functions */
ul.subroutines blockquote,
ul.functions blockquote {
  font-size: 0.875rem;
  margin: 0.5rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--bs-primary);
  background-color: var(--bs-light);
}

[data-bs-theme="dark"] ul.subroutines blockquote,
[data-bs-theme="dark"] ul.functions blockquote {
  background-color: var(--bs-dark);
}

/* Return arguments highlighting */
ul.arguments li.return {
  color: var(--bs-purple);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background-color: rgba(var(--bs-purple-rgb), 0.1);
  border-radius: 0.25rem;
  margin: 0.25rem 0;
}

/* Return type styling */
.return_type {
  color: var(--bs-success) !important;
  font-weight: 600;
}

/* Fix code blocks in dark theme */
[data-bs-theme="dark"] code {
  background-color: var(--bs-gray-800);
  color: var(--bs-info);
}

/* Fix border colors in dark theme */
[data-bs-theme="dark"] .border {
  border-color: var(--bs-gray-700) !important;
}

/* Improve text contrast */
[data-bs-theme="dark"] .text-muted {
  color: var(--bs-gray-400) !important;
}

[data-bs-theme="dark"] .text-secondary {
  color: var(--bs-gray-300) !important;
}

/* Fix list item backgrounds in dark theme */
[data-bs-theme="dark"] .properties li.bg-light {
  background-color: var(--bs-gray-800) !important;
  border-color: var(--bs-gray-700) !important;
}

/* Improve comment readability */
.class-comment pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
}

[data-bs-theme="dark"] .class-comment {
  background-color: var(--bs-gray-800);
  color: var(--bs-light);
  border-color: var(--bs-success);
}

/* Responsive design improvements */
@media (max-width: 768px) {
  body {
    padding-top: 60px;
  }

  .tree-diagram-container {
    height: 300px !important;
    margin: 1rem 0;
  }

  .tree-controls {
    position: static !important;
    margin: 0.5rem 0 !important;
    text-align: center;
  }

  .tree-controls .btn-group-vertical {
    display: inline-flex;
    flex-direction: row;
  }
}

/* Enhanced card styling for content sections */
.content-section {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin: 1rem 0;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Improved code blocks */
pre, code {
  background-color: var(--bs-gray-100);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  color: var(--bs-body-color);
  padding: 0.5rem;
}

/* Fix blockquote pre elements - common in program/file descriptions */
blockquote pre,
blockquote p pre {
  background-color: rgba(0, 0, 0, 0.08) !important;
  color: #212529 !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  padding: 1rem !important;
  margin: 0.5rem 0 !important;
  border-radius: 0.375rem !important;
  font-family: var(--bs-font-monospace) !important;
  font-size: 0.875rem !important;
  line-height: 1.4 !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}

[data-bs-theme="dark"] pre,
[data-bs-theme="dark"] code {
  background-color: var(--bs-gray-800);
  color: var(--bs-gray-100);
}

[data-bs-theme="dark"] blockquote pre,
[data-bs-theme="dark"] blockquote p pre {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #f8f9fa !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* Enhanced table styling */
.table {
  --bs-table-bg: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}

/* Smooth transitions for theme switching */
* {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Print styles */
@media print {
  body {
    padding-top: 0;
  }

  .navbar,
  .tree-controls,
  #theme-toggle {
    display: none !important;
  }

  .tree-diagram-container {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
}