/* Global box-sizing fix to prevent overflow */
.blog-section *,
.blog-container *,
.blog-main *,
.blog-sidebar * {
  box-sizing: border-box;
}

/* Blog Header */
.blog-header {
  background: #f8f9fa;
  padding: 1rem 0;
  border-bottom: 1px solid #e9ecef;
}

.blog-header .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #6c757d;
}

.breadcrumb a {
  color: #495057;
  text-decoration: none;
  transition: color 0.3s ease;
}

.breadcrumb a:hover {
  color: #212529;
}

.breadcrumb span {
  color: #adb5bd;
}

/* Blog Section & Container */
.blog-section {
  padding: 2rem 0;
  background-color: #ffffff;
}

.blog-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  align-items: start;
  box-sizing: border-box;
  width: 100%;
}

/* Main Content */
.blog-main {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

.blog-post {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

/* Post Header */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #212529;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  letter-spacing: -0.5px;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-top: 1px solid #e9ecef;
  border-bottom: 1px solid #e9ecef;
}

.author-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

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

.author-details {
  display: flex;
  flex-direction: column;
}

.author-name {
  font-weight: 600;
  color: #212529;
  font-size: 0.95rem;
}

.author-title {
  font-size: 0.8rem;
  color: #6c757d;
}

.post-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: #6c757d;
}

.post-stats span {
  position: relative;
}

/* Featured Image */
.post-featured-image {
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
}

.post-featured-image img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}

.image-caption {
  padding: 0.8rem 1rem;
  background: #f8f9fa;
  font-size: 0.9rem;
  color: #6c757d;
  font-style: italic;
  text-align: center;
}

/* Post Content */
.post-content {
  margin: 2rem 0;
  line-height: 1.8;
  font-size: 1.1rem;
  color: #212529;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin: 2rem 0 1rem 0;
  font-weight: 700;
  color: #212529;
  line-height: 1.3;
}

.post-content h2 {
  font-size: 1.8rem;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0.5rem;
}

.post-content h3 {
  font-size: 1.5rem;
}

.post-content p {
  margin-bottom: 1.5rem;
}

.post-content blockquote,
#blog-content blockquote {
  border-left: 4px solid #212529;
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  font-size: 1.2rem;
  color: #495057;
  background: #f8f9fa;
  padding: 1.5rem 1.5rem 1.5rem 2.5rem;
  border-radius: 0 8px 8px 0;
}

.post-content ul,
.post-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content code {
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #e83e8c;
  word-break: break-word;
}

.post-content pre,
#blog-content pre {
  background: #212529;
  color: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
}

/* --- Responsive Blog Content --- */
.post-content img,
#blog-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 1.5rem auto;
  object-fit: contain;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  border-radius: 8px;
}

.post-content iframe,
#blog-content iframe,
.post-content video,
#blog-content video {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 8px;
}

.post-content table,
#blog-content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

.post-content th,
.post-content td,
#blog-content th,
#blog-content td {
  padding: 0.75rem 1rem;
  border: 1px solid #dee2e6;
  text-align: left;
  font-size: 1rem;
}
figure.table {
  margin-left: 0;
  margin-right: 0;
  float: none !important;
}

/* CKEditor 5 Code Block Styling  */

/* Responsive horizontal scroll for wide content */
.post-content,
#blog-content {
  overflow-wrap: break-word;
}

/* --- Mobile & Tablet Adjustments --- */
@media (max-width: 1024px) {
  .blog-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 0 1.5rem;
    max-width: 100%;
  }

  .blog-sidebar {
    position: static;
  }
}

@media (max-width: 992px) {
  .blog-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 0 1.5rem;
  }

  .blog-sidebar {
    position: static;
  }

  .post-title {
    font-size: 2rem;
  }

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

