/* Global Styles */
:root {
  --primary-color: #003366;
  --secondary-color: #0066cc;
  --text-color: #333333;
  --light-gray: #f5f5f5;
  --navbar-bg: var(--color-background-default);
  --navbar-text: var(--color-content-default);
  --footer-bg: #398376;
  --color-background-transparent-strong: rgba(0, 0, 0, 0.9);
  --color-content-knockout: var(--color-white-solid);
  --button-primary-color-content-default: var(--color-white-solid);
  --typography-title-default-font-family: Rubik;
  --typography-title-default-font-size: 2rem;
  --typography-title-default-font-weight: 600;
  --typography-title-default-line-height: 3rem;
  --typography-title-default-letter-spacing: -0.0625rem;
  --font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --max-width: 1440px;
  --content-padding: 2rem;
  --color-content-default: hsla(180, 10%, 12%, 1);
  --typography-display-default-font-family: Rubik;
  --typography-display-default-font-size: 5rem;
  --typography-display-default-font-weight: 600;
  --typography-display-default-line-height: 6rem;
  --typography-display-default-letter-spacing: -0.125rem;
  --typography-body-default-font-size: 1rem;
  --typography-body-default-font-weight: 400;
  --typography-body-default-line-height: 1.5rem;
  --typography-body-default-letter-spacing: 0rem;
  --typography-title-lg-font-family: Rubik;
  --typography-title-lg-font-size: 2.5rem;
  --typography-title-lg-font-weight: 600;
  --typography-title-lg-line-height: 3.75rem;
  --typography-title-lg-letter-spacing: -0.0625rem;
  --color-border-default: #afbbbb;
  --color-white-solid: #fff;
  --stroke-weight-1: 1px;
  --typography-title-sm-font-size: 1.5rem;
  --typography-title-sm-line-height: 2rem;
  --typography-title-xs-font-size: 1.25rem;
  --typography-title-xs-line-height: 1.75rem;
  --focus-ring-color: #0066cc;
  --focus-ring-width: 3px;
  --focus-ring-offset: 2px;
  --min-touch-target: 44px;
  --z-index-base: 1;
  --z-index-above: 2;
  --z-index-header: 10;
  --z-index-mobile-nav: 20;
  --z-index-modal: 30;
  --z-index-tooltip: 40;
  --z-index-skip-link: 50;
  --color-border-default-hover: #6b7373;
  --color-background-subtle: #e8eded;
  --color-content-default-hover: #111;
  --color-background-default: #feffff;
  --color-content-subtle: #646b76;
  --button-primary-color-background-default: #065996;
  --button-primary-color-background-hover: #033b66;
  --button-primary-color-border-default: #065996;
  --button-primary-color-border-hover: #033b66;
  --button-color-background-default: var(--color-white-solid);
  --button-color-background-hover: var(--color-white-solid);
  --button-color-content-default: #065996;
  --button-color-content-hover: #033b66;
  --color-background-utility-info: #dbefff;
  --color-border-utility-info: #0088e5;
}

/* Dark Mode Variables */
:root[data-theme="dark"] {
  /* Base colors */
  --primary-color: #4dabf7;
  --secondary-color: #339af0;
  --text-color: #e9ecef;
  --light-gray: #343a40;
  --navbar-bg: #212529;
  --navbar-text: #ffffff;
  --footer-bg: #2c3e50;

  /* Background colors */
  --color-background-default: #121212;
  --color-background-subtle: #1e1e1e;
  --color-background-transparent-strong: rgba(33, 37, 41, 0.9);
  --color-content-knockout: #e9ecef;

  /* Text colors */
  --color-content-default: #e9ecef;
  --color-content-subtle: #adb5bd;
  --color-content-default-hover: #f8f9fa;

  /* Border colors */
  --color-border-default: #495057;
  --color-border-default-hover: #6c757d;

  /* Button colors */
  --button-primary-color-background-default: #339af0;
  --button-primary-color-background-hover: #228be6;
  --button-primary-color-border-default: #339af0;
  --button-primary-color-border-hover: #228be6;
  --button-primary-color-content-default: #ffffff;
  --button-color-background-default: #343a40;
  --button-color-background-hover: #495057;
  --button-color-content-default: #e9ecef;
  --button-color-content-hover: #f8f9fa;
  --button-primary-color-background-active: #228be6;
  --button-primary-color-border-active: #228be6;
  --button-primary-color-content-active: #ffffff;

  /* Focus ring */
  --focus-ring-color: #339af0;

  /* Calculator specific colors */
  --color-background-utility-info: #1a3b5c;
  --color-border-utility-info: #339af0;
}

/* Dark Mode Overrides */
/* Important overrides for Bootstrap */
:root[data-theme="dark"] body {
  background-color: var(--color-background-default) !important;
  color: var(--text-color) !important;
}

