/* 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;
}

.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;
}

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

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

.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;
}

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