/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* Layout */
.container { width: 90%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.main { min-height: calc(100vh - 140px); padding: 40px 0; }

/* Header & Nav */
.header {
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
}
.nav {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 30px;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}
.nav-logo { font-size: 1.4em; font-weight: bold; color: #333; }
.nav-links { display: flex; gap: 25px; }
.nav-links a { color: #666; font-size: 0.95em; }
.nav-links a:hover { color: #0066cc; text-decoration: none; }

/* Posts - Grid Layout */
.page-title {
  font-size: 2em;
  margin-bottom: 30px;
  margin-left: -300px;
  color: #333;
}
.posts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-left: -300px;
  margin-right: -300px;
  width: calc(100% + 600px);
}

@media (min-width: 1400px) {
  .posts { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 1024px) and (max-width: 1399px) {
  .posts { grid-template-columns: repeat(3, 1fr); margin: 0; width: 100%; }
  .hero { margin-left: 0; margin-right: 0; width: 100%; }
  .page-title { margin-left: 0; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .posts { grid-template-columns: repeat(2, 1fr); margin: 0; width: 100%; }
  .hero { margin-left: 0; margin-right: 0; width: 100%; }
  .page-title { margin-left: 0; }
}

@media (max-width: 767px) {
  .posts { grid-template-columns: 1fr; }
}
.post-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 15px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #eee;
  display: flex;
  flex-direction: column;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.post-card .card-link {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}
.post-card {
  position: relative;
}
.post-card .post-cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
}
.post-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.post-content h2 {
  font-size: 1.15em;
  margin-bottom: 10px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-content h2 a { color: #333; }
.post-content h2 a:hover { color: #0066cc; text-decoration: none; }
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #999;
  font-size: 0.8em;
  margin-bottom: 12px;
}
.post-meta span { display: flex; align-items: center; gap: 5px; }
.post-meta a { color: #0066cc; }
.post-content p {
  color: #888;
  font-size: 0.9em;
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Single Post */
.post-detail {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.08);
}
.post-cover-large {
  width: 100%;
  max-height: 450px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 30px;
}
.post-title { font-size: 2.2em; margin-bottom: 15px; color: #222; }
.post-body { margin-top: 30px; line-height: 1.9; font-size: 1.1em; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  margin: 25px 0 15px;
  color: #222;
}
.post-body p { margin-bottom: 18px; }
.post-body img { border-radius: 8px; margin: 20px 0; }
.post-body pre {
  background: #1e1e1e;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0;
  position: relative;
}
.post-body pre code {
  display: block;
  padding: 20px;
  overflow-x: auto;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  line-height: 1.7;
  white-space: pre;
}
.post-body code {
  background: #f0f0f5;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  color: #d63384;
  border: 1px solid #ddd;
}
.post-body pre code { background: none; padding: 20px; color: #d4d4d4; }

/* Copy button */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2d2d2d;
  padding: 8px 15px;
  border-radius: 8px 8px 0 0;
}
.code-header span {
  color: #888;
  font-size: 0.85em;
}
.copy-btn {
  background: #4a4a4a;
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
}
.copy-btn:hover { background: #5a5a5a; }

/* Comments */
.comments { margin-top: 50px; background: #fff; border-radius: 12px; padding: 30px; }
.comments h3 { margin-bottom: 25px; font-size: 1.3em; }
.comment { padding: 20px 0; border-bottom: 1px solid #eee; }
.comment:last-child { border-bottom: none; }
.comment-author { font-weight: bold; color: #333; }
.comment-date { font-size: 0.8em; color: #999; margin: 5px 0; }
.comment-content { color: #555; line-height: 1.7; }
.comment-form { margin-bottom: 30px; }
.comment-form input, .comment-form textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 1em;
}
.comment-form textarea { resize: vertical; min-height: 120px; }
.comment-form button {
  background: #0066cc;
  color: #fff;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
}
.comment-form button:hover { background: #0052a3; }

/* Hero Section */
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 60px 0;
  margin-bottom: 40px;
  margin-left: -300px;
  margin-right: -300px;
  border-radius: 16px;
  text-align: center;
  width: calc(100% + 600px);
}

.hero h1 {
  font-size: 2.5em;
  margin-bottom: 15px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.hero p {
  font-size: 1.2em;
  opacity: 0.9;
}

/* Article Table */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 25px 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 15px rgba(0,0,0,0.08);
}
.post-body table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 14px 20px;
  text-align: left;
  font-weight: 600;
}
.post-body table td {
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
}
.post-body table tr:nth-child(even) {
  background: #f8f9fa;
}
.post-body table tr:hover {
  background: #f0f4ff;
}
.post-body table tr:last-child td {
  border-bottom: none;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 40px;
  padding: 20px;
}
.pagination a {
  background: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  color: #0066cc;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.pagination span { color: #666; }

/* Footer */
.footer {
  background: #fff;
  padding: 30px;
  text-align: center;
  color: #999;
  font-size: 0.9em;
}

/* Admin Sidebar - New Design */
.admin-sidebar {
  width: 240px;
  background: #1a1a2e;
  color: #fff;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-sidebar-header {
  padding: 25px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar-header h1 {
  font-size: 1.1em;
  font-weight: 600;
  color: #fff;
  margin: 0;
}
.admin-sidebar nav {
  flex: 1;
  padding: 15px 0;
}
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 0.95em;
  transition: all 0.2s;
}
.admin-sidebar nav a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.admin-sidebar nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.admin-sidebar-nav-icon {
  font-size: 1.1em;
  width: 24px;
  text-align: center;
}
.admin-sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 5px 0;
}
.admin-sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 10px 0;
}
.admin-sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 0.95em;
}
.admin-sidebar-footer a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.admin-sidebar-footer .logout-link {
  color: #ff6b6b;
}
.admin-sidebar-footer .logout-link:hover {
  background: rgba(255,107,107,0.15);
  color: #ff6b6b;
}
.admin-container {
  display: flex;
  min-height: 100vh;
}
.admin-main {
  flex: 1;
  padding: 30px 40px;
  background: #f4f5f7;
}
.admin-main h1 {
  margin-bottom: 25px;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 1.5em;
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 40px; }
.stat-card {
  background: #fff;
  padding: 25px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.stat-card h3 { font-size: 2.5em; color: #2c3e50; margin-bottom: 5px; }
.stat-card p { color: #7f8c8d; font-size: 0.9em; }

/* Admin Table */
.admin-table { width: 100%; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.admin-table th, .admin-table td { padding: 15px 20px; text-align: left; }
.admin-table th { background: #34495e; color: #fff; font-weight: 500; }
.admin-table tr:nth-child(even) { background: #f8f9fa; }
.admin-table a { margin-right: 15px; color: #0066cc; }

/* Buttons */
.btn {
  display: inline-block;
  background: #3498db;
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.9em;
}
.btn:hover { background: #2980b9; color: #fff; text-decoration: none; }
.btn-primary {
  background: #27ae60;
  color: #fff;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
}
.btn-primary:hover { background: #219a52; }
.error { color: #e74c3c; background: #fdf2f2; padding: 15px; border-radius: 8px; margin-bottom: 20px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #2c3e50; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
}
.form-group textarea { resize: vertical; min-height: 150px; }
.form-group .help { font-size: 0.85em; color: #999; margin-top: 5px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 15px; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: normal; }
.form-actions { display: flex; gap: 15px; margin-top: 30px; }
.inline-form { display: flex; gap: 10px; margin-bottom: 25px; background: #fff; padding: 20px; border-radius: 10px; }
.inline-form input { padding: 10px 15px; border: 1px solid #ddd; border-radius: 6px; }
.inline-form button { padding: 10px 20px; background: #3498db; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.settings-form { background: #fff; padding: 30px; border-radius: 10px; max-width: 600px; }

/* Login */
.login-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 5px 30px rgba(0,0,0,0.1);
}
.login-container h1 { text-align: center; margin-bottom: 30px; color: #2c3e50; }
.login-container input { width: 100%; padding: 15px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 1em; }
.login-container button { width: 100%; padding: 15px; background: #3498db; color: #fff; border: none; border-radius: 8px; font-size: 1em; cursor: pointer; }
.login-container button:hover { background: #2980b9; }

/* Disclaimer */
.disclaimer {
  margin-top: 30px;
  padding: 15px 20px;
  background: #f5f5f5;
  border-radius: 8px;
  color: #666;
  font-size: 0.9em;
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  .header { height: auto; }
  .nav { flex-direction: column; gap: 10px; padding: 12px 20px; }
  .nav-links { flex-wrap: wrap; justify-content: center; gap: 15px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .admin-container { flex-direction: column; }
  .sidebar { width: 100%; }
  .post-detail { padding: 25px; }
  .post-title { font-size: 1.6em; }
  .posts { grid-template-columns: 1fr; margin: 0; width: 100%; }
  .hero { margin-left: 0; margin-right: 0; width: 100%; }
  .page-title { margin-left: 0; }
}

/* Settings Page */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.settings-card.full-width {
  grid-column: 1 / -1;
}
.settings-card h2 {
  font-size: 1.1em;
  color: #1a1a2e;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}
.settings-card .form-group {
  margin-bottom: 15px;
}
.settings-card .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #333;
  font-size: 0.9em;
}
.settings-card .form-group input,
.settings-card .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95em;
  font-family: inherit;
}
.settings-card textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9em;
  font-family: 'Monaco', 'Menlo', monospace;
  resize: vertical;
}
.settings-tip {
  font-size: 0.85em;
  color: #888;
  margin-bottom: 15px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 15px;
}
.msg {
  font-size: 0.9em;
  margin-left: 10px;
}
.msg.success { color: #27ae60; }
.msg.error { color: #e74c3c; }
.status-tag {
  font-size: 0.85em;
  padding: 3px 10px;
  border-radius: 4px;
}
.status-tag.ok { background: #e8f8f0; color: #27ae60; }
.status-tag.error { background: #fdf2f2; color: #e74c3c; }
.info-list { display: flex; flex-direction: column; gap: 12px; }
.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}
.info-item:last-child { border-bottom: none; }
.info-label { color: #888; font-size: 0.9em; }
.info-value { color: #333; font-weight: 500; font-size: 0.9em; }
.info-value.status-ok { color: #27ae60; }
.totp-status {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.totp-status.enabled { color: #27ae60; font-size: 0.9em; }
.btn-totp {
  display: inline-block;
  background: #3498db;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85em;
  margin-top: 10px;
}
.btn-totp:hover { background: #2980b9; color: #fff; text-decoration: none; }
.btn-totp-disable {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8em;
  cursor: pointer;
}
.btn-totp-disable:hover { background: #c0392b; }
.login-tip { font-size: 0.9em; color: #888; text-align: center; margin-bottom: 15px; }
.settings-card input[type=text] { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95em; }
.settings-card button[type=submit] { background: #3498db; color: #fff; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-size: 0.9em; }
@media (max-width: 768px) {
  .settings-grid { grid-template-columns: 1fr; }
}
