/* Documentation Sidebar Styles */
.documentation-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 350px;
  height: 100%;
  background: white;
  border-left: 1px solid var(--color-grey-225-10-75);
  z-index: 999;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: visible;
}

/* Markdown Alerts (GitHub-style) */
.markdown-alert {
  padding: 16px;
  margin: 16px 0;
  border-left: 4px solid;
  border-radius: 6px;
  background-color: var(--alert-bg, #f8f9fa);
}

.markdown-alert-title {
  display: flex;
  align-items: center;
  font-weight: 600;
  margin: 0 0 8px 0;
  gap: 8px;
}

.markdown-alert-content {
  margin: 0;
}

.markdown-alert-content > *:first-child {
  margin-top: 0;
}

.markdown-alert-content > *:last-child {
  margin-bottom: 0;
}

.markdown-alert-icon {
  flex-shrink: 0;
}

.markdown-alert-note {
  border-left-color: #0969da;
  background-color: #ddf4ff;
  --alert-title-color: #0969da;
}

.markdown-alert-note .markdown-alert-title {
  color: var(--alert-title-color);
}

.markdown-alert-tip {
  border-left-color: #1a7f37;
  background-color: #dcffe4;
  --alert-title-color: #1a7f37;
}

.markdown-alert-tip .markdown-alert-title {
  color: var(--alert-title-color);
}

.markdown-alert-important {
  border-left-color: #8250df;
  background-color: #f6f8ff;
  --alert-title-color: #8250df;
}

.markdown-alert-important .markdown-alert-title {
  color: var(--alert-title-color);
}

.markdown-alert-warning {
  border-left-color: #d1242f;
  background-color: #fff8f8;
  --alert-title-color: #d1242f;
}

.markdown-alert-warning .markdown-alert-title {
  color: var(--alert-title-color);
}

.markdown-alert-caution {
  border-left-color: #bf8700;
  background-color: #fff8c5;
  --alert-title-color: #9a6700;
}

.markdown-alert-caution .markdown-alert-title {
  color: var(--alert-title-color);
}

/* Enhanced Code Blocks */
.markdown-code-block {
  margin: 16px 0;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  overflow: hidden;
  background-color: #f8f9fa;
}

.markdown-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: #f1f3f4;
  border-bottom: 1px solid #d1d9e0;
  font-size: 12px;
}

.markdown-code-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.markdown-code-title {
  color: #24292f;
  font-weight: 600;
  font-size: 13px;
}

.markdown-code-language {
  color: #656d76;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}

.markdown-code-copy {
  background: none;
  border: none;
  color: #656d76;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: background-color 0.2s ease;
}

.markdown-code-copy:hover {
  background-color: #e1e4e8;
  color: #24292f;
}

.markdown-code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background-color: #f8f9fa;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.markdown-code-block code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-family: inherit;
}

.markdown-inline-code {
  background-color: rgba(175, 184, 193, 0.2);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 85%;
}

.markdown-error {
  background-color: #fff8f8;
  border: 1px solid #d1242f;
  border-radius: 6px;
  padding: 12px;
  color: #d1242f;
  margin: 16px 0;
}

.horizontal-resize-handle {
  position: absolute;
  top: 0;
  right: 350px;
  width: 4px;
  height: 100%;
  background: transparent;
  cursor: ew-resize;
  z-index: 10000;
  display: none;
  transition: background-color 0.2s ease;
  border-right: 1px solid transparent;
}

.horizontal-resize-handle:hover {
  background: #007bff !important;
  border-right: 1px solid #007bff;
}

.documentation-header {
  padding: 12px 10px;
  background-color: var(--color-grey-225-10-95);
  border-bottom: 1px solid var(--color-grey-225-10-75);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  min-height: 64px;
}

.header-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.documentation-header h3 {
  margin: 0;
  font-size: 12px;
  color: var(--color-grey-225-10-15);
  font-weight: 600;
  text-transform: uppercase;
}

