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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #202124;
  --text-light: #5f6368;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

/* Header */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
}

.logo span {
  color: var(--text);
}

nav a {
  color: var(--text-light);
  text-decoration: none;
  margin-left: 24px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}

nav a:hover, nav a.active {
  color: var(--primary);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
}

/* Ad Banner */
.ad-banner {
  background: #f0f4ff;
  border: 2px dashed #c4d7ff;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 24px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-banner.has-ad {
  border-style: solid;
  background: transparent;
  padding: 0;
}

.ad-banner.has-ad > * {
  width: 100%;
}

/* Featured Post */
.featured-post {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.featured-post .post-img {
  height: 320px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 3rem;
  font-weight: 800;
}

.featured-post .post-body {
  padding: 32px;
}

.featured-post .category {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 12px;
}

.featured-post h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  line-height: 1.3;
}

.featured-post h2 a {
  color: var(--text);
  text-decoration: none;
}

.featured-post h2 a:hover {
  color: var(--primary);
}

.featured-post .meta {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.featured-post .excerpt {
  color: var(--text-light);
  font-size: 1rem;
}

/* Post Grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.post-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.post-card .card-img {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
}

.card-content {
  padding: 20px;
}

.card-content .category {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-content h3 {
  font-size: 1.15rem;
  margin: 8px 0;
  line-height: 1.4;
}

.card-content h3 a {
  color: var(--text);
  text-decoration: none;
}

.card-content h3 a:hover {
  color: var(--primary);
}

.card-content .meta {
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
}

.sidebar-widget {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.sidebar-widget h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.sidebar-widget ul {
  list-style: none;
}

.sidebar-widget ul li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-widget ul li:last-child {
  border-bottom: none;
}

.sidebar-widget ul li a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.sidebar-widget ul li a:hover {
  color: var(--primary);
}

/* Ad in Sidebar */
.sidebar-ad {
  background: #f9f9fb;
  border: 2px dashed #ddd;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.sidebar-ad.has-ad {
  border-style: solid;
  background: transparent;
  padding: 0;
}

.sidebar-ad.has-ad > * {
  width: 100%;
}

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

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--text);
}

/* Footer */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 32px 24px;
  color: var(--text-light);
  font-size: 0.9rem;
}

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

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

.post-header .category {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 16px;
}

.post-header h1 {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 12px;
}

.post-header .meta {
  color: var(--text-light);
  font-size: 0.9rem;
}

.post-header .meta span {
  margin-right: 16px;
}

.post-featured-img {
  height: 400px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 4rem;
  font-weight: 800;
  margin-bottom: 32px;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content p {
  margin-bottom: 20px;
}

.post-content h2 {
  font-size: 1.4rem;
  margin: 32px 0 16px;
}

.post-content h3 {
  font-size: 1.2rem;
  margin: 24px 0 12px;
}

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

.post-content li {
  margin-bottom: 8px;
}

.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 20px;
  margin: 24px 0;
  color: var(--text-light);
  font-style: italic;
}

.post-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 24px 0;
}

.in-article-ad {
  background: #f9f9fb;
  border: 2px dashed #ddd;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0;
}

.in-article-ad.has-ad {
  border-style: solid;
  background: transparent;
  padding: 0;
}

/* ======================= */
/* ADMIN PANEL             */
/* ======================= */
.admin-body {
  background: #f0f2f5;
}

.admin-header {
  background: #1a1a2e;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header .logo {
  color: #fff;
}

.admin-header .logo span {
  color: #aaa;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.admin-user button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.admin-user button:hover {
  background: rgba(255,255,255,0.25);
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

.admin-sidebar {
  background: #16213e;
  padding: 16px 0;
}

.admin-sidebar a {
  display: block;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  color: #fff;
  background: rgba(255,255,255,0.05);
  border-left-color: var(--primary);
}

.admin-main {
  padding: 32px;
}

.admin-main h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
}

/* Admin Forms */
.admin-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

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

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

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

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-danger:hover {
  background: #b02a37;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

/* Post List */
.post-list {
  width: 100%;
  border-collapse: collapse;
}

.post-list th,
.post-list td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.post-list th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.post-list tr:hover td {
  background: #f8f9fa;
}

.post-list .actions {
  display: flex;
  gap: 8px;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}

.login-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  padding: 40px;
  width: 400px;
}

.login-box h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.login-box p {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 24px;
}

.login-box .error {
  color: #dc3545;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 16px;
  display: none;
}

/* Tab System */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
  }

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

  nav a {
    margin: 0 8px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    display: flex;
    overflow-x: auto;
    padding: 0;
  }

  .admin-sidebar a {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    padding: 12px 16px;
  }

  .admin-sidebar a:hover,
  .admin-sidebar a.active {
    border-left-color: transparent;
    border-bottom-color: var(--primary);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

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

  .featured-post .post-img {
    height: 200px;
  }

  .post-featured-img {
    height: 200px;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 24px;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  z-index: 999;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.notification.success {
  background: #28a745;
}

.notification.error {
  background: #dc3545;
}

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