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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --secondary: #0ea5e9;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-dark: #0f172a;
  --bg-dark-card: #1e293b;
  --text: #1e293b;
  --text-light: #64748b;
  --text-dark: #f1f5f9;
  --text-dark-light: #94a3b8;
  --border: #e2e8f0;
  --border-dark: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

html { scroll-behavior: smooth; }

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

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

img { max-width: 100%; height: auto; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary); color: white; }

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

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }

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

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

.navbar-brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand i { color: var(--primary); font-size: 26px; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.navbar-links a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--primary);
  background: rgba(99,102,241,0.08);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
}

/* ============ HERO ============ */
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 80px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero p {
  font-size: 18px;
  opacity: 0.9;
  margin-bottom: 32px;
  line-height: 1.7;
}

.hero .btn {
  background: white;
  color: var(--primary-dark);
}
.hero .btn:hover { background: var(--primary-light); color: white; }

/* ============ POSTS GRID ============ */
.section {
  padding: 60px 0;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.section-subtitle {
  color: var(--text-light);
  margin-bottom: 40px;
  font-size: 16px;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
}

.post-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
  cursor: pointer;
}

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

.post-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 48px;
}

.post-card-body {
  padding: 24px;
}

.post-card-category {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.post-card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
  color: var(--text);
}

.post-card-excerpt {
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-light);
}

.post-card-meta i { margin-right: 4px; }

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.post-card-tags span {
  padding: 2px 10px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-light);
}

/* ============ FEATURED POSTS ============ */
.featured-section {
  background: var(--bg-dark);
  color: var(--text-dark);
  padding: 60px 0;
}

.featured-section .section-title { color: var(--text-dark); }
.featured-section .section-subtitle { color: var(--text-dark-light); }

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
}

.featured-card {
  background: var(--bg-dark-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-dark);
  transition: var(--transition);
  cursor: pointer;
}

.featured-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.featured-card-image {
  height: 180px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
}

.featured-card-body {
  padding: 24px;
}

.featured-card-body h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.featured-card-body p {
  color: var(--text-dark-light);
  font-size: 14px;
  line-height: 1.6;
}

.featured-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  color: #1e293b;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ============ ABOUT SECTION ============ */
.about-section {
  padding: 80px 0;
  background: var(--bg-card);
}

.about-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.about-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 48px;
  color: white;
}

.about-content h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.about-content p {
  color: var(--text-light);
  font-size: 16px;
  line-height: 1.8;
  max-width: 600px;
  margin: 0 auto 24px;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.social-links a {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 18px;
  transition: var(--transition);
}

.social-links a:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* ============ CATEGORIES ============ */
.categories-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 40px;
  justify-content: center;
}

.category-chip {
  padding: 8px 20px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.category-chip:hover,
.category-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============ POST DETAIL ============ */
.post-detail {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px;
}

.post-detail-header {
  margin-bottom: 32px;
}

.post-detail-header .post-card-category { margin-bottom: 16px; }

.post-detail h1 {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 16px;
}

.post-detail-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.post-detail-cover {
  width: 100%;
  height: 400px;
  border-radius: var(--radius);
  object-fit: cover;
  margin-bottom: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 64px;
}

.post-content {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
}

.post-content h2 { font-size: 24px; margin: 32px 0 16px; }
.post-content h3 { font-size: 20px; margin: 24px 0 12px; }
.post-content p { margin-bottom: 16px; }
.post-content ul, .post-content ol { margin-bottom: 16px; padding-left: 24px; }
.post-content li { margin-bottom: 8px; }
.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 16px 24px;
  margin: 24px 0;
  background: rgba(99,102,241,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}
.post-content code {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
}
.post-content pre {
  background: var(--bg-dark);
  color: var(--text-dark);
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 24px 0;
}
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content img { border-radius: var(--radius-sm); margin: 24px 0; }

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.post-tags span {
  padding: 6px 16px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-light);
}

/* ============ CONTACT ============ */
.contact-section {
  padding: 60px 0;
  background: var(--bg-card);
}

.contact-form {
  max-width: 600px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 20px;
}

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

.form-input, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-card);
  color: var(--text);
}

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

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

.form-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 4px;
}

.form-success {
  text-align: center;
  padding: 40px;
  color: #22c55e;
}

.form-success i { font-size: 48px; margin-bottom: 16px; }
.form-success h3 { font-size: 24px; margin-bottom: 8px; color: var(--text); }

/* ============ SEARCH ============ */
.search-bar {
  max-width: 500px;
  margin: 0 auto 40px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 2px solid var(--border);
  border-radius: 50px;
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-card);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.search-bar i {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
}

.pagination button {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  color: var(--text);
}

.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ FOOTER ============ */
.footer {
  background: var(--bg-dark);
  color: var(--text-dark-light);
  padding: 40px 0;
  text-align: center;
}

.footer p { font-size: 14px; }

/* ============ ADMIN PANEL ============ */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 70px);
}

.admin-sidebar {
  width: 260px;
  background: var(--bg-dark);
  padding: 24px 0;
  flex-shrink: 0;
}

.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text-dark-light);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: rgba(99,102,241,0.1);
  color: var(--primary-light);
}

.admin-sidebar a i { width: 20px; text-align: center; }

.admin-content {
  flex: 1;
  padding: 32px;
  background: var(--bg);
}

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

.admin-header h2 { font-size: 24px; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.stat-card h3 { font-size: 14px; color: var(--text-light); margin-bottom: 8px; }
.stat-card .stat-number { font-size: 32px; font-weight: 800; color: var(--text); }
.stat-card .stat-icon { font-size: 24px; color: var(--primary); margin-bottom: 8px; }

.admin-table {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table .actions {
  display: flex;
  gap: 8px;
}

.admin-table .actions button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.admin-table .actions .btn-edit { background: rgba(99,102,241,0.1); color: var(--primary); }
.admin-table .actions .btn-edit:hover { background: var(--primary); color: white; }
.admin-table .actions .btn-delete { background: rgba(239,68,68,0.1); color: #ef4444; }
.admin-table .actions .btn-delete:hover { background: #ef4444; color: white; }

/* ============ MODAL ============ */
.modal-overlay {
  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: 200;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h3 { font-size: 20px; font-weight: 700; margin-bottom: 24px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============ LOGIN ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-card p {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card .form-group { margin-bottom: 20px; }
.login-card .btn { width: 100%; justify-content: center; }

.login-error {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
}

/* ============ LOADING ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-light);
}

.loading i { font-size: 32px; animation: spin 1s linear infinite; }

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

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

.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* ============ TOGGLE SWITCH ============ */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .navbar-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    flex-direction: column;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }

  .navbar-links.open { display: flex; }
  .navbar-toggle { display: block; }

  .hero h1 { font-size: 32px; }
  .hero p { font-size: 16px; }
  .hero { padding: 60px 0; }

  .posts-grid { grid-template-columns: 1fr; }
  .featured-grid { grid-template-columns: 1fr; }

  .post-detail h1 { font-size: 26px; }
  .post-detail-cover { height: 250px; }

  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    padding: 12px 0;
    display: flex;
    overflow-x: auto;
  }
  .admin-sidebar a { white-space: nowrap; padding: 10px 16px; }
  .admin-content { padding: 20px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero h1 { font-size: 26px; }
  .section-title { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr; }
}