* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-bg: rgba(79, 70, 229, 0.08);
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --success: #059669;
  --success-light: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --bg: #f1f5f9;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.95);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.logo-text {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.logo-text strong {
  font-weight: 700;
}

/* Search */
.search-box {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 80px 9px 40px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--bg-subtle);
  color: var(--text);
  transition: all var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
  background: var(--surface);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: inherit;
  pointer-events: none;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#userInfo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-xs);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

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

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ===== MAIN ===== */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
  flex: 1;
}

.page {
  display: none;
  animation: fadeIn 0.25s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--primary-hover);
}

.breadcrumb .fa-chevron-right {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Page Header */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== HERO ===== */
.hero-section {
  background: linear-gradient(135deg, rgba(79,70,229,0.85) 0%, rgba(8,145,178,0.8) 100%),
              url('/images/hero-bg.png') center/cover no-repeat;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  margin-bottom: 28px;
  border: none;
  position: relative;
  overflow: hidden;
  color: white;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  border-radius: 50%;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: white;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hero-subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ===== CATEGORIES GRID ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.category-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.category-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.category-card:hover::after {
  opacity: 1;
}

.category-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.category-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.category-count {
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

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

.category-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.category-admin-btns {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Category Page Header */
.category-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* ===== ARTICLES LIST ===== */
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.article-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}

.article-item-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.article-item-info .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.article-item-arrow {
  color: var(--text-muted);
  transition: all var(--transition);
  font-size: 0.85rem;
}

.article-item:hover .article-item-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

/* ===== ARTICLE VIEW ===== */
.article-header {
  margin-bottom: 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.date {
  color: var(--text-muted);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.article-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.3;
  margin-bottom: 8px;
}

.article-admin-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Article Content */
.article-content {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  line-height: 1.85;
  font-size: 1rem;
  color: var(--text);
  box-shadow: var(--shadow);
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 32px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  letter-spacing: -0.01em;
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text);
}

.article-content p {
  margin-bottom: 14px;
}

.article-content ul, .article-content ol {
  margin: 10px 0 16px 28px;
}

.article-content li {
  margin-bottom: 6px;
}

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

.article-content a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(79, 70, 229, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--transition);
}

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

.article-content pre, .article-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.article-content code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--primary);
}

.article-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 16px 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.article-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}

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

.article-content table th,
.article-content table td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.article-content table th {
  background: var(--bg);
  font-weight: 600;
}

.article-content table tr:hover td {
  background: var(--bg-subtle);
}

.article-content blockquote {
  border-left: 4px solid var(--primary);
  margin: 16px 0;
  padding: 12px 20px;
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

/* ===== LOGIN ===== */
.login-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.login-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--primary);
  font-size: 1.3rem;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.login-card form {
  text-align: left;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group label i {
  margin-right: 4px;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.icon-input {
  max-width: 80px;
  text-align: center;
  font-size: 1.5rem !important;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
  min-height: 20px;
}

/* ===== EDITOR ===== */
.editor-form {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.editor-top-row {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  gap: 2px;
}

.toolbar button {
  padding: 7px 10px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.toolbar button:hover {
  background: var(--border);
  color: var(--text);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.rich-editor {
  min-height: 450px;
  padding: 20px;
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 1rem;
  line-height: 1.8;
  outline: none;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
}

.rich-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.rich-editor img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

.rich-editor h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 20px 0 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}

.rich-editor h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 16px 0 6px;
}

.rich-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.rich-editor table th,
.rich-editor table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.rich-editor table th {
  background: var(--bg);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: var(--shadow-xl);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 380px;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.toast.removing {
  animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100px); opacity: 0; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.empty-state-icon i {
  font-size: 1.8rem;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 4px;
}

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

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  background: var(--surface);
  margin-top: auto;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-sep {
  margin: 0 8px;
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    gap: 10px;
  }

  .search-box {
    max-width: none;
    flex: 1;
  }

  .search-hint {
    display: none;
  }

  .logo-text {
    display: none;
  }

  .user-name {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .hero-section {
    padding: 28px 24px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

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

  .article-content {
    padding: 24px 20px;
  }

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

  .editor-top-row {
    flex-direction: column;
  }

  .hero-actions {
    flex-direction: column;
  }

  .category-header-row {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0 12px;
  }

  .main {
    padding: 12px;
  }

  .hero-section {
    padding: 24px 20px;
    border-radius: var(--radius);
  }

  .article-content {
    padding: 20px 16px;
    border-radius: var(--radius);
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== SELECTION ===== */
::selection {
  background: rgba(79, 70, 229, 0.15);
  color: var(--text);
}
