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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --error: #ef4444;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow: 0 4px 20px rgba(0,0,0,0.07);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.09);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.logo span { color: var(--muted); font-weight: 500; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: #fee2e2;
  color: var(--error);
  border: 1.5px solid #fecaca;
}
.btn-danger:hover { background: var(--error); color: white; border-color: var(--error); }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-full { width: 100%; }

/* ===== HERO ===== */
.hero {
  padding: 80px 24px 72px;
  text-align: center;
  background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-inner { max-width: 640px; margin: 0 auto; }

.hero-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 32px;
  line-height: 1.7;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
  flex: 1;
}

.section-header { margin-bottom: 32px; }
.section-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ===== POSTS GRID ===== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
  overflow: hidden;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.post-card-body { padding: 28px 28px 16px; flex: 1; }

.post-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--primary); }

.post-card-excerpt {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  padding: 16px 28px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.meta-author { font-weight: 600; color: var(--text); }
.meta-dot { opacity: 0.4; }

.read-more {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}
.read-more:hover { color: var(--primary-hover); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; color: var(--text); margin-bottom: 8px; }

/* ===== POST DETAIL ===== */
.post-container {
  max-width: 740px;
  margin: 0 auto;
  padding: 48px 24px;
  flex: 1;
}

.post-back { margin-bottom: 32px; }
.back-link { font-size: 0.9rem; font-weight: 600; color: var(--muted); transition: color 0.15s; }
.back-link:hover { color: var(--primary); }

.post-header { margin-bottom: 40px; }

.post-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.post-lead {
  font-size: 1.15rem;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
  color: #1e293b;
}
.post-content p { margin-bottom: 1.4em; }
.post-content h2 { font-size: 1.5rem; font-weight: 700; margin: 2em 0 0.75em; }
.post-content h3 { font-size: 1.2rem; font-weight: 700; margin: 1.8em 0 0.6em; }
.post-content ul, .post-content ol { margin: 1em 0 1em 1.5em; }
.post-content li { margin-bottom: 0.4em; }
.post-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 12px 20px;
  margin: 1.5em 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
  font-style: italic;
}
.post-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Courier New', monospace;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-wrapper.reverse { direction: rtl; }
.auth-wrapper.reverse > * { direction: ltr; }

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--surface);
}

.auth-container { width: 100%; max-width: 400px; }

.auth-container h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-subtitle { color: var(--muted); margin-bottom: 32px; font-size: 0.95rem; }

.auth-footer { margin-top: 24px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.auth-footer a { color: var(--primary); font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

.auth-banner-side {
  background: linear-gradient(145deg, #4f46e5 0%, #7c3aed 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.banner-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px;
  animation: scrollUp 15s linear infinite;
}

@keyframes scrollUp {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

.banner-card {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 24px;
  color: white;
}
.banner-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.banner-card p { font-size: 0.85rem; opacity: 0.85; line-height: 1.5; }

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

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

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-group input.invalid { border-color: var(--error); }
.form-group input.invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }

.field-error {
  display: none;
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 5px;
  font-weight: 500;
}

.input-lg { font-size: 1.05rem; padding: 14px 16px; }
.label-hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.required { color: var(--error); }

/* ===== FLASH MESSAGES ===== */
.flash { padding: 14px 24px; font-size: 0.9rem; font-weight: 500; text-align: center; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

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

.toast {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}
.toast.success { background: #166534; color: white; }
.toast.error { background: #7f1d1d; color: white; }

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

/* ===== DASHBOARD ===== */
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.dashboard-header h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.5px; }
.dashboard-header h1 span { color: var(--primary); }
.text-muted { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }

.dashboard-stats { display: flex; gap: 16px; margin-bottom: 40px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 32px;
  min-width: 140px;
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

.posts-table-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }

.posts-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.posts-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.posts-table-row:last-child { border-bottom: none; }
.posts-table-row:hover { background: var(--bg); }

.posts-table-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }

.posts-table-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.posts-table-title:hover { color: var(--primary); }
.posts-table-date { font-size: 0.8rem; color: var(--muted); }
.posts-table-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== EDITOR ===== */
.editor-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px;
  flex: 1;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}
.editor-header h1 { font-size: 1.6rem; font-weight: 800; }

.editor-textarea { min-height: 360px; resize: vertical; line-height: 1.7; font-size: 1rem; }
.textarea-hint { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.editor-actions { display: flex; gap: 12px; margin-top: 32px; }

/* ===== FOOTER ===== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .posts-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .posts-grid { grid-template-columns: 1fr; }
  .hero { padding: 56px 20px 48px; }
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-wrapper.reverse { direction: ltr; }
  .auth-banner-side { display: none; }
  .auth-form-side { padding: 40px 24px; min-height: 100vh; }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
  .posts-table-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .posts-table-actions { align-self: flex-end; }
  .editor-actions { flex-direction: column; }
  .editor-actions .btn { width: 100%; }
  .navbar-inner { padding: 0 16px; }
  .container { padding: 32px 16px; }
  .post-container { padding: 32px 16px; }
}

@media (max-width: 480px) {
  .nav-links .nav-link { display: none; }
}
