/**
 * ElectroParts Wiki Styles
 * Version: 1.0.3
 */

/* Wiki Page Container */
.wiki-page {
  min-height: calc(100vh - 200px);
  background: var(--bg-secondary, #f8fafc);
  padding: 2rem 1rem;
}

.wiki-container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Wiki Header */
.wiki-header {
  text-align: center;
  margin-bottom: 2rem;
}

.wiki-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.wiki-icon {
  width: 36px;
  height: 36px;
  color: var(--primary, #2563eb);
}

.wiki-title h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  margin: 0;
}

.wiki-subtitle {
  color: var(--text-secondary, #64748b);
  font-size: 1rem;
  margin: 0;
}

/* Search Panel */
.wiki-search-panel {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wiki-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search-input-group {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-secondary, #64748b);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.5rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-group {
  display: flex;
  gap: 0.5rem;
}

.filter-select {
  padding: 0.625rem 2rem 0.625rem 0.875rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 0.875rem;
  background: white
    url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e")
    right 0.5rem center / 1.25rem no-repeat;
  cursor: pointer;
  appearance: none;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
}

/* Tabs */
.wiki-tabs {
  display: flex;
  gap: 0.25rem;
  background: white;
  border-radius: 12px 12px 0 0;
  padding: 0.5rem 0.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wiki-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  color: var(--text-secondary, #64748b);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 8px 8px 0 0;
  transition: color 0.2s, background-color 0.2s;
}

.wiki-tab svg {
  width: 18px;
  height: 18px;
}

.wiki-tab:hover {
  color: var(--text-primary, #1e293b);
  background: var(--bg-secondary, #f8fafc);
}

.wiki-tab.active {
  color: var(--primary, #2563eb);
  background: var(--bg-secondary, #f8fafc);
  border-bottom: 2px solid var(--primary, #2563eb);
  margin-bottom: -1px;
}

.wiki-tab-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding-right: 0.5rem;
}

/* Wiki Content */
.wiki-content {
  background: white;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.wiki-view-mode {
  padding: 2rem;
}

/* Markdown Body */
.markdown-body {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-primary, #1e293b);
}

.markdown-body h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border, #e2e8f0);
}

.markdown-body h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary, #f8fafc);
  border-left: 4px solid var(--primary, #2563eb);
  border-radius: 0 8px 8px 0;
}

.markdown-body h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--text-primary, #1e293b);
}

.markdown-body p {
  margin: 0 0 1rem;
}

.markdown-body ul {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.markdown-body li {
  margin-bottom: 0.375rem;
}

.markdown-body code {
  font-family: "SF Mono", Monaco, "Courier New", monospace;
  font-size: 0.875em;
  background: var(--bg-secondary, #f1f5f9);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  color: var(--primary, #2563eb);
}

.markdown-body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.8125rem;
}

.markdown-body strong {
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}

.markdown-body a {
  color: var(--primary, #2563eb);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border, #e2e8f0);
  margin: 2rem 0;
}

.markdown-body mark {
  background: #fef08a;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
}

.markdown-body .wiki-badge {
  height: 20px;
  vertical-align: middle;
  margin-right: 0.25rem;
}

/* Edit Mode */
.wiki-edit-mode {
  padding: 0;
}

.edit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary, #f8fafc);
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.edit-label {
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  font-size: 0.875rem;
}

.edit-actions {
  display: flex;
  gap: 0.5rem;
}

.wiki-editor {
  width: 100%;
  min-height: 500px;
  padding: 1.25rem;
  font-family: "SF Mono", Monaco, "Courier New", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  border: none;
  border-bottom: 1px solid var(--border, #e2e8f0);
  resize: vertical;
}

.wiki-editor:focus {
  outline: none;
}

.edit-help {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary, #f8fafc);
  font-size: 0.8125rem;
  color: var(--text-secondary, #64748b);
}

.edit-help strong {
  color: var(--text-primary, #1e293b);
}

/* Legend Section */
.wiki-legend {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wiki-legend h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text-primary, #1e293b);
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.legend-section h5 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-secondary, #64748b);
}

.legend-section p {
  margin: 0 0 0.5rem;
}

.legend-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.legend-section li {
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Category Badges */
.cat-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.cat-added {
  background: #dcfce7;
  color: #166534;
}

.cat-changed {
  background: #dbeafe;
  color: #1e40af;
}

.cat-fixed {
  background: #fef3c7;
  color: #92400e;
}

.cat-removed {
  background: #fee2e2;
  color: #991b1b;
}

.cat-security {
  background: #f3e8ff;
  color: #6b21a8;
}

.cat-deprecated {
  background: #f1f5f9;
  color: #475569;
}

/* Alerts */
.alert {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary, #2563eb);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--bg-secondary, #f1f5f9);
  color: var(--text-primary, #1e293b);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: white;
  color: var(--text-primary, #1e293b);
  border: 1px solid var(--border, #e2e8f0);
}

.btn-outline:hover {
  background: var(--bg-secondary, #f8fafc);
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 768px) {
  .wiki-page {
    padding: 1rem 0.75rem;
  }

  .wiki-title h1 {
    font-size: 1.5rem;
  }

  .wiki-search-form {
    flex-direction: column;
  }

  .search-input-group {
    width: 100%;
  }

  .filter-group {
    width: 100%;
  }

  .filter-select {
    flex: 1;
  }

  .wiki-tabs {
    overflow-x: auto;
  }

  .wiki-view-mode {
    padding: 1.25rem;
  }

  .markdown-body h1 {
    font-size: 1.375rem;
  }

  .markdown-body h2 {
    font-size: 1.125rem;
  }

  .legend-grid {
    grid-template-columns: 1fr;
  }
}
