/* ============================================================
   Typie — Modern Blog CSS
   A clean, beautiful design system for a personal blog
   ============================================================ */

/* ========== CSS Variables ========== */
:root {
  /* Color palette */
  --bg: #fefefe;
  --bg-secondary: #f3f4f6;
  --bg-tertiary: #e5e7eb;
  --surface: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;

  /* Brand */
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --accent: #f59e0b;
  --accent-bg: #fffbeb;

  /* Semantic */
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;

  /* Spacing & sizing */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px rgba(0,0,0,.06), 0 4px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px rgba(0,0,0,.08), 0 8px 10px rgba(0,0,0,.04);
  --shadow-xl: 0 25px 50px rgba(0,0,0,.1);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --max-width: 820px;
  --max-width-admin: 1100px;

  /* Code */
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;

  /* Transitions */
  --transition: 200ms ease;
  --transition-slow: 350ms ease;
}

/* ========== Dark Mode ========== */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --primary-bg: #1e1b4b;
  --accent-bg: #451a03;
  --success-bg: #064e3b;
  --danger-bg: #450a0a;
  --warning-bg: #451a03;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow: 0 4px 6px rgba(0,0,0,.25);
  --shadow-md: 0 10px 15px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 25px rgba(0,0,0,.35);
  --shadow-xl: 0 25px 50px rgba(0,0,0,.4);
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-dark); }

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

video {
  max-width: 100%;
  border-radius: var(--radius);
}

::selection {
  background: var(--primary-light);
  color: white;
}

/* ========== Container ========== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

.admin-body .container {
  max-width: var(--max-width-admin);
}

/* ========== Navbar ========== */
.navbar {
  background: rgba(254, 254, 254, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all var(--transition);
}

[data-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.85);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  transition: color var(--transition);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-bg);
  text-decoration: none;
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-toggle { cursor: default; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  padding: 6px;
  animation: fadeInDown 0.2s ease;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  font-size: .88rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.dropdown-menu a:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ========== Main Content ========== */
main {
  flex: 1;
  padding: 40px 0 80px;
}

/* ========== Hero ========== */
.hero {
  text-align: center;
  padding: 60px 0 40px;
  position: relative;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
}
.hero h1 {
  font-size: 2.6rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-desc {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 400;
  max-width: 500px;
  margin: 0 auto;
}

/* ========== Category Filter ========== */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
  justify-content: center;
}
.filter-tag {
  padding: 8px 20px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  background: var(--surface);
}
.filter-tag:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  background: var(--primary-bg);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.filter-tag.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow);
}

/* ========== Article Cards ========== */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--accent));
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.article-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}
.article-card:hover::before { opacity: 1; }

.article-cover {
  margin: -28px -32px 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}
.article-cover img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: 0;
  transition: transform var(--transition-slow);
}
.article-card:hover .article-cover img {
  transform: scale(1.03);
}

.article-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.35;
  letter-spacing: -0.3px;
}
.article-title a {
  color: var(--text);
  transition: color var(--transition);
}
.article-title a:hover {
  color: var(--primary);
  text-decoration: none;
}

.article-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--text-secondary);
  font-size: .88rem;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.category-badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 4px 14px;
  border-radius: 100px;
  font-size: .8rem;
  font-weight: 600;
  transition: all var(--transition);
}
.category-badge:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}

.article-excerpt {
  color: var(--text-secondary);
  font-size: .95rem;
  margin-bottom: 16px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.article-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: .8rem;
  color: var(--text-tertiary);
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--bg-secondary);
  transition: all var(--transition);
  font-weight: 500;
}
.tag:hover {
  color: var(--primary);
  background: var(--primary-bg);
  text-decoration: none;
}

.read-more {
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--primary);
  padding: 6px 16px;
  border-radius: 100px;
  transition: all var(--transition);
  border: 1.5px solid transparent;
}
.read-more:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  text-decoration: none;
}

/* ========== Article Detail ========== */
.article-detail { padding-top: 10px; }

.article-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.article-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.3;
  letter-spacing: -0.8px;
}
.article-header .article-meta { margin-bottom: 16px; font-size: .9rem; }
.updated-at {
  font-size: .82rem;
  color: var(--text-tertiary);
  font-style: italic;
}

/* Article content — rich typography */
.article-content {
  font-size: 1.08rem;
  line-height: 1.9;
  color: var(--text);
}

