/* ============================
   MyMD Design System
   Notion/Medium inspired
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --color-bg: #ffffff;
  --color-surface: #f8f9fa;
  --color-surface-hover: #f1f3f5;
  --color-border: #e9ecef;
  --color-border-light: #f1f3f5;
  --color-text: #1a1a2e;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-danger-light: #fef2f2;
  --color-success: #10b981;
  --color-code-bg: #f6f8fa;
  --color-blockquote-border: #e5e7eb;
  --color-blockquote-bg: #f9fafb;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  min-height: 100vh;
}

/* ============================
   Article Reader Styles
   ============================ */

.article-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 24px 120px;
}

.article-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--color-border-light);
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  transition: color var(--transition);
}

.article-back:hover {
  color: var(--color-accent);
}

.article-title {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

/* Article content typography */
.article-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 48px 0 16px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 40px 0 14px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.article-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 32px 0 12px;
  line-height: 1.4;
}

.article-content h4, .article-content h5, .article-content h6 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 24px 0 10px;
}

.article-content p {
  margin-bottom: 20px;
  font-size: 1.075rem;
  line-height: 1.8;
}

.article-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}

.article-content a:hover {
  text-decoration-color: var(--color-accent);
}

.article-content strong {
  font-weight: 600;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 24px 0;
  box-shadow: var(--shadow-md);
}

.article-content ul, .article-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

.article-content li {
  margin-bottom: 8px;
  font-size: 1.075rem;
  line-height: 1.7;
}

.article-content li::marker {
  color: var(--color-text-muted);
}

.article-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 3px solid var(--color-accent);
  background: var(--color-blockquote-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: 40px 0;
}

/* Code styles */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: #e11d48;
}

.article-content pre {
  margin: 24px 0;
  background: #1e293b;
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}

.article-content pre code {
  display: block;
  padding: 20px 24px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e2e8f0;
  background: none;
  border-radius: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.article-content thead th {
  background: var(--color-surface);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--color-border);
}

.article-content tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.article-content tbody tr:hover {
  background: var(--color-surface);
}

/* ============================
   Admin Panel Styles
   ============================ */

.admin-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

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

.admin-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-accent), #7c3aed);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  margin-bottom: 40px;
  transition: all var(--transition);
  cursor: pointer;
  background: var(--color-bg);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.upload-zone-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
  transition: opacity var(--transition);
}

.upload-zone:hover .upload-zone-icon,
.upload-zone.dragover .upload-zone-icon {
  opacity: 0.7;
}

.upload-zone h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.upload-zone p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* Articles list */
.articles-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.articles-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.article-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.article-item:hover {
  background: var(--color-surface-hover);
}

.article-info {
  flex: 1;
  min-width: 0;
}

.article-slug-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.article-slug {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-slug-link {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: color var(--transition);
}

.article-slug-link:hover {
  color: var(--color-accent-hover);
}

.article-original {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.article-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn-danger {
  background: transparent;
  color: var(--color-text-muted);
  padding: 6px 10px;
}

.btn-danger:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Slug edit input */
.slug-edit-input {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 4px 8px;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  outline: none;
  background: white;
  color: var(--color-text);
  width: 200px;
}

/* Copy tooltip */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: all 300ms ease;
  pointer-events: none;
  z-index: 1000;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 404 */
.not-found {
  text-align: center;
  padding: 120px 24px;
}

.not-found h1 {
  font-size: 6rem;
  font-weight: 700;
  color: var(--color-border);
  line-height: 1;
  margin-bottom: 16px;
}

.not-found h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.not-found p {
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

/* Upload progress */
.upload-progress {
  margin-top: 16px;
  display: none;
}

.upload-progress.visible {
  display: block;
}

.progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 300ms ease;
  width: 0%;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 640px) {
  .article-wrapper {
    padding: 32px 16px 80px;
  }

  .article-title {
    font-size: 1.75rem;
  }

  .article-content h1 { font-size: 1.5rem; }
  .article-content h2 { font-size: 1.25rem; }
  .article-content h3 { font-size: 1.1rem; }
  .article-content p, .article-content li { font-size: 1rem; }

  .admin-wrapper {
    padding: 24px 16px 60px;
  }

  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .upload-zone {
    padding: 32px 16px;
  }

  .article-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .article-actions {
    margin-left: 0;
  }
}
