/* Reset and basic layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: #fafafa;
  color: #333;
  padding: 120px 20px 40px; /* Added 20px side padding for all screens */
  line-height: 1.6; /* Improved readability for body text */
}

/* --- Navbar styles --- */
.navbar {
  background-color: #ffffff;
  border-bottom: 1px solid #ddd;
  padding: 12px 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo img {
  height: 30px;
  display: block;
}

.company-name {
  font-size: 28px;
  font-weight: 700;
  color: #000000;
  text-decoration: none;
}

/* Hamburger Menu */
.menu-toggle {
  cursor: pointer;
  display: none; /* Hidden by default, shown on mobile */
}

.hamburger {
  font-size: 24px;
  color: #2c3e50;
}

/* Desktop Nav Links */
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links li a {
  text-decoration: none;
  color: #2c3e50;
  font-size: 16px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links li a:hover {
  color: #007BFF;
}

/* Overlay Menu */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.overlay.active {
  display: flex;
}

.close-menu {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  color: #2c3e50;
  cursor: pointer;
  padding: 5px 10px;
}

.close-menu:hover {
  color: #007BFF;
}

.overlay-nav-links {
  list-style: none;
  text-align: center;
}

.overlay-nav-links li {
  margin: 20px 0;
}

.overlay-nav-links a {
  text-decoration: none;
  color: #2c3e50;
  font-size: 24px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.overlay-nav-links a:hover {
  color: #007BFF;
}

/* Header */
header {
  text-align: center;
  margin: 30px auto 0;
  position: relative;
  z-index: 900;
  max-width: 750px;
  width: 750px; /* Fixed width to match blog post images */
  margin-left: auto;
  margin-right: auto;
  padding: 0;
}

header h1 {
  font-size: 28px;
  color: #2c3e50;
}

header p {
  font-size: 16px;
  color: #555;
  margin-top: 5px;
}

.hero-image {
  width: 750px;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
  object-fit: cover;
}

/* Calculator Container */
.calculator-container {
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 30px;
  margin: 20px auto 40px; /* Centered with auto margins */
  max-width: 1000px; /* Fixed maximum width */
  width: 100%; /* Allows scaling down */
}

.calculator-container > * {
  max-width: 1000px; /* Ensures all child elements respect the 1000px limit */
  margin-left: auto;
  margin-right: auto;
}

select {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  color: #333;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

select:focus {
  outline: none;
  border-color: #007BFF;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

/* Sections */
main {
  max-width: 1000px; /* Increased to match calculator width on home page */
  margin: 0 auto;
  padding: 0;
}

main.blog-page {
  max-width: 750px; /* Restrict blog page to 750px */
}

.blog-section {
  max-width: 750px;
  margin: 40px auto 0; /* Top margin for spacing between sections */
  padding: 0;
}

.section-image {
  width: 750px;
  height: auto;
  display: block;
  margin: 0 auto 20px; /* Padding below image */
  border-radius: 8px;
  object-fit: cover;
}

.blog-section h2 {
  font-size: 24px;
  color: #2c3e50;
  margin-bottom: 15px; /* Padding between title and text */
}

.blog-section p {
  font-size: 16px; /* Readable text size */
  color: #555;
  line-height: 1.6; /* Improved line spacing for readability */
  margin-bottom: 20px; /* Padding below text on desktop */
}

/* Contact Form */
.contact-section {
  margin-top: 40px;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 750px; /* Match the blog-section width */
  margin-top: 20px;
  width: 100%; /* Ensure it takes full available width */
}

.contact-form .input-group {
  position: relative;
}

.contact-form .input-group input,
.contact-form .input-group textarea {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: white;
}

.contact-form .input-group textarea {
  resize: vertical;
  min-height: 100px;
}

.contact-form button {
  padding: 10px 20px;
  background-color: #0C8CD2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  transition: background-color 0.2s ease;
  width: fit-content; /* Button width adjusts to content */
  align-self: flex-start; /* Align button to start */
}

.contact-form button:hover {
  background-color: #0A73AD;
}

/* Input groups with unit inside input field */
.input-group {
  position: relative;
  margin-top: 5px; /* Space between label and input */
}

.input-group input[type="number"] {
  width: 100%;
  padding: 10px 106px 10px 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: white;
}

/* Unit positioned inside input field on the right */
.unit {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 100px;
  background-color: #eee;
  color: #333;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* Tooltip icon (SVG) next to label */
.tooltip-icon {
  position: relative;
  display: inline-block;
  margin-left: 5px; /* Space between label and icon */
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle; /* Align with label text */
  z-index: 100;
  background-image: url('images/tooltip-icon.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Tooltip popup box */
.tooltip {
  display: none;
  position: absolute;
  background-color: #fff;
  border: 1px solid #ddd;
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 99999;
  font-size: 14px;
  width: 250px;
  white-space: normal;
  top: 20px;
  left: 20px;
  color: #333;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  visibility: hidden;
}

/* Create an invisible bridge area between icon and tooltip to maintain hover */
.tooltip::before {
  content: '';
  position: absolute;
  top: -25px;
  left: -25px;
  width: 30px;
  height: 30px;
  background: transparent;
  z-index: 99998;
}

/* Triangle arrow pointing left from tooltip */
.tooltip::after {
  content: '';
  position: absolute;
  top: 15px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid #ddd;
  z-index: 100000;
}

/* Clickable example values in tooltip */
.tooltip-example {
  display: block;
  margin: 4px 0;
  padding: 4px 8px;
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-decoration: none;
  color: #333;
}

.tooltip-example:hover {
  background-color: #e9ecef;
  color: #007BFF;
}

/* Show tooltip on hover over the tooltip-icon or the tooltip itself */
.tooltip-icon:hover .tooltip,
.tooltip:hover {
  display: block;
  opacity: 1;
  visibility: visible;
}

/* Buttons */
.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  padding: 10px 14px;
  border: none;
  background-color: #e0e0e0;
  cursor: pointer;
  font-size: 16px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

button:hover {
  background-color: #d0d0d0;
}

button.active {
  background-color: #007BFF;
  color: white;
}

/* Calculate and Reset buttons */
.buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 25px;
  margin-bottom: 30px;
}

.buttons button {
  background-color: #0C8CD2;
  color: white;
  font-weight: bold;
  padding: 10px 14px;
  border: none;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.buttons button:hover {
  background-color: #0A73AD;
}

.buttons button:last-child {
  background-color: #95a5a6;
}

.buttons button:last-child:hover {
  background-color: #7f8c8d;
}

/* Results */
.results-section {
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  width: 100%;
  box-sizing: border-box;
}

.results-section h2 {
  margin-bottom: 10px;
  font-size: 20px;
  color: #2c3e50;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 40px;
  font-size: 14px;
  color: #888;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#downloadPdfBtn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #2c3e50;
  padding: 4px;
  transition: color 0.2s ease;
}

#downloadPdfBtn:hover {
  color: #007BFF;
}

.results-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.results-row .result-box {
  flex: 1;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.result-box {
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  padding-top: 22px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.result-box .label {
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
}

.result-box .value {
  font-size: 26px;
  font-weight: 600;
  color: #2c3e50;
}

.blog-list {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 20px 0;
}

.blog-card {
  display: flex;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: transform 0.2s ease;
}

.blog-card:hover {
  transform: translateY(-2px);
}

.blog-card img {
  width: 250px;
  height: auto;
  object-fit: cover;
}

.blog-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.blog-content h2 {
  font-size: 20px;
  margin-bottom: 10px;
  color: #2c3e50;
}

.blog-content p {
  font-size: 15px;
  color: #555;
  margin-bottom: 10px;
}

.blog-content a {
  font-weight: 500;
  color: #007BFF;
  text-decoration: none;
}

.blog-content a:hover {
  text-decoration: underline;
}

/* Blog Post */
.blog-post {
  max-width: 750px;
  margin: 0 auto;
  width: 750px; /* Fixed width to match images */
}

/* New layout grid for input rows */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* Full width sections (unit selector and annual distance) */
.full-width-section {
  margin-bottom: 20px;
}

/* Chart wrapper */
.chart-wrapper {
  width: 100%;
  height: 600px;
  margin: 20px auto;
  position: relative;
}

#savingsChart {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

/* Responsive chart sizing */
@media (max-width: 600px) {
  .chart-wrapper {
    height: 400px;
  }
}

@media (max-width: 800px) {
  .chart-wrapper {
    height: 500px;
  }
}

/* ---------------- MOBILE (<768px) ---------------- */
@media (max-width: 768px) {
  .input-grid {
    grid-template-columns: 1fr;
  }

  .buttons {
    flex-direction: column;
    gap: 12px;
  }

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

  .calculator-container {
    max-width: 100%;
    width: 100%; /* Full width on mobile */
    padding: 20px;
  }

  .contact-form {
    max-width: 100%;
  }

  header h1 {
    font-size: 22px;
  }

  header p {
    font-size: 14px;
  }

  .menu-toggle {
    display: block; /* Show hamburger on tablet and below */
  }

  .nav-links {
    display: none; /* Hide desktop nav links on mobile */
  }

  .hero-image, .section-image {
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
  }

  .blog-post {
    max-width: 100%;
    width: 100%;
    padding: 0;
  }

  header {
    max-width: 100%;
    width: 100%;
    padding: 0;
  }

  .blog-section {
    margin: 20px auto 0;
  }

  .blog-section p {
    margin-bottom: 40px; /* Increased padding below text on mobile */
  }

  body {
    padding: 120px 10px 40px; /* Reduced side padding on mobile for narrower screens */
  }

  /* Stack results boxes vertically on mobile */
  .results-row {
    flex-direction: column;
    gap: 15px; /* Reduced gap for vertical layout */
  }

  .results-row .result-box {
    width: 100%; /* Ensure each box takes full width */
  }
}

/* ---------------- TABLET (<800px) ---------------- */
@media (max-width: 800px) {
  .input-grid {
    grid-template-columns: 1fr;
  }

  .calculator-container {
    max-width: 100%;
    width: 100%; /* Full width on tablet */
    padding: 24px;
  }

  .contact-form {
    max-width: 100%;
  }

  .hero-image, .section-image {
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
  }

  .blog-post {
    max-width: 100%;
    width: 100%;
    padding: 0;
  }

  header {
    max-width: 100%;
    width: 100%;
    padding: 0;
  }

  .blog-section {
    margin: 20px auto 0;
  }

  body {
    padding: 120px 15px 40px; /* Adjusted side padding for tablet */
  }
}

.results-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.results-summary-box {
  margin: 20px 0;
  padding: 16px;
  border-radius: 10px;
  background-color: #e6f5ec;
  border: 1px solid #b9e6ce;
  color: #2a7a4b;
  font-size: 1.1rem;
  text-align: center;
  font-weight: 500;
}

.input-error {
  border-color: #e74c3c !important;
}

/* Ensure the main content is left-aligned */
.blog-page {
  text-align: left; /* Left-align all text within main */
}

/* Left-align headings and paragraphs in blog-section */
.blog-section {
  text-align: left;
}

/* Left-align form elements in contact-section */
.contact-section .contact-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Left-align form inputs */
}

/* Ensure form inputs and textarea take full width and align left */
.contact-form .input-group {
  width: 100%; /* Ensure inputs stretch to container width */
  text-align: left;
}

.contact-form input,
.contact-form textarea {
  text-align: left; /* Ensure text inside inputs is left-aligned */
}

/* Optional: Style the submit button to align left */
.contact-form button {
  align-self: flex-start; /* Align button to the left */
}