:root[data-theme="dark"] .card {
  background-color: var(--color-background-subtle) !important;
  border-color: var(--color-border-default) !important;
}

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
  background-color: var(--color-background-subtle) !important;
  border-color: var(--color-border-default) !important;
  color: var(--text-color) !important;
}

:root[data-theme="dark"] .form-control:focus,
:root[data-theme="dark"] .form-select:focus {
  background-color: var(--color-background-subtle) !important;
  border-color: var(--focus-ring-color) !important;
  color: var(--text-color) !important;
}

/* Calculator text styles */
:root[data-theme="dark"] .calculator-content h2,
:root[data-theme="dark"] .calculator-content p,
:root[data-theme="dark"] .calculator-description {
  color: var(--text-color) !important;
}

/* Tab styles for dark mode */
:root[data-theme="dark"]
  .calculator-form
  .nav-tabs
  .nav-link:not(.active):hover {
  background: var(--color-background-default);
  color: var(--color-content-default);
  border-color: var(--color-border-default-hover);
  border-bottom: 1px solid var(--color-border-default-hover);
}

:root[data-theme="dark"] .calculator-form .nav-tabs .nav-link.active {
  background: var(--color-background-subtle);
  color: var(--color-content-default);
  border-color: var(--color-border-default);
  border-bottom-color: var(--color-background-subtle);
}

/* Dropdown chevron dark mode styles */
:root[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e9ecef' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

:root[data-theme="dark"] .choices[data-type*="select-one"]:after {
  border-color: var(--text-color) transparent transparent;
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--button-primary-color-content-default);
  cursor: pointer;
  font-size: 1rem;
  transition: opacity 0.2s ease;
}

.theme-toggle:hover {
  opacity: 0.8;
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Theme toggle icons */
.sun-icon,
.moon-icon {
  transition: opacity 0.2s ease;
}

.sun-icon {
  display: block;
}

.moon-icon {
  display: none;
}

:root[data-theme="dark"] .sun-icon {
  display: none;
}

:root[data-theme="dark"] .moon-icon {
  display: block;
}

/* Keep theme toggle visible in mobile menu */
@media (max-width: 1330px) {
  .theme-toggle {
    display: flex;
    margin-left: auto;
    margin-right: 1rem;
  }

  .nav-links.active .theme-toggle {
    display: flex;
  }
}

/* Apply Rubik to all elements */
html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
div,
input,
select,
textarea,
button,
label,
a,
li,
.nav-link,
.btn,
.form-control,
.form-select,
.card,
.card-body,
.card-title,
.card-text {
  font-family: var(--font-family);
}

body {
  color: var(--text-color);
  line-height: 1.6;
  background: var(--color-background-default);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
}

/* Content Container */
.content-container {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--content-padding);
  box-sizing: border-box;
}

/* Header Styles */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-index-header);
  width: 100%;
  background: var(--color-background-transparent-strong, rgba(0, 0, 0, 0.9));
  backdrop-filter: blur(40.2px);
}

/* Navbar Styles */
.navbar {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  background: var(--color-background-transparent-strong);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-index-header);
}

.navbar .content-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 var(--content-padding);
  box-sizing: border-box;
}

/* Navbar Brand */
.navbar-brand,
.navbar-dark .navbar-brand,
.navbar .navbar-brand {
  width: auto;
  flex-shrink: 0;
  color: var(--color-content-knockout);

  /* Nav bar title */
  font-family: var(--typography-title-default-font-family, Rubik);
  font-size: var(--typography-title-default-font-size, 2rem);
  font-style: normal;
  font-weight: var(--typography-title-default-font-weight, 600);
  line-height: var(--typography-title-default-line-height, 3rem); /* 150% */
  text-transform: uppercase;
  display: block;
  white-space: nowrap;
}

/* Ensure hover state maintains the white color */
.navbar-brand:hover,
.navbar-dark .navbar-brand:hover,
.navbar .navbar-brand:hover {
  color: var(--color-content-knockout);
}

/* Main content wrapper */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding);
  width: 100%;
}

/* Update main container padding */
main.container-fluid {
  width: 100%;
  padding: var(--content-padding) 0;
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  margin-top: 4rem;
}

/* Section Styles */
section {
  margin-bottom: 2rem;
  width: 100%;
}

h2 {
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  font-weight: bold;
}

/* Section Heading Focus Styles */
h2[tabindex="0"]:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
  padding: 0.5rem;
  margin: -0.5rem;
  background: var(--color-background-default);
  position: relative;
  z-index: var(--z-index-above);
}

