/**
 * Savings Calculator Redesigned Styles
 * Complete redesign with visual components, sliders, popovers, and accordion
 */

/* ========================================
   CSS Variables for Theming
   ======================================== */
:root {
  /* Brand Colors */
  --apu-green: #7ABA08;
  --green-dark: #5a8b06;
  --apu-grey: #1E1E1E;
  --apu-white: #FFFFFF;

  /* Text Colors */
  --text-color-primary: rgb(30, 30, 30);
  --text-color-secondary: rgb(119, 119, 119);
  --text-white: #FFFFFF;

  /* Border & Background */
  --border-color-light: rgb(221, 221, 221);
  --bg-light: #F8F9FA;
  --overlay-dark: rgba(30, 30, 30, 0.8);

  /* Typography */
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 800;
  --font-weight-black: 900;

  /* Layout */
  --border-radius: 0.25rem;
  --slider-height: 8px;
  --thumb-size: 24px;
  --transition-speed: 0.3s;
}

/* ========================================
   Base Typography
   ======================================== */
body {
  font-family: var(--font-family-base);
  color: var(--text-color-primary);
  line-height: 1.6;
}

h2, h3, h4, h5, h6 {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Visual Heading
   ======================================== */
.visual-heading {
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-color-primary);
}

/* ========================================
   Visual Results Grid (1x4)
   ======================================== */
.visual-results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Visual Component Container */
.visual-component {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.visual-component:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Visual Background */
.visual-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-size 0.6s ease-out, background-position 0.6s ease-out;
}

/* Visual Background - 1 Year Layer (bottom, zooms) */
.visual-bg-1x {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-size 0.6s ease-out, background-position 0.6s ease-out;
}

/* Visual Background - 5 Year Layer (top, fades in/out, static) */
.visual-bg-5x {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover !important;
  background-position: center !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 1;
}

/* Show 5-year image when in 5-year mode */
.show-5x .visual-bg-5x {
  opacity: 1;
}

/* Visual Content Overlay */
.visual-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--text-white);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.visual-value {
  font-size: 3rem;
  font-weight: var(--font-weight-black);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.visual-label {
  font-size: 1.25rem;
  font-weight: var(--font-weight-semibold);
  text-transform: capitalize;
}

/* Percentage Component Overlay */
.percentage-component .percentage-overlay {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 35%; /* Default, will be updated by JS */
  background-color: var(--apu-green);
  opacity: 0.7;
  transition: width 0.4s ease;
  z-index: 1;
}

/* ========================================
   Calculator Wrapper
   ======================================== */
.calculator-wrapper {
  /*box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);*/
}

/* ========================================
   Slider Controls
   ======================================== */
.slider-controls {
  margin-bottom: 1.5rem;
}

.slider-control-group {
  margin-bottom: 2rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.slider-header label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-color-primary);
  margin-bottom: 0;
}

.slider-value {
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-color-primary);
}

/* Info Icon Buttons */
.info-icon,
.info-icon-small {
  background: none;
  border: none;
  padding: 0;
  color: var(--apu-green);
  font-size: 1rem;
  cursor: pointer;
  transition: color var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.info-icon:hover,
.info-icon-small:hover {
  color: var(--green-dark);
  transform: scale(1.1);
}

.info-icon:focus,
.info-icon-small:focus {
  outline: 2px solid var(--apu-green);
  outline-offset: 2px;
  border-radius: 50%;
}

/* Custom Range Slider Styling */
.custom-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--slider-height);
  background: var(--border-color-light);
  border-radius: 4px;
  outline: none;
  position: relative;
}

/* Webkit (Chrome, Safari, Edge) */
.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  background: var(--apu-green);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-range::-webkit-slider-thumb:hover {
  background: var(--green-dark);
  transform: scale(1.15);
}

.custom-range::-webkit-slider-thumb:active {
  transform: scale(1.05);
}

