/* ============================================================
   AGC Blog - Main Stylesheet
   Clean, modern, SEO-friendly design
   ============================================================ */

:root {
  --primary:    #2563eb;
  --primary-dark: #1d4ed8;
  --text:       #1e293b;
  --text-muted: #64748b;
  --bg:         #f8fafc;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'Fira Code', 'Courier New', monospace;
  --max-w:      1100px;
  --sidebar-w:  300px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ---- Layout ---- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

.site-wrapper {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 40px;
  max-width: var(--max-w);
  margin: 30px auto;
  padding: 0 20px;
}

.main-content { min-width: 0; }
.sidebar { min-width: 0; }

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

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.site-logo:hover { text-decoration: none; color: var(--primary-dark); }

.site-nav { display: flex; gap: 4px; }
.site-nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background .15s, color .15s;
}
.site-nav a:hover {
  background: var(--bg);
  color: var(--primary);
  text-decoration: none;
}

/* ---- Post Cards ---- */
.posts-grid { display: flex; flex-direction: column; gap: 24px; }

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
}
.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cat-badge {
  background: #eff6ff;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cat-badge:hover { background: #dbeafe; text-decoration: none; }

.lang-badge {
  background: #f0fdf4;
  color: #16a34a;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.post-date { color: var(--text-muted); font-size: 0.85rem; }

.post-card h2 { font-size: 1.25rem; line-height: 1.4; margin-bottom: 10px; }
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--primary); text-decoration: none; }

.post-excerpt { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 16px; }

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.875rem;
}
.read-more:hover { text-decoration: none; gap: 8px; }

/* ---- Single Post ---- */
.single-post {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
}

.post-header { margin-bottom: 30px; }
.post-header h1 {
  font-size: 2rem;
  line-height: 1.3;
  margin: 12px 0;
  color: var(--text);
}

.post-content {
  font-size: 1rem;
  color: var(--text);
}
.post-content h2 {
  font-size: 1.5rem;
  margin: 32px 0 12px;
  color: var(--text);
  border-left: 4px solid var(--primary);
  padding-left: 12px;
}
.post-content h3 {
  font-size: 1.2rem;
  margin: 24px 0 10px;
  color: var(--text);
}
.post-content p { margin-bottom: 16px; }
.post-content ul, .post-content ol {
  margin: 12px 0 16px 24px;
}
.post-content li { margin-bottom: 6px; }
.post-content strong { color: var(--text); }
.post-content a { color: var(--primary); }

/* ---- Sidebar ---- */
.sidebar-widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.widget-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.cat-list { list-style: none; }
.cat-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.cat-list li:last-child { border-bottom: none; }
.cat-count {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
}

.recent-posts-list { list-style: none; }
.recent-posts-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.recent-posts-list li:last-child { border-bottom: none; }
.recent-posts-list a { color: var(--text); line-height: 1.4; }
.recent-posts-list a:hover { color: var(--primary); }
.recent-date { color: var(--text-muted); font-size: 0.78rem; display: block; margin-top: 3px; }

/* ---- Tags ---- */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-link {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 20px;
  transition: all .15s;
}
.tag-link:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 40px;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--card-bg);
  transition: all .15s;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--text);
  color: #94a3b8;
  text-align: center;
  padding: 30px 20px;
  margin-top: 60px;
  font-size: 0.875rem;
}
.site-footer a { color: #cbd5e1; }

/* ---- Related Posts ---- */
.related-posts { margin-top: 50px; }
.related-posts h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.related-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all .2s;
}
.related-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
}
.related-card a { color: var(--text); font-weight: 600; font-size: 0.9rem; line-height: 1.4; }
.related-card a:hover { color: var(--primary); text-decoration: none; }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }

