/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  font-size: 14px;
}
a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: 'SF Mono', 'Fira Code', Consolas, 'Liberation Mono', Menlo, monospace; }
pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
  font-size: 13px;
}
pre code { background: none; color: inherit; }
code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ===== Auth Pages ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.auth-card {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 400px;
  max-width: 90vw;
}
.auth-card h1 { font-size: 28px; margin-bottom: 4px; }
.auth-subtitle { color: #64748b; margin-bottom: 28px; }
.auth-link { margin-top: 20px; text-align: center; color: #64748b; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #334155; }
.form-group input, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: #6366f1;
}
.form-group textarea { resize: vertical; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-primary { background: #6366f1; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-success { background: #22c55e; color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-logout { color: #cbd5e1; font-size: 14px; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; white-space: pre-line; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; margin-bottom: 16px; padding: 12px 16px; border-radius: 8px; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: #1e293b;
  color: #fff;
}
.topbar-brand { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-info { color: #94a3b8; font-size: 14px; }

/* ===== Container ===== */
.container { max-width: 1200px; margin: 32px auto; padding: 0 24px; }

/* ===== Dashboard ===== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.dashboard-header h2 { font-size: 24px; }
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.project-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}
.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.project-card-header h3 { font-size: 16px; }
.project-desc { color: #64748b; font-size: 13px; margin-bottom: 12px; flex: 1; }
.project-meta { display: flex; gap: 16px; font-size: 12px; color: #94a3b8; margin-bottom: 16px; }
.project-meta code { font-size: 11px; }
.project-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.badge-published { background: #dcfce7; color: #16a34a; }
.badge-draft { background: #fef3c7; color: #d97706; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; color: #334155; }
.empty-state p { margin-bottom: 20px; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 440px;
  max-width: 90vw;
}
.modal-content h3 { margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== Editor Layout ===== */
.editor-layout {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}
.editor-sidebar {
  width: 240px;
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-section { padding: 12px 16px; border-bottom: 1px solid #334155; }
.sidebar-title { display: flex; align-items: center; justify-content: space-between; font-weight: 600; color: #fff; }
.sidebar-section-title { font-size: 12px; text-transform: uppercase; color: #64748b; margin-bottom: 8px; }
.file-list { display: flex; flex-direction: column; gap: 2px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #cbd5e1;
}
.file-item:hover { background: #334155; }
.file-item.active { background: #6366f1; color: #fff; }
.file-item .del-btn { opacity: 0; font-size: 11px; color: #ef4444; }
.file-item:hover .del-btn { opacity: 0.6; }
.file-item .del-btn:hover { opacity: 1; }
.version-list { display: flex; flex-direction: column; gap: 4px; }
.version-item {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.version-item:hover { background: #334155; }

.editor-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  font-weight: 500;
}
.editor-area { flex: 1; overflow: hidden; }
.editor-area textarea { width: 100%; height: 100%; border: none; padding: 12px; font-size: 14px; }
.CodeMirror { height: 100% !important; }

.preview-area { width: 480px; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  font-weight: 500;
}
.preview-frame { flex: 1; border: none; background: #fff; }

/* ===== API Docs ===== */
.api-doc-container { max-width: 900px; }
.api-doc-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.api-doc-content { background: #fff; border-radius: 12px; padding: 40px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.api-doc-content h2 { font-size: 24px; margin-bottom: 20px; color: #1e293b; }
.api-doc-content h3 { font-size: 18px; margin: 24px 0 12px; color: #334155; }
.api-doc-content h4 { font-size: 15px; margin: 20px 0 8px; color: #475569; }
.api-doc-content p { margin-bottom: 10px; line-height: 1.7; color: #475569; }
.api-doc-content ul { margin: 8px 0 12px 20px; }
.api-doc-content li { margin-bottom: 6px; line-height: 1.7; color: #475569; }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 13px; }
.table th { background: #f8fafc; font-weight: 600; color: #334155; }
.table td { color: #475569; }
.table td code { font-size: 12px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.editor-sidebar::-webkit-scrollbar-thumb { background: #475569; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .project-grid { grid-template-columns: 1fr; }
  .editor-sidebar { width: 200px; }
  .preview-area { display: none; }
}

/* ===== Accessibility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #6366f1;
  color: white;
  padding: 8px 16px;
  z-index: 1000;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: -2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}