/* Firefox */
.custom-range::-moz-range-thumb {
  width: var(--thumb-size);
  height: var(--thumb-size);
  background: var(--apu-green);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-range::-moz-range-thumb:hover {
  background: var(--green-dark);
  transform: scale(1.15);
}

.custom-range::-moz-range-thumb:active {
  transform: scale(1.05);
}

.custom-range::-moz-range-track {
  width: 100%;
  height: var(--slider-height);
  background: var(--border-color-light);
  border-radius: 4px;
}

/* ========================================
   Savings Results Section
   ======================================== */
.savings-results {
  padding-top: 1.5rem;
  /*border-top: 2px solid var(--border-color-light);*/
}

.results-heading {
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
  margin-bottom: 1rem;
  color: var(--text-color-primary);
}

/* Period Toggle (Annual/5-Year) */
.period-toggle {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--border-color-light);
  border-radius: var(--border-radius);
}

.period-btn {
  padding: 0.5rem 1.5rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-color-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.period-btn.active {
  background: var(--apu-green);
  color: white;
}

.period-btn:hover:not(.active) {
  background: rgba(122, 186, 8, 0.1);
  color: var(--apu-green);
}

/* Results List */
.results-list {
  margin-top: 1rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px dotted var(--border-color-light);
}

.result-row:last-child {
  border-bottom: none;
}

.result-label-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-label {
  font-size: 1rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-color-primary);
}

.result-sublabel {
  font-size: 0.85rem;
  color: var(--text-color-secondary);
  margin-top: 0.25rem;
}

.result-value {
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold);
  color: var(--apu-green);
}

.payback-row .payback-value {
  color: var(--apu-green);
}

/* Total Savings */
.total-savings {
  padding-top: 1.5rem;
  border-top: 2px solid var(--border-color-light);
  text-align: center;
}

.total-label {
  font-size: 1rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-color-secondary);
  margin-bottom: 0.5rem;
}

.total-value {
  font-size: 2rem;
  font-weight: var(--font-weight-black);
  color: var(--apu-green);
}

/* ========================================
   Additional Benefits Accordion
   ======================================== */
.additional-benefits-wrapper {
  position: relative;
  height: 60px;
  overflow: visible;
}

.additional-benefits {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.benefits-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
  border-radius: var(--border-radius);
}

.benefits-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.benefits-header {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--apu-grey);
  color: white;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: var(--font-weight-semibold);
  transition: background var(--transition-speed) ease;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  order: 1;
}

.benefits-content {
  background: #1a1a1a;
  color: white;
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  order: 2;
  
}

.benefits-content.show {
  max-height: 600px;
  padding: 1.5rem;
  overflow-y: auto;
  /* Hide scrollbar for all browsers */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  height:540px;
}

.benefits-content.show::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.benefits-header:hover {
  background: #1a1a1a;
}

.arrow-icon {
  transition: transform var(--transition-speed) ease;
  font-size: 1.2rem;
  transform: rotate(180deg);
}

.benefits-header[aria-expanded="true"] .arrow-icon {
  transform: rotate(0deg);
}

/* Benefits List */
.benefits-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.benefit-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.benefit-item i {
  color: var(--apu-green);
  font-size: 1.2rem;
}

/* ROI Table */
.roi-table h6 {
  font-size: 1.1rem;
  font-weight: var(--font-weight-semibold);
  margin-bottom: 0.5rem;
}

.table-subtitle {
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 1rem;
}

.roi-table .table {
  color: white;
  font-size: 0.9rem;
}

.roi-table .table thead th {
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem;
  font-weight: var(--font-weight-semibold);
}

.roi-table .table tbody td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
}

.roi-table .table tr, 
.roi-table .table td, 
.roi-table .table th
{
  color:#fff;
  background-color: #1a1a1a;
}

.roi-table .table .table-highlight {
  background: rgba(122, 186, 8, 0.2);
}

/* ========================================
   Info Popover Modal
   ======================================== */
.info-popover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
  border-radius: var(--border-radius);
  overflow-y: auto;
}

.info-popover-overlay.show {
  opacity: 1;
}