@media (max-width: 768px) {
  .blog-header .container {
    padding: 0 1rem;
  }
  
  .blog-container {
    padding: 0 1rem;
    gap: 1.5rem;
  }

  .post-meta {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .post-stats {
    justify-content: center;
  }

  .post-featured-image img {
    max-height: 250px;
  }

  .post-title {
    font-size: 1.8rem;
  }

  .post-content {
    font-size: 1rem;
  }

  .share-buttons {
    justify-content: center;
  }

  .related-item {
    flex-direction: column;
    text-align: center;
  }

  .related-item img {
    width: 100%;
    height: 150px;
  }

  .post-content img,
  #blog-content img {
    height: auto;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .post-content pre,
  #blog-content pre {
    font-size: 0.85rem;
    padding: 1rem;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    border-radius: 8px;
    overflow-x: auto;
  }

  .post-content code {
    font-size: 0.85rem;
    word-break: break-all;
  }

  .post-content table,
  #blog-content table {
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
  }
}

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

  .breadcrumb {
    font-size: 0.8rem;
    flex-wrap: wrap;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .author-info {
    gap: 0.5rem;
  }

  .author-avatar {
    width: 40px;
    height: 40px;
  }

  .tags-list {
    gap: 0.3rem;
  }

  .tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }

  .post-content img,
  #blog-content img {
    margin: 1rem 0;
    border-radius: 4px;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .post-content pre,
  #blog-content pre {
    font-size: 0.8rem;
    padding: 0.7rem;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    border-radius: 6px;
    overflow-x: auto;
  }

  .post-content code {
    font-size: 0.75rem;
    word-break: break-all;
  }

  .post-content th,
  .post-content td,
  #blog-content th,
  #blog-content td {
    padding: 0.5rem 0.5rem;
    font-size: 0.9rem;
  }
}

/* Post Footer */
.post-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e9ecef;
}

.post-tags {
  margin-bottom: 2rem;
}

.post-tags h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.8rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: #e9ecef;
  color: #495057;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tag:hover {
  background: #212529;
  color: #ffffff;
}

/* Social Share */
.social-share h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.8rem;
}

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

.share-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.share-btn.twitter {
  background: #1da1f2;
}

.share-btn.facebook {
  background: #4267b2;
}

.share-btn.linkedin {
  background: #0077b5;
}

.share-btn.copy {
  background: #6c757d;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Sidebar */
.blog-sidebar {
  position: sticky;
  top: 2rem;
  height: fit-content;
}

.sidebar-widget {
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding-bottom: 1.5rem;
}

.sidebar-widget h3 {
  font-size: 1.2rem;
  font-weight: 700;
  padding:0 1.5rem 0.5rem 1.5rem;
  color: #212529;
  margin-bottom: 1rem;
  border-bottom: 2px solid #e9ecef;
}

/* Popular Posts Widget */
.popular-posts {
  display: flex;
  flex-direction: column;
}

.popular-item {
  display: flex;
  gap: 0.8rem;
  transition: background-color 0.3s ease;
  border-radius: 6px;
  padding:0 0.7rem 0 0.7rem;
  margin: 0 0.8rem 0 0.8rem;
  align-items: center;
}

.popular-item:hover {
  background-color: #f8f9fa;
}

.popular-item img {
  width: 70px;
  height: 55px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.popular-content h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #212529;
  line-height: 1.3;
}

.popular-views {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Newsletter Widget */
.newsletter-widget {
  background: linear-gradient(135deg, #212529, #495057);
  color: white;
  padding: 0 0 1.5rem 0;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding-bottom: 1.5rem;
}

.newsletter-widget h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  border-bottom: 1px solid #a1a1a1;
}

.newsletter-widget h3,
.newsletter-widget p {
  color: white;
  padding:0 1.5rem 0.5rem 1.5rem;
}

.newsletter-widget .newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
    padding:0 1.5rem 0.5rem 1.5rem;

}

.newsletter-widget input[type="email"] {
  padding: 0.8rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.newsletter-widget input[type="email"]::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.newsletter-widget input[type="email"]:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
}

.newsletter-widget button {
  background: white;
  color: #212529;
  border: none;
  padding: 0.8rem;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.newsletter-widget button:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}