/* Reset & Base Styles */
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background-color: #F5F5F5;
  color: #333333;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-x: hidden;
}
*, *::before, *::after {
  box-sizing: inherit;
}

.result-intro {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 10px;
}

.error-message {
  display: none;
  color: #b00020;
  background-color: #ffe5e5;
  border: 1px solid #b00020;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 1.125rem;
  font-weight: bold;
  border-radius: 4px;
}

.clear-btn {
  display: none;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  background-color: #AAAAAA;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  margin-top: 10px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.clear-btn:hover {
  background-color: #888888;
}

/* Header & Navigation */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background-color: #FFFFFF;
  color: #000000;
  padding: 0 20px;
  z-index: 2000;
  border-bottom: 2px solid #000000;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.header-container h1 {
  margin: 0;
  font-size: 24px;
}

/* Desktop Navigation */
nav {
  height: 100%;
}
nav > ul#nav-menu {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0 20px;
  height: 100%;
  align-items: center;
  overflow-x: auto;
  color: #000000;
  background-color: transparent;
}
nav > ul#nav-menu a {
  display: inline-flex;
  align-items: center;
  padding: 0.75em 1em;
  font-size: 1.125rem;
  color: #000000;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 0.3s;
}
nav > ul#nav-menu a:hover,
nav > ul#nav-menu a:focus {
  background-color: #EAEAEA;
  color: #000000;
}

/* Hamburger Button (mobile only) */
#hamburger {
  display: none;
  position: fixed;
  top: 18px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 2100;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
#hamburger span {
  width: 100%;
  height: 4px;
  background: #000000;
  border-radius: 2px;
}

/* Default: Show desktop logo, hide mobile */
.logo-desktop {
  display: block;
}
.logo-mobile {
  display: none;
}

/* On smaller screens, switch to mobile logo */
@media (max-width: 768px) {
  .logo-desktop {
    display: none;
  }
  .logo-mobile {
    display: block;
  }
}

/* Push page content below header */
main {
  margin-top: 70px;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  gap: 60px;
  flex-wrap: wrap;
}

/* Calculator Panel */
.calculator {
  background-color: #FFFFFF;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 500px;
}

/* Advertisement Panel */
.advertisement {
  width: 300px;
  border: 1px solid #B0B0B0;
  border-radius: 8px;
  align-self: stretch;
}
@media (max-width: 800px) {
  .advertisement {
    display: none;
  }
}

/* Section Title */
.section-title {
  font-size: 2.5em;
  margin-bottom: 20px;
  text-align: center;
}

/* Form Elements */
label {
  display: block;
  margin: 15px 0 5px;
  font-size: 18px;
}
input[type="number"],
select {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  border: 1px solid #B0B0B0;
  border-radius: 6px;
  margin-bottom: 20px;
  background-color: #FFFFFF;
  color: #333333;
}

/* Height Fields Layout */
.height-wrapper {
  display: flex;
  gap: 50px;
  margin-bottom: 20px;
}

.height-field {
  flex: 1;
}

.height-field input[type="number"] {
  margin-bottom: 0;
}

#heightMetricWrapper {
  margin-bottom: 20px;
}

#heightMetricWrapper input[type="number"] {
  margin-bottom: 0;
}

/* Calculate Button */
.calc-btn {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  font-weight: bold;
  background-color: #333333;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.calc-btn:hover {
  background-color: #4A4A4A;
}

/* Result Display */
.main-size {
  font-size: 3em;
  font-weight: bold;
  margin-bottom: 0.35em;
}
.size-standards small {
  display: block;
  line-height: 1.6;
  font-size: 1.15rem;
}
.result {
  margin-top: 25px;
  text-align: center;
}

/* Unit Toggle */
.unit-toggle {
  display: flex;
  border: 1px solid #B0B0B0;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}
.toggle-label {
  flex: 1;
  text-align: center;
  padding: 16px 0;
  font-size: 18px;
  cursor: pointer;
  background-color: #F5F5F5;
  color: #4A4A4A;
  transition: background-color 0.3s;
}
.toggle-label:hover {
  background-color: #E5E5E5;
}
.toggle-label.active {
  background-color: #333333;
  color: #FFFFFF;
}

/* Tooltips */
.info {
  display: inline-block;
  background-color: #DDD;
  color: #333333;
  border-radius: 50%;
  padding: 2px 6px;
  margin-left: 5px;
  font-size: 0.8em;
  position: relative;
}
.info:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 125%;
  transform: translateX(-50%);
  background-color: #4A4A4A;
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: 4px;
  white-space: normal;
  line-height: 1.4;
  z-index: 1002;
  width: 200px;
}
.info:hover::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 115%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #4A4A4A transparent transparent transparent;
  z-index: 1001;
}