.info-popover-modal {
  background: #1a1a1a;
  color: white;
  border-radius: var(--border-radius);
  width: 100%;
  padding: 2rem;
  position: relative;
  /*box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);*/
  transform: translateY(-10px);
  transition: transform var(--transition-speed) ease;
  margin-top: 1rem;
}

.info-popover-overlay.show .info-popover-modal {
  transform: translateY(0);
}

.popover-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-speed) ease;
}

.popover-close:hover {
  color: white;
}

.popover-title {
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
  margin-bottom: 1rem;
  padding-right: 2rem;
  color: white;
}

.popover-body {
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.6;
}

.popover-body h4 {
  font-size: 1.1rem;
  font-weight: var(--font-weight-semibold);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.popover-body p {
  margin-bottom: 1rem;
}

.popover-body ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.popover-body ul li {
  margin-bottom: 0.5rem;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablets and Below */
@media (max-width: 991px) {
  .visual-results-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .visual-heading {
    font-size: 1.75rem;
  }

  .visual-value {
    font-size: 2.5rem;
  }

  .visual-label {
    font-size: 1.1rem;
  }
}

/* Mobile Devices */
@media (max-width: 767px) {
  .visual-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .visual-heading {
    font-size: 1.5rem;
    text-align: center;
  }

  /* Ensure calculator sections are visible on mobile */
  .calculator-wrapper {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Debug: Make sure rows and columns are visible */
  .savings-calculator .row {
    display: flex !important;
  }

  .savings-calculator [class*='col-'] {
    display: block !important;
  }

  .visual-value {
    font-size: 2rem;
  }

  .visual-label {
    font-size: 1rem;
  }

  .slider-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .slider-value {
    font-size: 1.25rem;
  }

  .benefits-list {
    grid-template-columns: 1fr;
  }

  .period-toggle {
    display: flex;
    width: 100%;
  }

  .period-btn {
    flex: 1;
  }

  .total-value {
    font-size: 1.5rem;
  }
}

/* Small Mobile */
@media (max-width: 575px) {
  .calculator-wrapper {
    padding: 1.5rem 1rem !important;
  }

  .visual-value {
    font-size: 1.75rem;
  }

  .result-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .result-value {
    font-size: 1.1rem;
  }

  .info-popover-modal {
    padding: 1.5rem;
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  .info-icon,
  .info-icon-small,
  .benefits-header {
    display: none;
  }

  .benefits-content {
    display: block !important;
    max-height: none !important;
  }

  .visual-component {
    break-inside: avoid;
  }
}

/* ========================================
   Accessibility Enhancements
   ======================================== */

/* Focus Visible States */
.custom-range:focus-visible {
  outline: 2px solid var(--apu-green);
  outline-offset: 4px;
}

.period-btn:focus-visible,
.benefits-header:focus-visible {
  outline: 2px solid var(--apu-green);
  outline-offset: 2px;
}

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

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .visual-component {
    border: 2px solid currentColor;
  }

  .custom-range::-webkit-slider-thumb,
  .custom-range::-moz-range-thumb {
    border: 2px solid currentColor;
  }
}

/* ========================================
   Debug Panel
   ======================================== */
.debug-panel {
  background: #1a1a1a;
  color: #0f0;
  padding: 2rem 0;
  margin-top: 2rem;
  border-top: 2px solid var(--primary-color);
}

.debug-panel h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.debug-panel pre {
  background: #000;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1.5rem;
  margin: 0;
  overflow-x: auto;
  /*max-height: 600px;
  overflow-y: auto;*/
}

.debug-panel code {
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre;
}

.debug-panel .btn-success {
  background-color: var(--apu-green);
  border-color: var(--apu-green);
  color: #000;
  font-weight: var(--font-weight-semibold);
}

.debug-panel .btn-success:hover {
  background-color: #8ab50a;
  border-color: #8ab50a;
  color: #000;
}


#export-csv-btn{
  color:#fff;
  padding-left: 1rem;
  padding-right: 1rem;
}