/* Blog Post Styles */
/* **************** */

/* Blog header adjustments */
.blog-header {
  padding: 3em 1em 2.5em 1em;
  background-color: #4686a0;
  color: rgba(255, 255, 255, 0.75);
  background-attachment: fixed, fixed, fixed;
  background-image: url("images/overlay2.png"), url("images/overlay4.svg"),
    linear-gradient(45deg, #4361c2, #4fa49a 50%, #9dc66b 95%);
  background-position: top left, center center, center center;
  background-size: auto, cover, cover;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.blog-nav {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.blog-nav .button {
  background: #2b797e;
  color: white;
  padding: 0 1rem;
  border-radius: 25px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 3px 10px rgba(43, 121, 126, 0.3);
}

.blog-nav .button:hover {
  background: #1a5b5f;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(43, 121, 126, 0.4);
}

.blog-title-container {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.codi-logo {
  max-width: 120px;
  height: auto;
  margin: 0 auto 1.5rem;
  display: block;
}

.blog-title-container h1 {
  color: black;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.3;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: -0.5px;
}

.blog-meta {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  font-style: italic;
}

.blog-description {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.2rem;
  line-height: 1.5;
  font-weight: 400;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  max-width: 750px;
  margin: 0 auto;
}

/* Blog content styling */
.blog-post {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
  background: white;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  margin-top: -2rem;
  position: relative;
  z-index: 10;
}

/* Override all link styles in blog post to prevent white color and underlines */
.blog-post a {
  text-decoration: none;
}

.blog-post a:hover {
  text-decoration: none;
  color: #1a5b5f;
}

.blog-section {
  margin-bottom: 4rem;
  line-height: 1.8;
}

#blog-content .blog-section h2 {
  color: black;
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 2rem;
  margin-top: 3rem;
  padding-bottom: 1rem;
  border-bottom: 3px solid #2b797e;
  position: relative;
}

.blog-section h2:first-child {
  margin-top: 0;
}

.blog-section h2::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 60px;
  height: 3px;
  background: #f39c12;
  border-radius: 2px;
}

#blog-content .blog-section h3 {
  color: black;
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  margin-top: 2.5rem;
}

#blog-content .blog-section h4 {
  color: black;
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

.blog-section p {
  margin-bottom: 0.5rem;
  text-align: justify;
  font-size: 1.1rem;
  color: #495057;
  line-height: 1.8;
}

.blog-section ul,
.blog-section ol {
  margin-bottom: 2rem;
  padding-left: 2.5rem;
  font-size: 1.1rem;
  color: #495057;
}

.blog-section li ul,
.blog-section li ol {
  margin-bottom: 0.2rem;
}

.blog-section li {
  margin-bottom: 0.8rem;
  line-height: 1.7;
}

.main.style2 .blog-section strong,
.main.style2 .blog-section b {
  color: #2b797e;
}

.blog-section a {
  color: #2b797e;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
}

.blog-section a:hover {
  color: #1a5b5f;
  border-bottom-color: #2b797e;
  text-decoration: none;
}

/* Table styles */
.blog-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.blog-section table thead,
.blog-section table tbody,
.blog-section table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.blog-section table thead tr {
  background-color: #2b797e;
  color: #ffffff;
}

.blog-section table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #ffffff;
  border-bottom: 2px solid #1a5b5f;
}

.blog-section table td {
  padding: 1rem;
  border-bottom: 1px solid #e9ecef;
  color: #495057;
}

.blog-section table tbody tr:hover {
  background-color: #f8f9fa;
}

.blog-section table tbody tr:last-child td {
  border-bottom: none;
}

.blog-section table code {
  background: #f1f3f5;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: #2b797e;
  font-weight: 500;
}

/* Blog link class to override main.css styles with higher specificity */
.blog-post .blog-section .blog-link,
.blog-post .blog-link {
  color: #2b797e;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
}

.blog-post .blog-section .blog-link:hover,
.blog-post .blog-link:hover {
  color: #1a5b5f;
  text-decoration: none;
  border-bottom-color: #2b797e;
}

/* TOC specific overrides for blog-section */
.blog-section .toc-container .toc a {
  color: #212529;
  border-bottom: none;
}

.blog-section .toc-container .toc a:hover {
  color: #2b797e;
  border-bottom: none;
}