/* Card styles */
.card {
  border-radius: 0.375rem;
  border: var(--stroke-weight-1) solid var(--color-border-default);
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.card-body {
  padding: var(--content-padding);
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Calculator Container */
.calculator-container .card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  height: auto;
  padding: 1rem;
  background: var(--color-white-solid);
}

/* Iframe Container */
.iframe-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  height: 100%;
  background: var(--light-gray);
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  /* Remove problematic CSS properties that were causing issues */
}

/* Ensure iframe fills container */
.iframe-container iframe.loaded {
  opacity: 1;
  height: 100% !important;
}

/* Improve iframe interaction and scrolling */
.iframe-container iframe {
  cursor: pointer;
  /* Ensure iframe can receive focus and handle scroll events properly */
}

.iframe-container iframe:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Better iframe scroll handling */
.iframe-container {
  /* Ensure iframe container can handle scroll events properly */
  position: relative;
}

/* Card body containing iframe should stretch */
.card-body .iframe-container {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

/* Skeleton Loader */
.skeleton-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--light-gray);
  overflow: hidden;
}

.skeleton-loader .content {
  padding: 2rem;
}

.skeleton-loader .header,
.skeleton-loader .line {
  background: #e0e0e0;
  background: linear-gradient(
    110deg,
    #ececec 8%,
    var(--light-gray) 18%,
    #ececec 33%
  );
  border-radius: 4px;
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

.skeleton-loader .header {
  width: 60%;
  height: 2rem;
  margin-bottom: 1.5rem;
}

.skeleton-loader .line {
  width: 100%;
  height: 1rem;
  margin-bottom: 1rem;
}

.skeleton-loader .line:nth-child(2) {
  width: 95%;
}
.skeleton-loader .line:nth-child(3) {
  width: 90%;
}
.skeleton-loader .line:nth-child(4) {
  width: 85%;
}
.skeleton-loader .line:last-child {
  width: 80%;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Loading Text for Screen Readers */
.sr-only-loading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hide skeleton when iframe is loaded */
.iframe-container.loaded .skeleton-loader {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
}

.iframe-container iframe {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.iframe-container iframe.loaded {
  opacity: 1;
}

/* Form Styles */
.form-label {
  font-weight: 500;
  color: var(--text-color);
}

.form-control {
  border: 1px solid var(--color-border-default);
  border-radius: 4px;
  padding: 0.5rem;
  max-width: 100%;
}

.btn-primary {
  display: inline-flex;
  padding: 0.5rem 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid #065996;
  background: #065996;
  transition: all 300ms ease-out;
  color: white;
  width: auto;
  text-decoration: none;
}

.btn-primary:hover {
  border: 1px solid #033b66;
  background: #033b66;
  text-decoration: none;
}

/* Calculator Result */
.calculator-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Calculator Result Container */
.calculator-result-container {
  display: flex;
  width: 100%;
  padding: 0.5rem 1rem;
  justify-content: space-between;
  align-items: center;
  border-radius: 0.375rem;
  border: 1px solid var(--color-border-utility-info, #0088e5);
  background: var(--color-background-utility-info, #dbefff);
  outline: none; /* Remove default focus outline */
  margin-top: 1rem; /* Add spacing from the element above */
}

.calculator-result-container:focus {
  box-shadow: 0 0 0 2px var(--primary-color);
}

/* Result Content Area */
.result-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  flex: 1;
  min-width: 0; /* Prevent flex item from overflowing */
}

/* Result Value */
.result-content h4 {
  width: 100%;
  color: var(--color-content-default, #1a1f1f);
  font-family: var(--typography-title-sm-font-family, Rubik);
  font-size: var(--typography-title-sm-font-size, 1.5rem);
  font-style: normal;
  font-weight: var(--typography-title-sm-font-weight, 600);
  line-height: var(--typography-title-sm-line-height, 2.375rem);
  letter-spacing: var(--typography-title-sm-letter-spacing, 0rem);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Result Label */
.result-content p {
  width: 100%;
  color: var(--color-content-subtle, #646b76);
  color: var(--color-content-subtle, color(display-p3 0.4 0.4196 0.4549));
  font-family: var(--typography-label-default-font-family, Rubik);
  font-size: var(--typography-label-default-font-size, 1rem);
  font-style: normal;
  font-weight: var(--typography-label-default-font-weight, 600);
  line-height: var(--typography-label-default-line-height, 1.5rem);
  letter-spacing: var(--typography-label-default-letter-spacing, 0rem);
  margin: 0;
}

/* Copy Value Button */
.copy-value {
  padding: 0.5rem 1rem;
  background-color: var(--button-color-background-default);
  border: 1px solid var(--button-primary-color-border-default);
  border-radius: 0.375rem;
  color: var(--button-color-content-default);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  margin-left: 1rem;
}

.copy-value:hover {
  background-color: var(--button-color-background-hover);
  border-color: var(--button-primary-color-border-hover);
  color: var(--button-color-content-hover);
}

.copy-value:focus-visible {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
}

.copy-value.active {
  background-color: var(--button-primary-color-background-active);
  border-color: var(--button-primary-color-border-active);
  color: var(--button-primary-color-content-active);
}

/* Remove old alert styles */
.calculator-result > div:not(:has(.calculator-result-container)) {
  display: none;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* Only show margin when result exists */
.calculator-result .calculator-result-container {
  margin-top: 1.5rem;
  margin-bottom: 0;
}

/* Form Field Container */
.calculator-form .form-group,
.calculator-form .mb-3 {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  width: 100%;
}

/* Label Styles - Apply to all form labels */
.calculator-form .form-label,
.calculator-form label {
  align-self: stretch;
  color: var(--color-content-default, #1a1f1f);
  color: var(--color-content-default, color(display-p3 0.1098 0.1216 0.1216));
  font-family: var(--typography-label-default-font-family, Rubik);
  font-size: var(--typography-label-default-font-size, 1rem);
  font-style: normal;
  font-weight: var(--typography-label-default-font-weight, 600);
  line-height: var(--typography-label-default-line-height, 1.5rem);
  letter-spacing: var(--typography-label-default-letter-spacing, 0rem);
  margin: 0;
}

/* Ensure inputs and selects stretch full width */
.calculator-form .form-control,
.calculator-form .form-select {
  width: 100%;
}

/* Nav Links Container */
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.nav-links .nav-link {
  display: inline-flex;
  padding: 0.625rem;
  justify-content: flex-start;
  align-items: center;
  gap: 0.625rem;
  color: var(--button-primary-color-content-default);
  text-decoration: none;
  transition: text-decoration 300ms ease-out;
  font-weight: 500;
  white-space: nowrap;
  font-size: 1rem; /* Set base font size */
  max-width: fit-content; /* Ensure button doesn't grow beyond content */
}

.nav-links .nav-link:hover {
  text-decoration: underline;
  color: var(--button-primary-color-content-default);
}

/* Hamburger Menu Button */
.menu-button {
  display: none; /* Hide by default */
  grid-column-gap: 0.1875em;
  grid-row-gap: 0.1875em;
  flex-flow: column;
  padding: 1em;
  font-size: 1em;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  border: none;
}

.menu-button-line {
  background-color: var(--color-white-solid);
  width: 2em;
  height: 0.1875em;
}

/* Mobile Menu */
@media (max-width: 1440px) {
  .menu-button {
    display: flex !important; /* Force display on mobile */
    margin-left: 1rem;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: 4rem; /* Start under the navbar */
    right: 0;
    width: auto;
    min-width: 12.5rem;
    max-width: 18rem;
    height: auto;
    background: var(--color-background-transparent-strong);
    backdrop-filter: blur(40.2px);
    padding: var(--content-padding);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1rem;
    z-index: var(--z-index-mobile-nav);
    border-radius: 0 0 0 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links .nav-link {
    color: var(--color-content-knockout) !important;
    font-size: 1rem;
    padding: 0.75rem;
    width: 100%;
    text-align: left;
    justify-content: flex-start;
  }

  /* Ensure content container maintains flex layout in mobile */
  .navbar .content-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .navbar-brand {
    font-size: var(--typography-title-sm-font-size, 1.5rem);
    line-height: var(--typography-title-sm-line-height, 2rem);
  }
}

@media (max-width: 768px) {
  .navbar,
  .main-content,
  .footer .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .container {
    padding: 0 1rem;
  }

  .iframe-container {
    max-width: 100%;
    min-height: 800px;
  }

  .iframe-container.reports-container {
    max-width: 100%;
    min-height: 500px;
  }

  h2 {
    font-size: 1.5rem;
  }

  .card-body {
    padding: 1rem;
  }

  #forms .row {
    flex-direction: column;
  }

  #forms .col-md-6 {
    width: 100%;
    margin-bottom: 1rem;
  }

  .navbar-brand,
  .navbar-dark .navbar-brand,
  .navbar .navbar-brand {
    font-size: var(--typography-title-xs-font-size, 1.25rem);
    line-height: var(--typography-title-xs-line-height, 1.75rem);
  }

  .nav-links {
    gap: 0.5rem;
  }

  .nav-link {
    padding: 0.375rem;
    font-size: 0.875rem;
  }

  :root {
    --content-padding: 1rem;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0.5rem var(--content-padding);
  }

  .navbar-brand {
    font-size: 1.25rem;
    line-height: 1.75rem;
  }

  .container {
    padding: 0 var(--content-padding);
    width: 100%;
  }

  .card {
    margin: 0 -0.75rem;
    border-radius: 0;
  }

  .card-body {
    padding: 0.75rem;
  }

  .nav-links {
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.375rem;
    font-size: 0.875rem;
  }

  :root {
    --content-padding: 0.75rem;
  }

  .calculator-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .calculator-container .card {
    width: 100%;
    margin: 0 auto;
  }

  .calculator-content {
    width: 100%;
    max-width: 100%;
  }
}

/* Footer Styles */
.footer {
  background: var(--color-background-transparent-strong);
  backdrop-filter: blur(40.2px);
  padding: 1.5rem 0;
  margin-top: 2rem;
  color: var(--color-white-solid);
  font-weight: 300;
  font-size: 1rem;
  width: 100%;
}

.footer .container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding);
}

.footer p {
  margin: 0;
  color: var(--color-white-solid);
}

/* Accessibility */
:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .header,
  .footer {
    display: none;
  }

  .card {
    border: none;
    box-shadow: none;
  }
}

/* Copy Value Button Styles */
.copy-value {
  /* Layout */
  display: inline-flex;
  padding: 0.5rem 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.625rem;

  /* Default state */
  border-radius: 0.375rem;
  border: 1px solid var(--button-primary-color-border-default);
  background: var(--button-color-background-default);
  color: var(--button-color-content-default);
  text-align: center;
  font-family: var(--font-family-Font-1, Rubik);
  font-size: var(--font-size-16, 1rem);
  font-style: normal;
  font-weight: var(--font-weight-400, 400);
  line-height: var(--line-height-24, 1.5rem);

  /* Animation */
  transition: all 300ms ease-out;
  cursor: pointer;

  /* Reset any browser defaults */
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  outline: none;
}

/* Hover state */
.copy-value:hover {
  border: 1px solid var(--button-primary-color-border-hover);
  background: var(--button-color-background-hover);
  color: var(--button-color-content-hover);
}

/* Active/Copied state */
.copy-value.active {
  border-radius: 0.375rem;
  border: 1px solid var(--button-primary-color-border-active);
  background: var(--button-primary-color-background-active);
  color: var(--button-primary-color-content-active);
}

/* Override any Bootstrap styles */
.copy-value.btn,
.copy-value.btn:hover,
.copy-value.btn:focus,
.copy-value.btn:active,
.copy-value.btn.active {
  all: unset; /* Reset all styles first */
  display: inline-flex;
  padding: 0.5rem 1rem;
  justify-content: center;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
}

/* Ensure the button inherits the correct styles even with Bootstrap */
.copy-value.btn {
  border-radius: 0.375rem;
  border: 1px solid var(--button-primary-color-border-default);
  background: var(--button-color-background-default);
  color: var(--button-color-content-default);
  text-align: center;
  font-family: var(--font-family-Font-1, Rubik);
  font-size: var(--font-size-16, 1rem);
  font-style: normal;
  font-weight: var(--font-weight-400, 400);
  line-height: var(--line-height-24, 1.5rem);
}

/* Override Bootstrap's alert button styles */
.alert .copy-value {
  background: var(--button-color-background-default);
  border: 1px solid var(--button-primary-color-border-default);
  color: var(--button-color-content-default);
}

.alert .copy-value.active {
  background: var(--button-primary-color-background-active);
  border: 1px solid var(--button-primary-color-border-active);
  color: var(--button-primary-color-content-active);
}

/* Add some spacing between form sections */
.form-group {
  margin-bottom: 1rem;
}

/* Make the calculator card match the form height */
#forms .card {
  height: 100%;
  min-height: 1200px;
}

/* Instruction Section */
.instruction-section {
  display: flex;
  align-items: flex-end;
  gap: 2rem;
  margin-bottom: 3rem;
  padding-top: 2rem;
  max-width: var(--max-width);
  width: 100%;
}

.instruction-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  max-width: 42.25rem;
  min-width: 0;
  outline: none;
}

.instruction-section h1 {
  color: var(--color-content-default);
  font-family: var(--typography-display-default-font-family);
  font-size: var(--typography-display-default-font-size);
  font-style: normal;
  font-weight: var(--typography-display-default-font-weight);
  line-height: var(--typography-display-default-line-height);
  letter-spacing: var(--typography-display-default-letter-spacing);
  margin: 0;
}

.instruction-section p {
  color: var(--color-content-default);
  font-family: var(--typography-display-default-font-family);
  font-size: var(--typography-body-default-font-size);
  font-style: normal;
  font-weight: var(--typography-body-default-font-weight);
  line-height: var(--typography-body-default-line-height);
  letter-spacing: var(--typography-body-default-letter-spacing);
  margin: 0;
}

.instruction-image {
  flex: 1;
  height: 100%;
  max-width: 42.25rem;
  width: 100%;
  min-width: 0;
  object-fit: cover;
  border-radius: 8px;
}

/* Update responsive styles for instruction content */
@media (max-width: 1330px) {
  .instruction-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .instruction-content {
    width: 100%;
    max-width: 42.25rem;
  }

  .instruction-image {
    display: none;
  }

  .instruction-section h1 {
    font-size: 3rem;
    line-height: 3.6rem;
  }
}

@media (max-width: 768px) {
  .instruction-section h1 {
    font-size: 2.5rem;
    line-height: 3rem;
  }
}

/* Report Section */
.report-section {
  display: flex;
  flex-direction: column;
  width: 42.25rem;
  gap: 1rem;
  margin-bottom: 2rem;
  outline: none;
}

.report-section:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
  background: var(--color-background-default);
  position: relative;
  z-index: var(--z-index-above);
}

.report-section h2 {
  color: var(--color-content-default);
  font-family: var(--typography-title-lg-font-family);
  font-size: var(--typography-title-lg-font-size);
  font-style: normal;
  font-weight: var(--typography-title-lg-font-weight);
  line-height: var(--typography-title-lg-line-height);
  letter-spacing: var(--typography-title-lg-letter-spacing);
  align-self: stretch;
  margin: 0;
  cursor: pointer;
}

.report-section p {
  color: var(--color-content-default);
  font-family: var(--typography-display-default-font-family);
  font-size: var(--typography-body-default-font-size);
  font-style: normal;
  font-weight: var(--typography-body-default-font-weight);
  line-height: var(--typography-body-default-line-height);
  letter-spacing: var(--typography-body-default-letter-spacing);
  margin: 0;
}

/* Calculator and Form Layout */
.form-calculator-container {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
}

.form-container {
  flex: 1;
}

.calculator-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Calculator Styles */
.calculator-container .card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  height: auto;
  padding: 1rem;
  background: var(--color-white-solid);
}

.calculator-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-bottom: 1.5rem;
  outline: none;
}