.article-content h1, .article-content h2, .article-content h3,
.article-content h4, .article-content h5, .article-content h6 {
  margin-top: 2em;
  margin-bottom: .6em;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.3px;
  scroll-margin-top: 80px;
}
.article-content h2 {
  font-size: 1.55rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  margin-top: 2.2em;
}
.article-content h3 { font-size: 1.25rem; color: var(--text); }
.article-content h4 { font-size: 1.1rem; }
.article-content p { margin-bottom: 1.2em; }
.article-content ul, .article-content ol {
  margin-bottom: 1.2em;
  padding-left: 1.8em;
}
.article-content li { margin-bottom: .4em; }
.article-content li::marker { color: var(--primary-light); }
.article-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 16px 24px;
  margin: 1.4em 0;
  background: var(--primary-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
  position: relative;
}
.article-content blockquote::before {
  content: '"';
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 2.5rem;
  color: var(--primary-light);
  opacity: 0.3;
  line-height: 1;
  font-style: normal;
}
.article-content code {
  background: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: .9em;
  font-family: var(--font-mono);
  color: var(--primary-dark);
  font-weight: 500;
}
.article-content pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 20px 24px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.3em;
  line-height: 1.6;
  box-shadow: var(--shadow-md);
  position: relative;
}
.article-content pre code {
  background: none;
  padding: 0;
  font-size: .88rem;
  color: inherit;
  font-weight: 400;
}
.article-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.3em;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.article-content th, .article-content td {
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  text-align: left;
}
.article-content th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.article-content tr:last-child td { border-bottom: none; }
.article-content tr:hover td { background: var(--bg-secondary); }
.article-content hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 2.5em 0;
}
.article-content a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--primary-light);
  text-underline-offset: 3px;
  word-break: break-all;
}
.article-content a:hover {
  color: var(--primary-dark);
  text-decoration-color: var(--primary);
}
.article-content img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1em 0;
}
.article-content video {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1em 0;
}

.article-nav {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
  display: flex;
  gap: 20px;
}
.back-link {
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.back-link:hover { color: var(--primary); }

/* ========== Search ========== */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 36px;
}
.search-form input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: 100px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.search-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
.search-form button {
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all var(--transition);
  box-shadow: var(--shadow);
}
.search-form button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  opacity: 0.95;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.page-btn {
  padding: 10px 24px;
  border: 2px solid var(--border);
  border-radius: 100px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--transition);
  background: var(--surface);
}
.page-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.page-info {
  font-size: .88rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========== Footer ========== */
footer {
  text-align: center;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .85rem;
  background: var(--bg-secondary);
  margin-top: auto;
}
footer a {
  font-weight: 600;
  color: var(--primary);
}

/* ========== Page Header ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1, .page-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.page-header p {
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========== 404 ========== */
.page-not-found {
  text-align: center;
  padding: 100px 0;
}
.page-not-found h1 {
  font-size: 7rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 16px;
}
.page-not-found p {
  margin: 20px 0;
  font-size: 1.15rem;
  color: var(--text-secondary);
}
.page-not-found a {
  font-weight: 600;
  font-size: 1rem;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ============================================================
   ADMIN STYLES
   ============================================================ */

.admin-navbar {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  border-bottom: none;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.admin-navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.admin-navbar .logo {
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  -webkit-text-fill-color: white;
  background: none;
}
.admin-navbar .logo:hover {
  -webkit-text-fill-color: var(--primary-light);
  background: none;
}
.admin-navbar .nav-links a {
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
}
.admin-navbar .nav-links a:hover {
  color: white;
  background: rgba(255,255,255,.1);
}

.admin-body {
  background: var(--bg-secondary);
  min-height: 100vh;
}

/* ========== Dashboard ========== */
.dashboard h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 28px;
  letter-spacing: -0.3px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card:hover::after { opacity: 1; }
.stat-number {
  font-size: 2.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
}
.stat-label {
  font-size: .85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 24px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
  text-align: center;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  box-shadow: var(--shadow-md);
  opacity: 0.95;
  color: white;
}
.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}
.btn-danger {
  color: var(--danger);
  border-color: var(--danger-bg);
  background: var(--surface);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-sm {
  padding: 6px 14px;
  font-size: .82rem;
  border-radius: var(--radius-sm);
}

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: .88rem;
  color: var(--text);
}
.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: .8rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}
.form-group input::placeholder, .form-group textarea::placeholder {
  color: var(--text-tertiary);
}
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.flex-grow { flex: 1; }

/* ========== Data Table ========== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.data-table th, .data-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: .9rem;
}
.data-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-secondary); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .actions {
  white-space: nowrap;
  display: flex;
  gap: 8px;
}
.data-table .actions form { margin: 0; }
.empty-cell {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px !important;
  font-size: .95rem;
}
.data-table input[type="text"],
.data-table input[type="number"] {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  transition: border-color var(--transition);
}
.data-table input[type="text"]:focus,
.data-table input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========== Badges ========== */
.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-success {
  background: var(--success-bg);
  color: var(--success);
}
.badge-draft {
  background: var(--warning-bg);
  color: var(--warning);
}

/* ========== Alerts ========== */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .9rem;
  font-weight: 500;
  border: 1px solid transparent;
  animation: fadeInDown .3s ease;
}
.alert-success {
  background: var(--success-bg);
  color: #065f46;
  border-color: #a7f3d0;
}
.alert-error {
  background: var(--danger-bg);
  color: #991b1b;
  border-color: #fecaca;
}

