/* Base Styles */
body {
  font-family: system-ui, -apple-system, Arial, sans-serif;
  margin: 0;
  background: #0b0e12;
  color: #e6edf3;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { 
  color: #7cc7ff; 
  text-decoration: none; 
}

a:hover { 
  text-decoration: underline; 
}

/* Header */
header {
  background: #121826;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #1a2233;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  min-height: 70px;
}

header h1 { 
  margin: 0; 
  font-size: 22px;
  font-weight: 600;
}

header h1 a {
  color: #e6edf3;
}

header h1 a:hover {
  text-decoration: none;
  color: #7cc7ff;
}

header form { 
  display: flex; 
  gap: 8px; 
  align-items: center; 
  margin-left: auto; 
}

header nav {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: auto;
}

header input { 
  padding: 8px 12px; 
  border-radius: 6px; 
  border: 1px solid #2b3445; 
  background: #0f1420; 
  color: #e6edf3;
  min-width: 200px;
}

header input:focus {
  outline: none;
  border-color: #7cc7ff;
}

header button, .new, button { 
  padding: 8px 16px; 
  border: 0; 
  border-radius: 6px; 
  background: #274060; 
  color: #e6edf3; 
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

header button:hover, .new:hover, button:hover { 
  background: #345882;
  text-decoration: none;
}

.edit-btn {
  background: #58a6ff;
  color: #0b0e12;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
}

.edit-btn:hover {
  background: #7cc7ff;
  text-decoration: none;
}

/* Main Content */
main {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  flex: 1;
}

/* Filters */
.filters {
  margin-bottom: 24px;
  padding: 16px;
  background: #121826;
  border-radius: 8px;
  border: 1px solid #1a2233;
}

.filters h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #8b949e;
  font-weight: 500;
}

.category-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Category Badges */
.cat-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid;
  background-color: transparent;
  transition: all 0.2s;
}

.cat-badge:hover {
  opacity: 0.8;
  text-decoration: none;
  transform: translateY(-1px);
}

.cat-badge.active {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(124, 199, 255, 0.3);
}

.cat-badge.large {
  padding: 10px 20px;
  font-size: 18px;
  color: #0b0e12;
  font-weight: 600;
}

/* Article List */
.article-count {
  margin-bottom: 16px;
  color: #8b949e;
  font-size: 14px;
}

ul.list { 
  list-style: none; 
  padding: 0; 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); 
  gap: 16px; 
}

ul.list li { 
  background: #121826; 
  border: 1px solid #1a2233; 
  border-radius: 8px; 
  padding: 16px;
  transition: all 0.2s;
}

ul.list li:hover {
  border-color: #2b3445;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.article-title {
  font-size: 18px;
  font-weight: 600;
  color: #7cc7ff;
  display: block;
  margin-bottom: 8px;
}

.snippet {
  color: #8b949e;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
}

.meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #1a2233;
}

.meta small {
  color: #6e7681;
  font-size: 12px;
}

.no-results {
  text-align: center;
  padding: 48px;
  color: #8b949e;
  font-size: 16px;
}

/* Article View */
.article {
  max-width: 800px;
}

.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid #1a2233;
}

.article-header h2 {
  margin: 0 0 12px 0;
  font-size: 32px;
  color: #e6edf3;
}

.article-header .categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.article-header .meta {
  border: none;
  padding: 0;
  margin: 12px 0 0 0;
}

.content { 
  line-height: 1.8;
  font-size: 16px;
}

.content h1, .content h2, .content h3 { 
  border-bottom: 1px solid #1a2233; 
  padding-bottom: 8px;
  margin-top: 32px;
  margin-bottom: 16px;
  color: #e6edf3;
}

.content h1 {
  font-size: 28px;
}

.content h2 {
  font-size: 24px;
}

.content h3 {
  font-size: 20px;
}

.content p {
  margin: 16px 0;
}

.content ul, .content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.content li {
  margin: 8px 0;
}

.content code {
  background: #1a2233;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.content strong {
  color: #e6edf3;
  font-weight: 600;
}

.article-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 48px;
}

section { 
  background: #121826;
  border: 1px solid #1a2233;
  border-radius: 8px;
  padding: 20px;
}

section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #e6edf3;
  font-weight: 600;
}