.calculator-content:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
  padding: 0.5rem;
  margin: -0.5rem;
  background: var(--color-background-default);
  position: relative;
  z-index: var(--z-index-above);
}

.calculator-container h2 {
  align-self: stretch;
  color: var(--color-content-default, #1a1f1f);
  color: var(--color-content-default, color(display-p3 0.1098 0.1216 0.1216));
  font-family: var(--typography-title-default-font-family, Rubik);
  font-size: var(--typography-title-default-font-size, 2rem);
  font-style: normal;
  font-weight: var(--typography-title-default-font-weight, 600);
  line-height: var(--typography-title-default-line-height, 3rem);
  letter-spacing: var(--typography-title-lg-letter-spacing, -0.0625rem);
  margin: 0;
}

.calculator-content h2 {
  margin: 0 0 0.5rem 0;
}

.calculator-content .calculator-description {
  margin: 0;
}

/* Calculator Content */
.calculator-content h2 {
  margin-bottom: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .report-section {
    width: 100%;
    max-width: 42.25rem;
  }

  .form-calculator-container {
    flex-direction: column;
  }

  .calculator-container {
    justify-content: flex-start;
  }

  .calculator-content {
    width: 100%;
    max-width: 29.625rem;
  }
}

/* Calculator Form */
.calculator-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 1rem;
}