.element-metadata {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.element-name {
  font-size: 14px;
  color: var(--color-grey-225-10-15);
  font-weight: 400;
  word-break: break-word;
}

.sidebar-controls {
  display: flex;
  gap: 4px;
}

.close-btn,
.minimize-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover,
.minimize-btn:hover {
  background: #e9ecef;
  color: #333;
}

.minimize-btn {
  font-weight: bold;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-btn {
  background: none;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  border: 1px solid #ddd;
}

.help-btn:hover {
  background: #f8f9fa;
  color: #333;
  border-color: #bbb;
}

.help-popover {
  position: absolute;
  top: 70px;
  right: 20px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 99999;
  display: none;
  /* Ensure proper scrolling behavior */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.help-popover.visible {
  display: block;
}

.help-content {
  padding: 16px;
}

.help-content h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.help-section {
  margin-bottom: 12px;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.help-section p {
  margin: 0 0 8px 0;
  font-size: 11px;
  line-height: 1.4;
  color: #666;
}

.help-section ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.4;
  color: #666;
}

.help-section li {
  margin-bottom: 4px;
}

.help-section code {
  background: #f1f3f4;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 10px;
  color: #333;
}

.tab-container {
  display: flex;
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 0 4px;
  margin: 0;
  align-items: center;
  justify-content: space-between;
}

.tab-buttons {
  display: flex;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 11px;
  cursor: pointer;
  color: #666;
  font-weight: 500;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  position: relative;
}

.tab-btn.active {
  color: #007bff;
  border-bottom-color: #007bff;
  font-weight: 600;
}

.tab-btn:hover:not(.active) {
  color: #555;
  background: rgba(0, 123, 255, 0.05);
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

.documentation-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.documentation-preview {
  height: 50%;
  padding: 20px;
  overflow-y: auto;
  background: #fdfdfd;
  flex-shrink: 0;
}

.documentation-preview h1,
.documentation-preview h2,
.documentation-preview h3,
.documentation-preview h4,
.documentation-preview h5,
.documentation-preview h6 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #333;
}

.documentation-preview p {
  margin: 0 0 10px 0;
  line-height: 1.6;
  color: #555;
}

.documentation-preview code {
  background: #f1f3f4;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 0.9em;
}

.documentation-preview pre {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 10px 0;
}

.documentation-preview pre code {
  background: none;
  padding: 0;
}

.documentation-preview ul,
.documentation-preview ol {
  margin: 10px 0;
  padding-left: 20px;
}

.documentation-preview li {
  margin-bottom: 5px;
  line-height: 1.6;
}

.documentation-preview blockquote {
  border-left: 4px solid #007bff;
  margin: 15px 0;
  padding: 10px 15px;
  background: #f8f9fa;
  color: #666;
}

.documentation-preview em {
  color: #999;
  font-style: italic;
}

.documentation-bottom {
  height: 50%;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.resize-handle {
  height: 4px;
  background: transparent;
  cursor: ns-resize;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
  border-top: 1px solid var(--color-grey-225-10-75);
}

.resize-handle:hover {
  background: #007bff;
}

.documentation-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.editor-container {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#doc-textarea {
  flex: 1;
  padding: 15px;
  border: none;
  outline: none;
  resize: none;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 14px;
  line-height: 1.5;
  background: #fff;
}

#doc-textarea::placeholder {
  color: #999;
  font-style: italic;
}

.autocomplete-dropdown {
  position: absolute;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  width: 300px;
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-list {
  padding: 0;
  margin: 0;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #f8f9fa;
}

.autocomplete-item-id {
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: #0066cc;
  font-weight: bold;
}

.autocomplete-item-name {
  font-size: 11px;
  color: #666;
}

.autocomplete-item-type {
  font-size: 10px;
  color: #999;
  text-transform: uppercase;
}

.overview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
  overflow: hidden;
}

.overview-header {
  margin-bottom: 16px;
}

.coverage-summary {
  margin-bottom: 16px;
}

.coverage-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 11px;
}

.stat-item strong {
  color: hsl(225, 10%, 15%);
  font-size: 14px;
}

.coverage-bar {
  height: 6px;
  background: hsl(225, 10%, 90%);
  border-radius: 3px;
  overflow: hidden;
}

.coverage-progress {
  height: 100%;
  background: hsl(150, 86%, 44%);
  width: 0%;
  transition: width 0.3s ease;
}

.overview-search {
  margin-bottom: 12px;
}

.overview-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid hsl(225, 10%, 75%);
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 8px;
}

.search-actions {
  display: flex;
  gap: 4px;
}

.btn-small {
  padding: 4px 8px;
  font-size: 10px;
  border: 1px solid hsl(225, 10%, 75%);
  background: hsl(225, 10%, 97%);
  border-radius: 3px;
  cursor: pointer;
  color: hsl(225, 10%, 40%);
  transition: all 0.2s ease;
}

.btn-small.active {
  background: hsl(205, 100%, 50%);
  color: white;
  border-color: hsl(205, 100%, 50%);
}

.btn-small:hover:not(.active) {
  background: hsl(225, 10%, 92%);
}

.btn-export {
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 400;
  border: 1px solid hsl(225, 10%, 75%);
  background: hsl(225, 10%, 97%);
  color: hsl(225, 10%, 40%);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
}

.btn-export:hover {
  background: hsl(225, 10%, 92%);
  border-color: hsl(225, 10%, 70%);
  color: hsl(225, 10%, 25%);
}

.btn-export:active {
  background: hsl(225, 10%, 88%);
}

.export-btn-icon {
  font-size: 10px;
}

.overview-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid hsl(225, 10%, 90%);
  border-radius: 4px;
}