.ref-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ref-list li {
  padding: 8px 0;
  border-bottom: 1px solid #1a2233;
}

.ref-list li:last-child {
  border-bottom: none;
}

.ref-list li.empty {
  color: #6e7681;
  font-style: italic;
}

/* Forms */
.form {
  max-width: 800px;
}

.form label { 
  display: block;
  margin-bottom: 24px;
  font-weight: 500;
}

.form label small {
  color: #8b949e;
  font-weight: 400;
  display: block;
  margin-top: 4px;
}

.form textarea, .form input[type="text"], .form input:not([type="checkbox"]) { 
  width: 100%; 
  box-sizing: border-box; 
  padding: 10px 12px; 
  border-radius: 6px; 
  border: 1px solid #2b3445; 
  background: #0f1420; 
  color: #e6edf3;
  font-family: inherit;
  font-size: 14px;
  margin-top: 8px;
}

.form textarea {
  font-family: 'Courier New', monospace;
  resize: vertical;
}

.form input:focus, .form textarea:focus {
  outline: none;
  border-color: #7cc7ff;
  box-shadow: 0 0 0 3px rgba(124, 199, 255, 0.1);
}

.checkbox-group {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.button-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

.cancel-btn {
  padding: 8px 16px;
  color: #8b949e;
  background: transparent;
  border: 1px solid #2b3445;
  border-radius: 6px;
  display: inline-block;
}

.cancel-btn:hover {
  background: #1a2233;
  text-decoration: none;
  color: #e6edf3;
}

/* Category Page */
.category-header {
  margin-bottom: 32px;
}

.category-header h2 {
  margin: 0 0 12px 0;
}

.category-description {
  color: #8b949e;
  font-size: 16px;
  margin: 8px 0;
}

/* Admin Tables */
.admin-table {
  margin-top: 24px;
  overflow-x: auto;
}

.admin-table table {
  width: 100%;
  border-collapse: collapse;
  background: #121826;
  border: 1px solid #1a2233;
  border-radius: 8px;
  overflow: hidden;
}

.admin-table thead {
  background: #1a2233;
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #e6edf3;
  border-bottom: 2px solid #2b3445;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #1a2233;
  color: #e6edf3;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover {
  background: #0f1420;
}

.color-preview {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #2b3445;
  margin-right: 8px;
  vertical-align: middle;
}

.admin-table code {
  background: #0f1420;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

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

.btn-small {
  padding: 4px 12px;
  font-size: 13px;
  border-radius: 4px;
  background: #274060;
  color: #e6edf3;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-small:hover {
  background: #345882;
  text-decoration: none;
}

.btn-danger {
  background: #da3633;
}

.btn-danger:hover {
  background: #f14e4b;
}

.disabled-hint {
  color: #6e7681;
  font-size: 13px;
  font-style: italic;
  cursor: not-allowed;
}

/* Color Picker */
.color-picker-container {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.color-picker-container input[type="color"] {
  width: 60px;
  height: 40px;
  border: 1px solid #2b3445;
  border-radius: 6px;
  cursor: pointer;
  background: #0f1420;
}

.color-picker-container input[type="text"] {
  width: 120px;
  font-family: 'Courier New', monospace;
}

.preview {
  margin: 24px 0;
  padding: 16px;
  background: #121826;
  border: 1px solid #1a2233;
  border-radius: 8px;
}

.preview p {
  margin: 0 0 12px 0;
  color: #8b949e;
  font-size: 14px;
}

.preview-badge {
  color: #0b0e12;
  font-weight: 600;
}

/* Footer */
footer {
  background: #121826;
  border-top: 1px solid #1a2233;
  padding: 20px 24px;
  margin-top: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  color: #8b949e;
  font-size: 14px;
}

.footer-left {
  text-align: left;
}

.footer-center {
  text-align: center;
}

.footer-right {
  text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
  }
  
  header form, header nav {
    margin-left: 0;
    width: 100%;
  }
  
  ul.list {
    grid-template-columns: 1fr;
  }
  
  .article-sections {
    grid-template-columns: 1fr;
  }
  
  .filters {
    padding: 12px;
  }
  
  .category-filters {
    gap: 6px;
  }
  
  .cat-badge {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  footer {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .footer-left,
  .footer-center,
  .footer-right {
    text-align: center;
  }
}