/* Measurement Guide */
.measurement-guide {
  background-color: #FFFFFF;
  border: 1px solid #B0B0B0;
  border-radius: 8px;
  padding: 30px;
  margin: 60px auto;
  max-width: 800px;
}
.measurement-guide h3 {
  font-size: 2.4em;
  margin-bottom: 20px;
  text-align: center;
}
.measurement-guide h4 {
  font-size: 1.8em;
  margin-top: 30px;
  margin-bottom: 10px;
}
.measurement-guide p {
  font-size: 18px;
  line-height: 1.6;
}
.diagram-placeholder {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 30px;
  border: 3px dashed #B0B0B0;
  border-radius: 6px;
  box-sizing: border-box;
}
.diagram-placeholder img {
  display: block;
  width: 100%;
  height: auto;
}

/* Other Calculator Tools */
.other-calculators {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 0 20px;
  max-width: 900px;
  margin: 60px auto;
}
.other-calculators h3 {
  width: 100%;
  font-size: 2.2em;
  margin-bottom: 20px;
  text-align: center;
}
.other-calculators .calc-card {
  flex: 0 0 260px;
  height: 260px;
  background-color: #FFFFFF;
  border: 1px solid #B0B0B0;
  border-radius: 8px;
  padding-top: 60px;
  padding-right: 30px;
  padding-left: 30px;
  padding-bottom: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
  color: #333333;
  font-size: 20px;
  text-decoration: none;
  transition: background-color 0.3s, box-shadow 0.3s;
  white-space: normal;
  overflow-wrap: break-word;
}
.other-calculators .calc-card:hover {
  background-color: #E8E8E8;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.other-calculators .calc-card .card-img-placeholder {
  width: 100%;
  height: 140px;
  background-color: #F5F5F5;
  border: 1px dashed #B0B0B0;
  margin: 0 0 8px;
  border-radius: 6px;
}

/* Footer */
footer {
  background-color: #4A4A4A;
  color: #FFFFFF;
  padding: 30px 20px;
  text-align: center;
}
.footer-links {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.footer-links .column {
  flex: 1;
  min-width: 150px;
  margin: 10px;
}
.footer-links h3 {
  margin-top: 0;
}
.footer-links ul {
  list-style: none;
  padding: 0;
}
.footer-links li {
  margin-bottom: 5px;
}
.footer-links a {
  color: #FFFFFF;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}

/* Mobile Menu (only under 768px) */
@media (max-width: 768px) {
  #hamburger {
    display: flex;
  }
  nav > ul#nav-menu {
    display: none;
  }
  #nav-menu {
    display: none;
  }
  #nav-menu.active {
    display: flex;
    position: fixed;
    top: 70px;
    right: 0;
    width: 260px;
    background: rgba(51,51,51,0.95);
    border-radius: 0 0 0 8px;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.2);
    flex-direction: column;
    padding: 10px 0;
    max-height: none !important;
    overflow-y: visible !important;
    z-index: 1999;
    animation: slideIn 0.3s ease-out forwards;
  }
  @keyframes slideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
  }
  #nav-menu.active li {
    width: 100%;
  }
  #nav-menu.active li a {
    display: block;
    width: 100%;
    padding: 15px 20px;
    color: #FFFFFF;
    text-decoration: none;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    box-sizing: border-box;
  }
  #nav-menu.active li:not(:last-child) a {
    border-bottom: 1px solid rgba(255,255,255,0.2);
  }
  #nav-menu.active li a:hover {
    background: rgba(255,255,255,0.1);
    color: #FFFFFF;
  }
}

/* Mobile-friendly: reduce side padding & let calculator grow */
@media (max-width: 600px) {
  body, main {
    padding: 0 10px;
  }

  .calculator {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 20px 10px;
  }

  .clear-btn,
  .calc-btn {
    padding: 14px;
    font-size: 1rem;
  }

  .other-calculators {
    gap: 10px;
    padding: 0 10px;
  }

  .height-wrapper {
    gap: 20px;
  }
}