/* Table of Contents */
.toc-container {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 0 auto 4rem auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.toc-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2b797e, #f39c12, #e74c3c);
}

.blog-post .toc-container h2 {
  color: #333333;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  margin-top: 0;
  display: flex;
  align-items: center;
}

.toc-container h2::before {
  content: "📋";
  margin-right: 0.5rem;
  font-size: 1.2rem;
}

.toc {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc li {
  margin-bottom: 0;
  position: relative;
  padding-left: 1.5rem;
}

.toc li ul {
  margin-bottom: 0;
}

.toc li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #2b797e;
  font-size: 1.5rem;
  top: 0.1rem;
}

.toc-container .toc a {
  color: #212529;
  text-decoration: none;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  display: block;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.toc-container .toc a:hover {
  color: #2b797e;
  background: rgba(43, 121, 126, 0.1);
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(43, 121, 126, 0.2);
}

/* Disabled CSS smooth scrolling to avoid conflicts with JavaScript */
/* html {
  scroll-behavior: smooth;
} */

/* Section separators */
.section-separator {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #2b797e, transparent);
  margin: 3rem 0;
  border: none;
}

/* Ensure all images have minimum padding */
.blog-post img {
  padding: 1rem;
  box-sizing: border-box;
}

/* Override main.css margin-bottom for image.fit */
.blog-post .image.fit {
  margin-bottom: 0;
}

/* Featured image */
.blog-featured-image {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem;
  background: #f8f9fa;
  border-radius: 12px;
}

.blog-featured-image img {
  padding: 0; /* Reset padding for featured images since container has padding */
}

.blog-featured-image .image.fit {
  max-width: 800px;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease;
  border: 3px solid white;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.blog-featured-image img:hover {
  transform: scale(1.01);
}

/* Image containers and captions */
.image-container {
  text-align: center;
  margin: 3rem auto;
  padding: 1.5rem;
  background: #fafbfc;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
  max-width: 900px;
}

.image-container:hover {
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.image-container img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  border: 2px solid white;
  transition: transform 0.3s ease;
  padding: 0; /* Reset padding since container provides it */
}

.image-container img:hover {
  transform: scale(1.02);
}

/* Ensure images maintain aspect ratio */
.image-container .image.fit {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* Make script index image fill container horizontally */
.image-container img[src*="financial_report_script_index_002.png"] {
  width: 100%;
  max-width: 100%;
  object-fit: cover;
}

/* Make API key configuration image fill container horizontally */
.image-container img[src*="financial_report_api_key_input_002.png"] {
  width: 100%;
  max-width: 100%;
  object-fit: cover;
}

/* Make FPDF2 library logo image fill container horizontally */
.image-container img[src*="financial_report_pyhon_fpdf2_library_logo_002.png"] {
  width: 100%;
  max-width: 100%;
  object-fit: cover;
}

/* Make file structure image fill container horizontally */
.image-container img[src*="financial_report_code_file_structure-300x208.png"] {
  width: 100%;
  max-width: 100%;
  object-fit: cover;
}

.image-caption {
  font-style: italic;
  color: #6c757d;
  font-size: 0.9rem;
  margin-top: 0;
  margin-bottom: 0;
  font-weight: 500;
  background: white;
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  border-left: 4px solid #2b797e;
  margin-top: 1.5rem;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.component-images {
  margin: 3rem 0;
  padding: 2rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  border: 1px solid #e9ecef;
}

.component-images .image-container {
  max-width: 350px;
  padding: 1rem;
  margin: 1.5rem auto;
}

.component-images .image-container img {
  max-height: 250px;
  width: auto;
  object-fit: contain;
}

/* Specific image size controls */
.image-container.small {
  max-width: 400px;
}

.image-container.medium {
  max-width: 600px;
}

.image-container.large {
  max-width: 800px;
}

/* Diagram images should be medium sized */
.image-container img[alt*="diagram"],
.image-container img[alt*="Diagram"],
.image-container img[alt*="Flow"],
.image-container img[alt*="setup"] {
  max-height: 600px;
}

/* Component images should be smaller */
.image-container img[alt*="sensor"],
.image-container img[alt*="controller"],
.image-container img[alt*="ESP32"],
.image-container img[alt*="Raspberry"] {
  max-height: 200px;
}

/* Chart and gauge images */
.image-container img[alt*="gauge"],
.image-container img[alt*="chart"],
.image-container img[alt*="time series"],
.image-container img[alt*="Gauge"] {
  max-height: 300px;
}

/* Water Level Monitor Blog - Specific image size constraints */
/* Water tank measurements - reduce from 867x874 to ~600x600 */
.blog-post .image-container img.image.fit[src*="water_level_tank_measurements"] {
  max-width: 600px;
  max-height: 600px;
  width: auto !important;
  height: auto !important;
}

/* Electrical box - reduce from 850x1049 to ~600x750 */
.blog-post .image-container img.image.fit[src*="water_level_electrical_box_label"] {
  max-width: 600px;
  max-height: 750px;
  width: auto !important;
  height: auto !important;
}

/* Complete setup photo - reduce from 850x867 to ~600x620 */
.blog-post .image-container img.image.fit[src*="water_level_setup3"] {
  max-width: 600px;
  max-height: 620px;
  width: auto !important;
  height: auto !important;
}

/* Sensor detail - reduce from 850x689 to ~600x490 */
.blog-post .image-container img.image.fit[src*="water_level_detail"] {
  max-width: 600px;
  max-height: 490px;
  width: auto !important;
  height: auto !important;
}

/* Tank diagram - constrain to reasonable size */
.blog-post .image-container img.image.fit[src*="water_level_tank_diagram"] {
  max-width: 650px;
  max-height: 460px;
  width: auto !important;
  height: auto !important;
}

/* Electrical diagram - constrain to reasonable size */
.blog-post .image-container img.image.fit[src*="water_level_diagram_002"] {
  max-width: 650px;
  max-height: 460px;
  width: auto !important;
  height: auto !important;
}

/* Code blocks */
.code-block {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  border: 1px solid #4a5568;
  border-radius: 12px;
  padding: 0;
  margin: 2.5rem 0;
  overflow: hidden;
  font-family: "JetBrains Mono", "Fira Code", "Monaco", "Menlo", "Ubuntu Mono",
    monospace;
  font-size: 0.5rem;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.code-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f39c12, #e74c3c, #9b59b6);
  z-index: 1;
}

.code-header {
  background: #1a202c;
  color: #a0a9c1;
  padding: 0.8rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #4a5568;
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copy-button {
  background: rgba(160, 169, 193, 0.8);
  color: white;
  border: none;
  padding: 0 0.8rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: none;
  letter-spacing: normal;
}

.copy-button:hover {
  background: #a0a9c1;
  transform: translateY(-1px);
}

.copy-button.copied {
  background: #38a169;
}

.code-block code {
  background: none;
  padding: 1.5rem;
  color: #e2e8f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  display: block;
  overflow-x: auto;
}

/* Override Prism.js font size with higher specificity */
.code-block code[class*="language-"],
.code-block pre[class*="language-"] {
  font-size: 0.75rem;
}

/* Syntax highlighting styles */
.code-block .comment {
  color: #68d391;
  font-style: italic;
}

.code-block .string {
  color: #fbd38d;
}

.code-block .number {
  color: #f687b3;
}

.code-block .keyword {
  color: #90cdf4;
  font-weight: bold;
}

.code-block .function {
  color: #fbb6ce;
}

.code-block .variable {
  color: #a78bfa;
}

.code-block .operator {
  color: #f56565;
}

.code-block .constant {
  color: #38b2ac;
  text-transform: uppercase;
}

/* Blog navigation */
.blog-navigation {
  margin-top: 0.5rem;
  padding: 2rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  border: 1px solid #dee2e6;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.nav-left,
.nav-right {
  flex: 1;
}

.nav-right {
  text-align: right;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.nav-links .button {
  background: #2b797e;
  color: white;
  padding: 0.8em 2em;
  border-radius: 25px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(43, 121, 126, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links .button:hover {
  background: #1a5b5f;
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(43, 121, 126, 0.4);
}

.white-text {
  color: white;
}

.white-text:hover {
  color: white;
}

/* Video resources styling */
.video-resources {
  margin: 3rem 0;
  padding: 2rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px;
  border: 1px solid #e9ecef;
}

.video-container {
  position: relative;
  margin-bottom: 1rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.video-container:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.video-thumbnail {
  width: 100%;
  height: auto;
  display: block;
  transition: all 0.3s ease;
}

.video-container:hover .video-thumbnail {
  transform: scale(1.05);
}

.play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  text-decoration: none;
}

.video-container:hover .play-button {
  background: rgba(255, 0, 0, 0.9);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Back to top buttons */
.back-to-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #3a8a8f;
  color: white;
  width: auto;
  height: 35px;
  padding: 0 1rem;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: bold;
  transition: all 0.3s ease;
  border: none;
  margin: 2rem auto 0 auto;
  position: relative;
  gap: 0.5rem;
}

.back-to-top:hover {
  background: #2b797e;
  color: white;
  transform: translateY(-2px);
}

.back-to-top::before {
  content: "↑ ";
  font-weight: bold;
  color: white;
}

.back-to-top span {
  font-weight: bold;
  color: white;
}

/* Special sections styling */
#featured-image {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: 2rem 0;
}

#blog-content {
  background: #ffffff;
  position: relative;
}

#blog-content::before {
  content: "";
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, #2b797e, #f39c12);
  border-radius: 2px;
}

/* Responsive adjustments for blog */
@media screen and (max-width: 768px) {
  .blog-post {
    padding: 2rem 1rem;
    margin-top: -1rem;
  }

  .blog-header {
    padding: 2.5rem 1rem 2rem 1rem;
  }

  .blog-title-container h1 {
    font-size: 2rem;
  }

  .blog-description {
    font-size: 1.1rem;
  }

  .image-container {
    max-width: 100%;
  }

  .component-images .image-container {
    max-width: 100%;
  }

  .blog-section {
    margin-bottom: 3rem;
  }

  .blog-section h2 {
    font-size: 1.8rem;
  }

  .toc-container {
    padding: 1.2rem;
  }

  .code-block {
    padding: 1.5rem;
    font-size: 0.85rem;
  }

  .nav-links {
    flex-direction: column;
    text-align: center;
  }

  .nav-right {
    text-align: center;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
  }

  .nav-right .button {
    width: 100%;
  }

  .blog-navigation {
    margin-bottom: 2rem;
  }

  /* Responsive table styles for mobile */
  .blog-section table {
    font-size: 0.85rem;
  }

  .blog-section table th,
  .blog-section table td {
    padding: 0.5rem;
  }

  .blog-section table code {
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
  }

  .image-container {
    padding: 1rem;
    margin: 2rem 0;
  }

  .component-images {
    padding: 1.5rem;
  }

  .code-header {
    font-size: 0.7rem;
    padding: 0.6rem 1rem;
  }
}

@media screen and (max-width: 480px) {
  .blog-header {
    padding: 2rem 0.5rem 1.5rem 0.5rem;
  }

  .blog-title-container h1 {
    font-size: 1.8rem;
  }

  .blog-post {
    padding: 1.5rem 0.8rem;
    border-radius: 8px;
  }

  .blog-section h2 {
    font-size: 1.6rem;
  }

  .blog-section p,
  .blog-section ul,
  .blog-section ol {
    font-size: 1rem;
  }

  .image-container {
    margin: 1.5rem 0;
    padding: 0.8rem;
  }

  /* Reduce padding for featured image on mobile */
  .blog-featured-image {
    padding: 0.5rem;
  }

  /* Make script index image container full width on mobile */
  .image-container[style*="max-width: 40%"] {
    max-width: 100% !important;
  }

  /* Make API key configuration image container full width on mobile */
  .image-container[style*="max-width: 60%"] {
    max-width: 100% !important;
  }

  /* Make FPDF2 library logo image container full width on mobile */
  .image-container[style*="max-width: 20%"] {
    max-width: 100% !important;
  }

  /* Make file structure image container full width on mobile */
  .image-container[style*="max-width: 30%"] {
    max-width: 100% !important;
  }

  .component-images .col-4 {
    margin-bottom: 1.5rem;
  }

  .toc-container {
    padding: 0.8rem;
  }

  .code-block {
    padding: 1rem;
    font-size: 0.8rem;
  }

  .code-header {
    font-size: 0.7rem;
    padding: 0.5rem 0.8rem;
  }
}