/* Tab Container */
.calculator-form .nav-tabs {
  display: flex;
  align-items: stretch;
  align-content: flex-start;
  align-self: stretch;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border-default);
  margin: 0;
  padding: 0;
  gap: 0;
  min-height: 40px;
}

/* Base Tab Styles */
.calculator-form .nav-tabs .nav-link {
  display: flex;
  padding: 0.5rem 1rem;
  justify-content: center;
  align-items: center;
  height: 40px;
  gap: 0.625rem;
  border: 1px solid var(--color-border-default);
  border-radius: 0.375rem 0.375rem 0 0;
  text-align: center;
  position: relative;
  margin-right: -1px;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--typography-display-default-font-family, Rubik);
  font-size: var(--typography-body-default-font-size, 1rem);
  font-style: normal;
  font-weight: 400;
  line-height: var(--typography-body-default-line-height, 1.5rem);
  letter-spacing: var(--typography-body-default-letter-spacing, 0rem);
  pointer-events: auto;
  z-index: var(--z-index-base);
  width: fit-content; /* Use fit-content instead of fixed width */
  min-width: max-content; /* Ensure content doesn't wrap */
}

/* Inactive Tab Styles */
.calculator-form .nav-tabs .nav-link:not(.active) {
  background: var(--color-background-default);
  color: var(--color-content-subtle);
  border-bottom: 1px solid var(--color-border-default);
  margin-bottom: -1px;
  pointer-events: auto;
  z-index: var(--z-index-base);
  font-weight: 400; /* Ensure consistent font weight */
}