/* ========== Card ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card h3 {
  margin-bottom: 18px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.inline-form { display: inline; }

/* ========== Editor ========== */
.editor-form { margin-top: 16px; }

.editor-container {
  display: flex;
  gap: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 520px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition);
}
.editor-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

.editor-pane, .preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-pane { border-right: 1px solid var(--border); }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.editor-toolbar button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.editor-toolbar button:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

#editor {
  flex: 1;
  width: 100%;
  border: none;
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: .9rem;
  line-height: 1.7;
  resize: none;
  background: var(--surface);
  color: var(--text);
  min-height: 500px;
  tab-size: 2;
}
#editor:focus { outline: none; }

.preview-header {
  padding: 10px 18px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.preview-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-height: 500px;
  max-height: 750px;
  background: var(--surface);
}

.form-actions {
  display: flex;
  gap: 14px;
  padding-bottom: 48px;
}

/* ========== Media Grid ========== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.media-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.media-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
.media-video-placeholder {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  font-size: .85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 12px;
  gap: 6px;
}
.media-info {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.media-name {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-size { font-size: .75rem; color: var(--text-secondary); }
.media-actions {
  padding: 0 14px 12px;
  display: flex;
  gap: 8px;
}

/* ========== Modal ========== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 750px;
  width: 92%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn .25s ease;
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text);
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ========== Login Page ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 70, 229, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(245, 158, 11, 0.05), transparent),
    var(--bg-secondary);
}
.login-container {
  background: var(--surface);
  padding: 48px 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  animation: scaleIn .4s ease;
}
.login-container h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.login-container::after {
  content: 'Typie';
  display: block;
  text-align: center;
  margin-top: 24px;
  font-size: .82rem;
  color: var(--text-tertiary);
  font-weight: 500;
}
.login-form { margin-top: 28px; }
.login-form .btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-top: 8px;
  border-radius: var(--radius);
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .hero h1 { font-size: 2rem; }
  .hero { padding: 40px 0 30px; }
  .article-header h1 { font-size: 1.7rem; }
  .article-content { font-size: 1rem; }
  .article-card { padding: 22px; }
}

@media (max-width: 768px) {
  .container { padding: 0 18px; }
  .nav-links { gap: 4px; }
  .nav-links a { font-size: .82rem; padding: 6px 10px; }
  .hero h1 { font-size: 1.7rem; }
  .hero { padding: 30px 0 20px; }
  .article-header h1 { font-size: 1.45rem; }
  .article-content { font-size: .98rem; }
  .editor-container { flex-direction: column; }
  .editor-pane { border-right: none; border-bottom: 1px solid var(--border); }
  .editor-pane, .preview-pane { min-height: 350px; }
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .admin-navbar .nav-links { flex-wrap: wrap; gap: 2px; }
  .admin-navbar .nav-links a { font-size: .78rem; padding: 5px 8px; }
  .data-table th, .data-table td { padding: 10px 12px; font-size: .82rem; }
  .login-container { padding: 32px 24px; max-width: 90%; }
  .search-form { flex-direction: column; }
  .search-form button { width: 100%; }
  footer { padding: 20px 16px; }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .navbar .container { height: 52px; }
  .logo { font-size: 1.15rem; }
  .article-card { padding: 18px; }
  .article-title { font-size: 1.15rem; }
  .data-table { font-size: .78rem; }
  .data-table th, .data-table td { padding: 8px; }
  .hero h1 { font-size: 1.5rem; }
  .article-header h1 { font-size: 1.3rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 18px 14px; }
  .stat-number { font-size: 2rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ========== Print Styles ========== */
@media print {
  .navbar, .admin-navbar, footer, .article-nav, .pagination, .search-form,
  .category-filter, .quick-actions, .form-actions, .editor-toolbar { display: none !important; }
  body { background: white; color: black; font-size: 13px; }
  .container { max-width: 100%; padding: 0; }
  .article-content { line-height: 1.6; }
  .article-content a { color: black; text-decoration: underline; }
}