/* ---- Admin ---- */
.admin-bar {
  background: #1e293b;
  color: #cbd5e1;
  padding: 8px 20px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-bar a { color: #94a3b8; }
.admin-bar a:hover { color: #fff; }

/* ---- Alert ---- */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .site-wrapper {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 20px;
  }
  .sidebar { order: -1; }
  .single-post { padding: 24px 18px; }
  .post-header h1 { font-size: 1.5rem; }
  .related-grid { grid-template-columns: 1fr; }
  .site-nav { display: none; }
}

/* ---- Page Hero ---- */
.page-hero { margin-bottom: 28px; }
.page-hero h1 { font-size: 1.7rem; font-weight: 800; color: var(--text); }
.page-hero p  { color: var(--text-muted); margin-top: 8px; }

/* ---- Post Lead ---- */
.post-lead { font-size: 1.05rem; color: var(--text-muted); margin-top: 10px; line-height: 1.6; }

/* ---- Table of Contents ---- */
.toc { background: #f8fafc; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 20px 24px; margin: 24px 0; }
.toc-title { font-weight: 700; font-size: .9rem; color: var(--primary); margin-bottom: 12px; }
.toc-list { margin: 0; padding-left: 20px; }
.toc-list li { margin-bottom: 6px; }
.toc-list a { color: var(--text); font-size: .9rem; }
.toc-list a:hover { color: var(--primary); }

/* ---- Post Tags ---- */
.post-tags { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tags-label { font-size: .82rem; font-weight: 700; color: var(--text-muted); }

/* ---- Post Source ---- */
.post-source { font-size: .78rem; color: var(--text-muted); margin-top: 12px; }

/* ---- Related Posts ---- */
.related-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
.related-date { font-size: .75rem; color: var(--text-muted); margin-top: 6px; }

/* ---- Post content blockquote ---- */
.post-content blockquote { border-left: 4px solid var(--primary); margin: 20px 0; padding: 12px 20px; background: #f8fafc; border-radius: 0 var(--radius) var(--radius) 0; font-style: italic; color: var(--text-muted); }
.post-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .9em; color: #e11d48; }
.post-content hr { border: none; border-top: 2px solid var(--border); margin: 32px 0; }

/* ---- Footer Grid ---- */
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; text-align: left; }
.footer-logo { font-size: 1.2rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.site-footer p { color: #94a3b8; font-size: .875rem; }
.site-footer ul { list-style: none; margin-top: 8px; }
.site-footer ul li { margin-bottom: 6px; }
.site-footer ul li a { color: #94a3b8; font-size: .875rem; }
.site-footer ul li a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #334155; padding-top: 20px; text-align: center; }
.footer-bottom p { color: #475569; font-size: .82rem; }

/* ---- Mobile nav toggle ---- */
.nav-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); padding: 4px 8px; }

/* ---- Alert ---- */
.alert-info { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; padding: 14px 18px; border-radius: var(--radius); }

/* ---- Responsive additions ---- */
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .nav-toggle  { display: block; }
  .site-nav    { display: none; position: absolute; top: 64px; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); flex-direction: column; padding: 8px 0; z-index: 99; }
  .site-nav.open { display: flex; }
  .site-nav a  { padding: 10px 20px; }
  .toc         { padding: 14px 16px; }
}

/* ---- Article Images ---- */
.article-image { margin: 28px 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); }
.article-image img { width: 100%; height: auto; display: block; aspect-ratio: 16/9; object-fit: cover; }
.article-image figcaption { font-size: .75rem; color: var(--text-muted); padding: 8px 12px; background: var(--bg); text-align: right; }
.article-image figcaption a { color: var(--text-muted); }

/* ---- FAQ Section ---- */
.faq-item { margin: 0; }
p.faq-q { background: #eff6ff; border-left: 4px solid var(--primary); padding: 10px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 16px 0 4px; font-size: .95rem; color: var(--text); }
p.faq-a { padding: 8px 16px 12px; color: var(--text-muted); margin: 0 0 8px; font-size: .9rem; border-left: 2px solid var(--border); }

/* ---- Key Takeaway box (from AI content) ---- */
.post-content blockquote { border-left: 4px solid #f59e0b; background: #fffbeb; border-radius: 0 var(--radius) var(--radius) 0; }

/* ---- TOC improved ---- */
.toc { position: relative; }
.toc::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); border-radius: 4px; }

/* ---- Post Card with Thumbnail ---- */
.post-card { padding: 0; overflow: hidden; }
.post-thumb { display: block; width: 100%; overflow: hidden; aspect-ratio: 16/9; background: var(--bg); }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.post-card:hover .post-thumb img { transform: scale(1.03); }
.post-card-body { padding: 22px 24px 24px; }
.post-card-body .post-meta { margin-bottom: 10px; }
.post-card-body h2 { font-size: 1.15rem; line-height: 1.4; margin-bottom: 10px; }
.post-card-body h2 a { color: var(--text); }
.post-card-body h2 a:hover { color: var(--primary); text-decoration: none; }
.post-card-body .post-excerpt { color: var(--text-muted); font-size: .9rem; margin-bottom: 14px; }

/* ---- Logo Image ---- */
.site-logo .logo-img { max-height: 42px; max-width: 180px; display: block; object-fit: contain; }

/* ---- Public uploads path ---- */
/* /public/uploads/ directory serves uploaded logos and favicons */

/* ---- Admin site setup form ---- */
.logo-preview { border: 2px dashed var(--border); border-radius: var(--radius); padding: 16px; text-align: center; margin-bottom: 10px; background: var(--bg); }

@media (max-width: 768px) {
  .post-card { margin-bottom: 0; }
  .post-card-body { padding: 16px; }
}

/* ---- Image credit — plain text, no link styling ---- */
.article-image figcaption { font-size: .72rem; color: #94a3b8; padding: 6px 10px; background: var(--bg); text-align: right; font-style: italic; }
.article-image figcaption a { pointer-events: none; color: inherit; text-decoration: none; cursor: default; }

/* ---- v5.2: figcaption plain text, ensure no link appearance ---- */
.article-image figcaption,
.article-image figcaption a {
  color: #94a3b8 !important;
  font-size: .72rem;
  font-style: italic;
  pointer-events: none;
  text-decoration: none;
  cursor: default;
}