.overview-loading {
  padding: 20px;
  text-align: center;
  color: hsl(225, 10%, 40%);
  font-size: 12px;
}

.element-item {
  padding: 12px;
  border-bottom: 1px solid hsl(225, 10%, 92%);
  cursor: pointer;
  transition: background 0.2s ease;
}

.element-item:last-child {
  border-bottom: none;
}

.element-item:hover {
  background: hsl(225, 10%, 97%);
}

.element-item.documented {
  border-left: 4px solid hsl(150, 86%, 44%);
}

.element-item.undocumented {
  border-left: 4px solid hsl(45, 100%, 50%);
}

.element-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.element-id {
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: hsl(205, 100%, 50%);
  font-weight: bold;
}

.element-status {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.element-status.documented {
  background: hsl(150, 86%, 90%);
  color: hsl(150, 86%, 25%);
}

.element-status.undocumented {
  background: hsl(45, 100%, 90%);
  color: hsl(45, 100%, 25%);
}

.element-info {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: hsl(225, 10%, 40%);
}

.element-preview,
.element-preview-rendered {
  margin-top: 6px;
  font-size: 11px;
  color: hsl(225, 10%, 30%);
  line-height: 1.3;
  max-height: 40px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.element-preview-rendered p {
  margin: 0 0 4px 0;
  padding: 0;
}

.element-preview-rendered ul,
.element-preview-rendered ol {
  margin: 0;
  padding-left: 16px;
}

.element-preview-rendered li {
  margin-bottom: 2px;
}

.element-preview-rendered strong {
  font-weight: 600;
}

.element-preview-rendered em {
  font-style: italic;
  color: hsl(225, 10%, 40%);
}

.element-preview-rendered code {
  background: hsl(225, 10%, 95%);
  padding: 1px 3px;
  border-radius: 2px;
  font-family: "Courier New", monospace;
  font-size: 10px;
}

.element-preview-rendered a {
  color: hsl(205, 100%, 50%);
  text-decoration: none;
}

.element-preview-rendered a:hover {
  text-decoration: underline;
}

/* Minimized Icon Styles */
.minimized-icon {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: white;
  border: 1px solid var(--color-grey-225-10-75);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 1000;
  min-width: 140px;
  transition: all 0.3s ease;
}

.minimized-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.minimized-content {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}

.minimized-element-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.minimized-element-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-grey-225-10-15);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minimized-element-id {
  font-size: 10px;
  color: #666;
  font-family: "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minimized-restore-btn {
  font-size: 16px;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.minimized-icon:hover .minimized-restore-btn {
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .documentation-sidebar {
    width: 100%;
    right: 0;
  }

  .minimized-icon {
    bottom: 15px;
    right: 15px;
    min-width: 120px;
  }
}
