/* ============================
   Blog App Styles
   ============================ */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #1f2937;
  background-color: #f9fafb;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* Container */
.blog-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Main */
.blog-main {
  min-height: 60vh;
  padding: 2rem 0 4rem;
}

/* ============================
   Default Header / Footer
   (used when no theme is set)
   ============================ */
.blog-default-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem 0;
}

.blog-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #1f2937;
}

.blog-logo {
  height: 36px;
  width: auto;
}

.blog-initial {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
}

.blog-brand-name {
  font-weight: 600;
  font-size: 1.125rem;
}

.blog-default-footer {
  background: #1f2937;
  color: #9ca3af;
  padding: 2rem 0;
  text-align: center;
  font-size: 0.875rem;
}

.blog-footer-links {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.blog-footer-links a {
  color: #d1d5db;
  transition: color 0.2s;
}

.blog-footer-links a:hover {
  color: #fff;
}

.blog-copyright {
  margin: 0;
}

/* ============================
   Blog Page Header
   ============================ */
.blog-page-header {
  margin-bottom: 2rem;
}

.blog-page-title {
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 0.5rem;
}

.blog-page-description {
  color: #6b7280;
  font-size: 1.125rem;
  margin: 0;
}

.blog-clear-filter {
  display: inline-block;
  color: #3b82f6;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  transition: color 0.2s;
}

.blog-clear-filter:hover {
  color: #2563eb;
}

/* ============================
   Category Navigation
   ============================ */
.blog-category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.blog-category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  font-size: 0.875rem;
  color: #4b5563;
  transition: all 0.2s;
}

.blog-category-pill:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.blog-category-pill.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.blog-category-count {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ============================
   Search
   ============================ */
.blog-search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  max-width: 480px;
}

.blog-search-input {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.875rem;
  background: #fff;
  transition: border-color 0.2s;
}

.blog-search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.blog-search-btn {
  padding: 0.625rem 1.25rem;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.blog-search-btn:hover {
  background: #2563eb;
}

/* ============================
   Posts Grid
   ============================ */
.blog-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

/* First post featured (large) */
.blog-post-card--featured {
  grid-column: 1 / -1;
}

.blog-post-card--featured .blog-post-image img {
  max-height: 400px;
}

.blog-post-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s, transform 0.2s;
}

.blog-post-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.blog-post-image {
  display: block;
  overflow: hidden;
}

.blog-post-image img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  transition: transform 0.3s;
}

.blog-post-card:hover .blog-post-image img {
  transform: scale(1.03);
}

.blog-post-content {
  padding: 1.25rem;
}

.blog-post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.blog-post-category {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: background 0.2s;
}

.blog-post-category:hover {
  background: #dbeafe;
}

.blog-post-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

.blog-post-title a {
  color: #111827;
  transition: color 0.2s;
}

.blog-post-title a:hover {
  color: #3b82f6;
}

.blog-post-excerpt {
  color: #6b7280;
  font-size: 0.9375rem;
  margin: 0 0 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: #9ca3af;
}

.blog-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.blog-meta-author {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 500;
  color: #6b7280;
}

.blog-author-avatar-sm {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

/* ============================
   Pagination
   ============================ */
.blog-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e5e7eb;
}

.blog-page-btn {
  padding: 0.5rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #374151;
  transition: all 0.2s;
}

.blog-page-btn:hover:not(.blog-page-btn--disabled) {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.blog-page-btn--disabled {
  opacity: 0.4;
  cursor: default;
}

.blog-page-info {
  font-size: 0.875rem;
  color: #6b7280;
}

/* ============================
   No Results
   ============================ */
.blog-no-results {
  text-align: center;
  padding: 4rem 2rem;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.blog-no-results h3 {
  font-size: 1.25rem;
  color: #374151;
  margin: 0 0 0.5rem;
}

.blog-no-results p {
  color: #6b7280;
  margin: 0;
}

.blog-no-results a {
  color: #3b82f6;
}

/* ============================
   Article Page
   ============================ */
.blog-article {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 2.5rem;
}

.blog-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #9ca3af;
  margin-bottom: 1.5rem;
}

.blog-breadcrumb a {
  color: #6b7280;
  transition: color 0.2s;
}

.blog-breadcrumb a:hover {
  color: #3b82f6;
}

.blog-article-header {
  margin-bottom: 2rem;
}

.blog-article-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: #111827;
  margin: 0.75rem 0 1.25rem;
}