/* Inactive Tab Hover State (Light Mode) */
:root:not([data-theme="dark"])
  .calculator-form
  .nav-tabs
  .nav-link:not(.active):hover {
  background: var(--color-background-subtle);
  color: var(--color-content-default-hover);
  border-color: var(--color-border-default-hover);
  border-bottom: 1px solid var(--color-border-default-hover);
  pointer-events: auto;
  z-index: var(--z-index-above);
}

/* Active Tab Styles */
.calculator-form .nav-tabs .nav-link.active {
  color: var(--color-content-default);
  background: var(--color-background-default);
  border-color: var(--color-border-default);
  border-bottom-color: var(--color-background-default);
  margin-bottom: -1px;
  z-index: var(--z-index-above);
  font-weight: 600;
  pointer-events: auto;
}

/* Dark Mode Tab Styles */
:root[data-theme="dark"] .calculator-form .nav-tabs .nav-link:not(.active) {
  background: var(--color-background-subtle);
  color: var(--color-content-subtle);
  border-bottom: 1px solid var(--color-border-default);
  pointer-events: auto;
  z-index: var(--z-index-base);
}

:root[data-theme="dark"]
  .calculator-form
  .nav-tabs
  .nav-link:not(.active):hover {
  background: var(--color-background-default);
  color: var(--color-content-default);
  border-color: var(--color-border-default-hover);
  border-bottom: 1px solid var(--color-border-default-hover);
  pointer-events: auto;
  z-index: var(--z-index-above);
}