.blog-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.blog-article-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blog-author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.blog-author-name {
  display: block;
  font-weight: 600;
  color: #111827;
  font-size: 0.9375rem;
}

.blog-author-bio {
  display: block;
  color: #6b7280;
  font-size: 0.8125rem;
}

.blog-article-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.blog-article-image {
  margin: 0 -2.5rem 2rem;
}

.blog-article-image img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
}

/* Article Body - Typography */
.blog-article-body {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: #374151;
}

.blog-article-body h1,
.blog-article-body h2,
.blog-article-body h3,
.blog-article-body h4,
.blog-article-body h5,
.blog-article-body h6 {
  color: #111827;
  margin-top: 2em;
  margin-bottom: 0.75em;
  line-height: 1.3;
}

.blog-article-body h2 { font-size: 1.5rem; }
.blog-article-body h3 { font-size: 1.25rem; }

.blog-article-body p {
  margin: 0 0 1.25em;
}

.blog-article-body a {
  color: #3b82f6;
  text-decoration: underline;
}

.blog-article-body a:hover {
  color: #2563eb;
}

.blog-article-body img {
  border-radius: 8px;
  margin: 1.5em 0;
}

.blog-article-body blockquote {
  border-left: 4px solid #3b82f6;
  margin: 1.5em 0;
  padding: 1em 1.5em;
  background: #f9fafb;
  border-radius: 0 8px 8px 0;
  color: #4b5563;
  font-style: italic;
}

.blog-article-body pre {
  background: #1f2937;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 1.25em;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: 0.875rem;
}

.blog-article-body code {
  background: #f3f4f6;
  padding: 0.125em 0.375em;
  border-radius: 4px;
  font-size: 0.9em;
}

.blog-article-body pre code {
  background: none;
  padding: 0;
}

.blog-article-body ul,
.blog-article-body ol {
  margin: 1em 0;
  padding-left: 1.5em;
}

.blog-article-body li {
  margin-bottom: 0.375em;
}

.blog-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.blog-article-body th,
.blog-article-body td {
  padding: 0.75em 1em;
  border: 1px solid #e5e7eb;
  text-align: left;
}

.blog-article-body th {
  background: #f9fafb;
  font-weight: 600;
}

.blog-article-body hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 2em 0;
}

/* Tags */
.blog-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.blog-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #f3f4f6;
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: #4b5563;
  transition: all 0.2s;
}

.blog-tag:hover {
  background: #e5e7eb;
  color: #111827;
}

/* Share */
.blog-article-share {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.blog-share-label {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

.blog-share-buttons {
  display: flex;
  gap: 0.5rem;
}

.blog-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #4b5563;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
}

.blog-share-btn:hover {
  background: #e5e7eb;
  color: #111827;
}

/* ============================
   Related Posts
   ============================ */
.blog-related {
  max-width: 800px;
  margin: 3rem auto 0;
}

.blog-related-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 1.25rem;
}

.blog-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.blog-related-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  transition: box-shadow 0.2s;
}

.blog-related-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.blog-related-image img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.blog-related-content {
  padding: 1rem;
}

.blog-related-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.375rem;
  line-height: 1.3;
}

.blog-related-content h3 a {
  color: #111827;
  transition: color 0.2s;
}

.blog-related-content h3 a:hover {
  color: #3b82f6;
}

.blog-related-content p {
  color: #6b7280;
  font-size: 0.8125rem;
  margin: 0 0 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Back Link */
.blog-back {
  max-width: 800px;
  margin: 2rem auto 0;
}

.blog-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #3b82f6;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.2s;
}

.blog-back-link:hover {
  color: #2563eb;
}

/* ============================
   404 Page
   ============================ */
.blog-not-found {
  text-align: center;
  padding: 4rem 2rem;
}

.blog-not-found h1 {
  font-size: 5rem;
  font-weight: 800;
  color: #e5e7eb;
  margin: 0;
  line-height: 1;
}