:root[data-theme="dark"] .calculator-form .nav-tabs .nav-link.active {
  background: var(--color-background-subtle);
  color: var(--color-content-default);
  border-color: var(--color-border-default);
  border-bottom-color: var(--color-background-subtle);
  pointer-events: auto;
  z-index: var(--z-index-above);
}

/* Tab Content Area */
.calculator-form .tab-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 0;
  margin-top: 1rem;
}

/* Choices.js Custom Styles */
.choices {
  margin-bottom: 0;
}

.choices__inner {
  background: var(--color-background-default, #feffff);
  border: 0.0625rem solid var(--color-border-default, #afbbbb);
  border-radius: 0.375rem;
  min-height: auto;
  padding: 0.5rem;
}

.choices__input {
  background: transparent;
}

.choices__list--dropdown {
  border: 0.0625rem solid var(--color-border-default, #afbbbb);
  border-radius: 0.375rem;
}

.choices__list--dropdown .choices__item--selectable {
  padding: 0.5rem;
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
  background: var(--color-background-default, #feffff);
  color: var(--color-content-default, #1a1f1f);
}

.choices[data-type*="select-one"]:after {
  border-color: var(--color-content-default, #1a1f1f) transparent transparent;
  right: 0.75rem;
}

/* Input Group Styles */
.calculator-form .input-group-text {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.calculator-form
  .input-group
  > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(
    .valid-feedback
  ):not(.invalid-tooltip):not(.invalid-feedback) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Accessibility - Focus Styles */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Custom focus styles for form controls */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
  outline: none;
}

/* Custom focus styles for buttons */
.btn:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px white;
}

/* Tab focus styles */
.calculator-form .nav-tabs .nav-link:focus-visible {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px 4px 0 0;
  position: relative;
  z-index: 2;
}

/* Copy button focus styles */
.copy-value:focus-visible {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
  border-radius: 4px;
  transform: scale(1.05);
}

/* Accessibility - Visually Hidden Elements */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Use higher specificity instead of !important */
.calculator-form .visually-hidden:focus,
.iframe-container .visually-hidden:focus {
  clip: auto;
  height: auto;
  width: auto;
  padding: 0.5rem;
  margin: 0.5rem;
  background: var(--color-background-default);
  border: 2px solid var(--secondary-color);
  border-radius: 4px;
  z-index: 100;
}

/* Ensure iframe container allows focus management */
.iframe-container {
  position: relative;
}

/* Ensure iframe escape button is still focusable */
.iframe-container .iframe-escape:focus {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--z-index-above);
  padding: 0.5rem;
  background: var(--color-white-solid);
  border: 2px solid var(--focus-ring-color);
}

/* Calculator return to tabs button positioning */
.calculator-form .calculator-return-to-tabs:focus {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--z-index-above);
}

/* Form Validation Styles */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #dc3545;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-select.is-invalid {
  padding-right: 4.125rem;
  background-position: right 0.75rem center, center right 2.25rem;
  background-size: 16px 12px, calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #dc3545;
}

.form-control:focus.is-invalid,
.form-select:focus.is-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Form Group spacing when validation is present */
.form-group:has(.is-invalid) {
  margin-bottom: 1.5rem;
}

/* Override any Bootstrap styles */
.navbar .nav-link {
  color: var(--button-primary-color-content-default);
}

.navbar .nav-link:hover {
  color: var(--button-primary-color-content-default);
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1440px) {
  .content-container {
    padding: 0 var(--content-padding);
    width: 100%;
  }
}

@media (max-width: 1200px) {
  .content-container {
    padding: 0 var(--content-padding);
    width: 100%;
  }
}

@media (max-width: 1024px) {
  .content-container {
    padding: 0 var(--content-padding);
    width: 100%;
  }

  .navbar {
    padding: 0.5rem var(--content-padding);
  }
}

@media (max-width: 768px) {
  .navbar,
  .main-content,
  .footer .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .container {
    padding: 0 1rem;
  }

  .iframe-container {
    max-width: 100%;
  }

  .iframe-container.reports-container {
    max-width: 100%;
  }

  h2 {
    font-size: 1.5rem;
  }

  .card-body {
    padding: 1rem;
  }

  #forms .row {
    flex-direction: column;
  }

  #forms .col-md-6 {
    width: 100%;
    margin-bottom: 1rem;
  }

  .navbar-brand,
  .navbar-dark .navbar-brand,
  .navbar .navbar-brand {
    font-size: var(--typography-title-xs-font-size, 1.25rem);
    line-height: var(--typography-title-xs-line-height, 1.75rem);
  }

  .nav-links {
    gap: 0.5rem;
  }

  .nav-link {
    padding: 0.375rem;
    font-size: 0.875rem;
  }

  :root {
    --content-padding: 1rem;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0.5rem var(--content-padding);
  }

  .navbar-brand {
    font-size: 1.25rem;
    line-height: 1.75rem;
  }

  .container {
    padding: 0 var(--content-padding);
    width: 100%;
  }

  .card {
    margin: 0 -0.75rem;
    border-radius: 0;
  }

  .card-body {
    padding: 0.75rem;
  }

  .nav-links {
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.375rem;
    font-size: 0.875rem;
  }

  :root {
    --content-padding: 0.75rem;
  }
}

.iframe-container.reports-container {
  max-width: 100%;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.iframe-container.reports-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
  overflow: auto;
}

/* Ensure iframe fills container */
.iframe-container.reports-container iframe.loaded {
  opacity: 1;
  height: 100% !important;
}

/* Form iframe container in existing projects section - now handled by specific card classes */

/* Specific card body heights */
.card-body.new-project-form-card {
  height: 1500px;
}

.card-body.existing-projects-reports-card {
  height: 700px;
}

.card-body.existing-projects-form-card {
  height: 700px;
}

.card-body.tn-allocation-form-card {
  height: 1500px;
}

/* Ensure all elements use border-box */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-width: 370px;
  overflow-x: auto;
}

#existing-projects {
  margin-bottom: 2rem;
}

#existing-projects .card:last-child {
  margin-bottom: 0;
}

#new-project {
  margin-bottom: 2rem;
}

#new-project .card:last-child {
  margin-bottom: 0;
}

@media (max-width: 370px) {
  html,
  body {
    min-width: 370px;
    overflow-x: auto;
  }
}

/* Skip Navigation */
.visually-hidden-focusable {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.visually-hidden-focusable:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--color-white-solid, #fff);
  color: var(--color-content-default, #000);
  padding: 0.5rem 1rem;
  border: 2px solid #000;
  z-index: 9999;
}

/* Touch Targets */
button,
.nav-link,
.form-control,
.form-select,
.btn {
  min-height: var(--min-touch-target);
  min-width: var(--min-touch-target);
}

/* High Contrast Mode */
@media (forced-colors: active) {
  .card {
    border: 2px solid CanvasText;
  }

  .btn-primary {
    border: 2px solid CanvasText;
  }

  .nav-link {
    border: 1px solid CanvasText;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Text Scaling */
html {
  font-size: 16px;
}

@media screen and (min-width: 768px) {
  html {
    font-size: 18px;
  }
}

/* Form Accessibility */
.form-control:focus,
.form-select:focus {
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #dc3545;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: #dc3545;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
  display: block;
}

/* Navigation Accessibility */
.navbar .nav-link {
  position: relative;
  padding: 0.5rem 1rem;
}

.navbar .nav-link:focus-visible {
  outline-offset: -2px;
}

/* Copy Value Button Accessibility */
.copy-value {
  position: relative;
  padding: 0.5rem 1rem;
  min-width: var(--min-touch-target);
  min-height: var(--min-touch-target);
}

.copy-value:focus-visible {
  outline-offset: 2px;
}

/* Hide stepper arrows from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

#nps-calculator-form button[type="submit"] {
  width: auto !important;
  display: inline-block !important;
}

/* Ensure form group doesn't force full width */
.calculator-form .form-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Dark Mode Copy Button Active State */
:root[data-theme="dark"] .copy-value.active {
  background: var(--button-primary-color-background-active);
  border-color: var(--button-primary-color-border-active);
  color: var(--button-primary-color-content-active);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navbar-text);
  text-decoration: none;
}