.blog-not-found h2 {
  font-size: 1.5rem;
  color: #374151;
  margin: 1rem 0 0.5rem;
}

.blog-not-found p {
  color: #6b7280;
  margin: 0 0 1.5rem;
}

/* ============================
   Legal Pages
   ============================ */
.blog-legal {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 2.5rem;
}

.blog-legal h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 1.5rem;
}

.blog-legal-content {
  font-size: 1rem;
  line-height: 1.75;
  color: #374151;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
  .blog-page-title {
    font-size: 1.5rem;
  }

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

  .blog-post-card--featured .blog-post-image img {
    max-height: 240px;
  }

  .blog-article {
    padding: 1.5rem;
  }

  .blog-article-title {
    font-size: 1.75rem;
  }

  .blog-article-image {
    margin: 0 -1.5rem 1.5rem;
  }

  .blog-article-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .blog-related-grid {
    grid-template-columns: 1fr;
  }

  .blog-category-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .blog-category-nav::-webkit-scrollbar {
    display: none;
  }

  .blog-category-pill {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .blog-search-form {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .blog-container {
    padding: 0 1rem;
  }

  .blog-article {
    padding: 1.25rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .blog-article-image {
    margin: 0 -1.25rem 1.25rem;
  }

  .blog-article-share {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

/* ============================================
   COMMENTS
   ============================================ */

.blog-comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #e5e7eb;
}

.blog-comments-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1.5rem;
}

/* Comment Form */
.blog-comment-form {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.blog-comment-form--reply {
  margin-top: 0.75rem;
  margin-bottom: 0;
  padding: 1rem;
  background: #f3f4f6;
}

.blog-comment-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.blog-comment-form-field {
  margin-bottom: 0.75rem;
}

.blog-comment-form-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.blog-comment-form-field input,
.blog-comment-form-field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.blog-comment-form-field input:focus,
.blog-comment-form-field textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.blog-comment-form-field textarea {
  resize: vertical;
  min-height: 80px;
}

.blog-comment-form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blog-comment-submit {
  padding: 0.625rem 1.25rem;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.blog-comment-submit:hover {
  background: #2563eb;
}

.blog-comment-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.blog-comment-cancel {
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.blog-comment-cancel:hover {
  background: #f3f4f6;
}

.blog-comment-form-note {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.5rem;
}

/* Comments List */
.blog-comments-list {
  margin-top: 1.5rem;
}

.blog-comments-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
  padding: 2rem 0;
}

/* Individual Comment */
.blog-comment {
  padding: 1rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.blog-comment:last-child {
  border-bottom: none;
}

.blog-comment-depth-1 {
  margin-left: 2rem;
  padding-left: 1rem;
  border-left: 2px solid #e5e7eb;
}

.blog-comment-depth-2 {
  margin-left: 2rem;
  padding-left: 1rem;
  border-left: 2px solid #e5e7eb;
}

.blog-comment-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.blog-comment-author {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
}

.blog-comment-date {
  font-size: 0.75rem;
  color: #9ca3af;
}

.blog-comment-body {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.6;
}

.blog-comment-body p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.blog-comment-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.blog-comment-like {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.blog-comment-like:hover {
  color: #ef4444;
}

.blog-comment-like.liked {
  color: #ef4444;
}

.blog-comment-like.liked svg {
  fill: #ef4444;
}

.blog-comment-like-count {
  font-size: 0.8125rem;
}

.blog-comment-reply-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.blog-comment-reply-btn:hover {
  color: #3b82f6;
}

.blog-comment-replies {
  margin-top: 0.5rem;
}

/* New comment animation */
.blog-comment-new {
  animation: commentFadeIn 0.3s ease-out;
}

@keyframes commentFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Comment message */
.blog-comment-message {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  margin-top: 0.5rem;
}

.blog-comment-message--success {
  background: #ecfdf5;
  color: #065f46;
}

.blog-comment-message--error {
  background: #fef2f2;
  color: #991b1b;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .blog-comment-form-row {
    grid-template-columns: 1fr;
  }

  .blog-comment-depth-1,
  .blog-comment-depth-2 {
    margin-left: 1rem;
    padding-left: 0.75rem;
  }

  .blog-comment-form {
    padding: 1rem;
  }
}
