/* ==========================================================================
   Pole Sensor Benefit Analysis Tool - Complete Stylesheet
   AmbientGrid Color Scheme and Typography
   ========================================================================== */

/* Google Fonts Import for IBM Plex Sans */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   CSS RESET
   ========================================================================== */
   
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   CSS VARIABLES - LIGHT MODE (DEFAULT)
   ========================================================================== */
:root {
  /* Primary Palette */
  --primary-blue: #0077c5;
  --dark-teal: #00727C;
  --smoky-gray: #4F4B45;
  --slate-black: #1A1A1A;
  
  /* Secondary/Utility Palette */
  --warm-beige: #fdf9f4;
  --soft-cloud-gray: #f2f4f6;
  --signal-yellow: #FFC72C;
  --fire-alert-orange: #D6452A;
  --eco-green: #4CB944;
  
  /* UI States */
  --primary-blue-hover: #0069b0;
  --primary-blue-active: #005a99;
  --primary-blue-light: rgba(0, 119, 197, 0.1);
  
  /* Borders */
  --border-color: rgba(0, 0, 0, 0.1);
  --border-light: rgba(0, 0, 0, 0.05);
  
  /* Typography */
  --font-family: 'IBM Plex Sans', 'Segoe UI', 'Helvetica Neue', sans-serif;
  --heading-size: 1.5rem;
  --subheading-size: 1.25rem;
  --body-size: 1rem;
  --caption-size: 0.875rem;
  --formula-size: 0.875rem;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Layout */
  --border-radius: 1rem;
  --panel-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  --transition-speed: 300ms;
}

/* ==========================================================================
   DARK MODE VARIABLES (SLEEP-FRIENDLY)
   ========================================================================== */
[data-theme="sleep"] {
  /* BACKGROUNDS - Very dark, low blue-light emission */
  --warm-beige: #0d0d0d;
  --soft-cloud-gray: #161616;
  --input-background: #1f1f1f;
  --hover-background: #252525;
  
  /* TEXT - Reduced brightness, warm tones */
  --slate-black: #d4d4d4;
  --smoky-gray: #a0a0a0;
  --muted-text: #787878;
  
  /* BRAND COLORS - Muted for night use */
  --primary-blue: #0066a5;
  --primary-blue-hover: #0077c5;
  --dark-teal: #3d8e90;
  --signal-yellow: #d4a017;
  --fire-alert-orange: #d64545;
  --eco-green: #4a9d4a;
  
  /* BORDERS - Very subtle */
  --border-color: #333333;
  --border-light: rgba(255, 255, 255, 0.08);
  
  /* FOCUS STATES - Subtle glows */
  --focus-glow: rgba(0, 102, 165, 0.3);
  --primary-blue-light: rgba(0, 102, 165, 0.15);
  
  /* SHADOWS */
  --panel-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  --modal-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */
html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
}

body {
  background-color: var(--warm-beige);
  color: var(--slate-black);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Page Content */
.page-content {
    margin-top: 70px;
}

/* First section padding to match homepage */
.page-content > section:first-child {
    padding-top: 70px !important;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: bold;
  color: var(--slate-black);
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 1.75rem; }
h2 { font-size: var(--heading-size); }
h3 { 
  font-size: var(--subheading-size);
  color: var(--primary-blue);
}

p {
  margin-bottom: var(--spacing-md);
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-container {
  display: flex;
  flex: 1;
  padding: var(--spacing-md);
  gap: var(--spacing-md);
  overflow: hidden;
}

/* ==========================================================================
   SAVE/IMPORT BAR
   ========================================================================== */
.save-import-bar {
  background-color: var(--soft-cloud-gray);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  box-shadow: var(--panel-shadow);
}

.bar-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.bar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.bar-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-blue);
}

.bar-actions {
  display: flex;
  gap: var(--spacing-sm);
}

/* PM Toggle in top bar */
.pm-toggle-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.pm-toggle-container .toggle-switch {
  transform: scale(0.9);
}

.pm-toggle-container .toggle-label {
  font-size: 0.9rem;
  color: var(--slate-black);
  user-select: none;
}

/* Status messages */
.status-message {
  margin-left: var(--spacing-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.status-message.success { color: var(--eco-green); }
.status-message.error { color: var(--fire-alert-orange); }
.status-message.info { color: var(--primary-blue); }

/* ==========================================================================
   CATEGORY TABS PANEL (LEFT)
   ========================================================================== */
.category-tabs-panel {
  flex: 0 0 15%;
  min-width: 180px;
  background-color: var(--soft-cloud-gray);
  border-radius: var(--border-radius);
  box-shadow: var(--panel-shadow);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.category-tabs-panel .panel-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.category-tabs-panel .panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary-blue);
}

[data-theme="sleep"] .category-tabs-panel .panel-header h3 {
  color: var(--slate-black);
}

.category-tabs {
  flex: 1;
  padding: var(--spacing-sm);
}

.category-tab {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-xs);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--smoky-gray);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  font-family: var(--font-family);
  font-size: 0.9rem;
}

.category-tab:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--slate-black);
}

.category-tab.active {
  background-color: var(--primary-blue-light);
  border-left-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 500;
}

[data-theme="sleep"] .category-tab:hover {
  background-color: var(--hover-background);
}

/* ==========================================================================
   PARAMETER PANEL (CENTER)
   ========================================================================== */
.parameter-panel {
  flex: 0 0 35%;
  background-color: var(--soft-cloud-gray);
  border-radius: var(--border-radius);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.parameter-panel .panel-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.parameter-panel .panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--slate-black);
}

#active-tab-title {
  font-size: 0.9rem;
  color: var(--primary-blue);
  margin-top: var(--spacing-xs);
}

.parameter-content {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

.parameters-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

/* Panel footer */
.panel-footer {
  margin-top: auto;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
}

/* ==========================================================================
   BENEFIT PANEL (RIGHT)
   ========================================================================== */
.benefit-panel {
  flex: 1;
  background-color: var(--soft-cloud-gray);
  border-radius: var(--border-radius);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.benefit-panel .panel-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.benefit-panel .panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--slate-black);
}

#benefit-summary {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

/* Benefit summary section */
.benefit-summary {
  margin-bottom: var(--spacing-lg);
}

.benefit-total-section {
  text-align: center;
  padding: var(--spacing-lg);
  background-color: white;
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-md);
}

[data-theme="sleep"] .benefit-total-section {
  background-color: #1a1a1a;
}

.benefit-total-section h3 {
  margin: 0 0 var(--spacing-sm) 0;
  font-size: 1.1rem;
  color: var(--smoky-gray);
}

.total-benefit {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--primary-blue);
  transition: all 0.3s ease;
}

[data-theme="sleep"] .total-benefit {
  color: #1a8cd8;
}

/* PM/GM Split */
.benefit-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.split-item {
  padding: var(--spacing-md);
  background-color: white;
  border-radius: calc(var(--border-radius) / 2);
  text-align: center;
}

[data-theme="sleep"] .split-item {
  background-color: #1a1a1a;
}

.split-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: var(--spacing-xs);
}

.split-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
}

.split-percentage {
  display: block;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Benefit categories */
.section-separator {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--spacing-lg) 0;
}

.categories-heading {
  margin-bottom: var(--spacing-md);
  font-size: 1.1rem;
}

.benefit-categories {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.benefit-category {
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: calc(var(--border-radius) / 2);
  overflow: hidden;
  transition: all 0.3s ease;
}

[data-theme="sleep"] .benefit-category {
  background-color: var(--input-background);
  border-color: var(--border-color);
}

.benefit-category:hover {
  border-color: var(--primary-blue);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  cursor: pointer;
  user-select: none;
}

.header-content {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: var(--spacing-md);
}

.category-title {
  font-weight: 600;
  color: var(--primary-blue);
}

.category-value {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--slate-black);
}

.expand-icon {
  color: var(--smoky-gray);
  transition: transform 0.3s ease;
}

.benefit-category.expanded .expand-icon {
  transform: rotate(180deg);
}

.category-content {
  padding: 0 var(--spacing-md) var(--spacing-md) var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

/* Category breakdown */
.category-breakdown {
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm);
  background-color: var(--soft-cloud-gray);
  border-radius: calc(var(--border-radius) / 4);
}

[data-theme="sleep"] .category-breakdown {
  background-color: #1a1a1a;
}

.breakdown-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-xs) 0;
}

.breakdown-label {
  flex: 0 0 150px;
  font-size: 0.9rem;
}

.breakdown-value {
  font-weight: 600;
  margin-right: var(--spacing-sm);
}

.breakdown-percentage {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Calculation details */
.category-calculations {
  margin-top: var(--spacing-md);
}

.category-calculations h4 {
  margin: 0 0 var(--spacing-md) 0;
  font-size: 1rem;
  color: var(--slate-black);
}

.calculation-detail {
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  background-color: var(--soft-cloud-gray);
  border-radius: calc(var(--border-radius) / 4);
  border-left: 3px solid var(--primary-blue);
}

[data-theme="sleep"] .calculation-detail {
  background-color: #1a1a1a;
}

.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xs);
}

.calc-name {
  font-weight: 500;
  color: var(--slate-black);
}

.calc-value {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary-blue);
}

.calc-formula,
.calc-inputs {
  font-size: 0.85rem;
  margin-top: var(--spacing-xs);
  color: var(--smoky-gray);
}

.formula-label,
.inputs-label {
  font-weight: 500;
  margin-right: var(--spacing-xs);
}

.formula-text {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--slate-black);
}

[data-theme="sleep"] .formula-text {
  background-color: rgba(255, 255, 255, 0.05);
  color: #d4d4d4;
}

.inputs-list {
  font-style: italic;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--smoky-gray);
}

.empty-state h3 {
  margin-bottom: var(--spacing-md);
  color: var(--smoky-gray);
}

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */
.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}

.form-label {
  display: block;
  font-weight: 500;
  color: var(--slate-black);
}

.form-control {
  width: 100%;
  padding: var(--spacing-sm);
  border: 1px solid #ddd;
  border-radius: calc(var(--border-radius) / 2);
  font-family: var(--font-family);
  font-size: var(--body-size);
  background-color: white;
  color: var(--slate-black);
  transition: all var(--transition-speed) ease;
}

[data-theme="sleep"] .form-control {
  background-color: var(--input-background);
  border-color: var(--border-color);
  color: #e0e0e0;
}

.form-control:focus {
  border-color: var(--primary-blue);
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-blue-light);
}

[data-theme="sleep"] .form-control:focus {
  background-color: var(--hover-background);
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.form-control:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

[data-theme="sleep"] .form-control:disabled {
  background-color: #1a1a1a;
  color: var(--muted-text);
  border-color: #303030;
}

/* Remove spinner arrows on number inputs */
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type='number'] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* Numeric inputs */
.numeric-input {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.numeric-input .form-control {
  flex: 1;
  text-align: right;
}

.input-suffix {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--smoky-gray);
}

/* Slider inputs */
.slider-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.slider-container .slider {
  flex: 1;
}

.slider-container .numeric-input {
  flex: 0 0 120px;
}

.slider {
  width: 100%;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  appearance: none;
  outline: none;
}

[data-theme="sleep"] .slider {
  background: #303030;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
}

[data-theme="sleep"] .slider::-webkit-slider-thumb {
  background: var(--primary-blue);
  border: 2px solid #161616;
  width: 18px;
  height: 18px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Toggle switches */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

[data-theme="sleep"] .toggle-slider {
  background-color: #505050;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

[data-theme="sleep"] .toggle-slider:before {
  background-color: var(--slate-black);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
  background-color: var(--primary-blue);
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

[data-theme="sleep"] input:checked + .toggle-slider:before {
  background-color: white;
}

.toggle-label {
  margin-left: var(--spacing-sm);
  font-size: var(--caption-size);
  color: var(--smoky-gray);
}

/* Select dropdowns */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem top 50%;
  background-size: 0.65rem auto;
  padding-right: 2rem;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--body-size);
  line-height: 1.5;
  border-radius: calc(var(--border-radius) / 2);
  transition: all var(--transition-speed) ease;
  cursor: pointer;
  font-family: var(--font-family);
}

.btn-primary {
  color: white;
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-primary:hover {
  background-color: var(--primary-blue-hover);
  border-color: var(--primary-blue-hover);
}

[data-theme="sleep"] .btn-primary:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  color: var(--primary-blue);
  background-color: transparent;
  border-color: var(--primary-blue);
}

.btn-secondary:hover {
  background-color: var(--primary-blue-light);
}

[data-theme="sleep"] .btn-secondary {
  color: #1a8cd8;
  border-color: #1a8cd8;
}

[data-theme="sleep"] .btn-secondary:hover {
  color: #2d9deb;
  border-color: #2d9deb;
  background-color: var(--primary-blue-light);
}

.btn-alert {
  color: white;
  background-color: var(--fire-alert-orange);
  border-color: var(--fire-alert-orange);
}

.btn-icon {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 1.2rem;
  min-width: auto;
  background: transparent;
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  background-color: var(--primary-blue-light);
  border-color: var(--primary-blue);
}

.theme-toggle {
  margin-right: var(--spacing-md);
}

/* ==========================================================================
   TOOLTIPS
   ========================================================================== */
.tooltip {
  position: relative;
  display: inline-block;
  margin-left: var(--spacing-xs);
  cursor: help;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--smoky-gray);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: var(--slate-black);
  color: white;
  text-align: center;
  border-radius: var(--border-radius);
  padding: var(--spacing-sm);
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
  font-size: var(--caption-size);
}

[data-theme="sleep"] .tooltip-text {
  background-color: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #404040;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   VALIDATION & ERRORS
   ========================================================================== */
.has-error .form-control {
  border-color: var(--fire-alert-orange);
  box-shadow: 0 0 0 2px rgba(214, 69, 42, 0.15);
}

.error-message {
  color: var(--fire-alert-orange);
  font-size: var(--caption-size);
  margin-top: var(--spacing-xs);
  animation: fadeIn var(--transition-speed) ease;
}

.required-badge {
  color: var(--fire-alert-orange);
  margin-left: var(--spacing-xs);
}

/* ==========================================================================
   ALERTS
   ========================================================================== */
.alert {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border-radius: calc(var(--border-radius) / 2);
  background-color: var(--soft-cloud-gray);
}

.alert-info {
  background-color: rgba(0, 119, 197, 0.1);
  color: var(--primary-blue);
}

.alert-warning {
  background-color: rgba(255, 199, 44, 0.1);
  color: #856404;
}

.alert-danger {
  background-color: rgba(214, 69, 42, 0.1);
  color: var(--fire-alert-orange);
}

[data-theme="sleep"] .alert {
  border: 1px solid var(--border-color);
}

[data-theme="sleep"] .alert-info {
  background-color: rgba(0, 119, 197, 0.1);
  color: #4da3d9;
  border-color: rgba(77, 163, 217, 0.3);
}

[data-theme="sleep"] .alert-warning {
  background-color: rgba(255, 204, 77, 0.1);
  color: var(--signal-yellow);
  border-color: rgba(255, 204, 77, 0.3);
}

[data-theme="sleep"] .alert-danger {
  background-color: rgba(255, 107, 107, 0.1);
  color: var(--fire-alert-orange);
  border-color: rgba(255, 107, 107, 0.3);
}

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.text-muted {
  color: var(--smoky-gray);
}

.calculated-note {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--smoky-gray);
}

[data-theme="sleep"] .calculated-note {
  color: var(--muted-text);
}

/* Value displays */
.pm-value {
  color: var(--primary-blue);
  font-weight: 500;
}

.gm-value {
  color: var(--dark-teal);
  font-weight: 500;
}

[data-theme="sleep"] .pm-value {
  color: #1a8cd8;
}

[data-theme="sleep"] .gm-value {
  color: #5db3b6;
}

.total-value {
  color: var(--slate-black);
  font-weight: bold;
}

.positive { color: var(--eco-green); }
.warning { color: var(--signal-yellow); }
.alert { color: var(--fire-alert-orange); }

[data-theme="sleep"] .positive { color: #5ECF5E; }
[data-theme="sleep"] .warning { color: #f5c842; }
[data-theme="sleep"] .alert { color: #ff6b6b; }

/* ==========================================================================
   LOADING & OVERLAYS
   ========================================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}

[data-theme="sleep"] .loading-overlay {
  background: rgba(13, 13, 13, 0.9);
  color: var(--slate-black);
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-blue);
  animation: spin 1s ease-in-out infinite;
}

[data-theme="sleep"] .spinner {
  border-color: rgba(184, 184, 184, 0.1);
  border-top-color: var(--primary-blue);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

[data-theme="sleep"] .modal-overlay {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: var(--warm-beige);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

[data-theme="sleep"] .modal-content {
  background-color: var(--soft-cloud-gray);
  color: var(--slate-black);
  border: 1px solid var(--border-color);
  box-shadow: var(--modal-shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.close-button {
  background: transparent;
  border: none;
  color: var(--smoky-gray);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.close-button:hover {
  background-color: var(--hover-background);
  color: var(--slate-black);
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes highlight-pulse {
  0%   { background-color: transparent; }
  50%  { background-color: rgba(179, 134, 0, 0.2); }
  100% { background-color: transparent; }
}

@keyframes highlight-pulse-sleep {
  0%   { background-color: transparent; }
  50%  { background-color: rgba(179, 134, 0, 0.15); }
  100% { background-color: transparent; }
}

.fade-in {
  animation: fadeIn var(--transition-speed) ease;
}

.highlight {
  animation: highlight-pulse 1.5s ease;
}

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

:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

.focus-outline:focus-visible {
  outline: 2px dashed var(--primary-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1200px) {
  .category-tabs-panel {
    flex: 0 0 200px;
  }
  
  .parameter-panel {
    flex: 0 0 300px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .category-tabs-panel,
  .parameter-panel,
  .benefit-panel {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }
  
  .category-tabs-panel {
    min-height: 200px;
    max-height: 250px;
  }
  
  .save-import-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .bar-left,
  .bar-right {
    justify-content: center;
  }
  
  .bar-title {
    font-size: 1.1rem;
  }
  
  .benefit-split {
    grid-template-columns: 1fr;
  }
  
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
  }
  
  .breakdown-item {
    flex-wrap: wrap;
  }
  
  .breakdown-label {
    flex: 1 1 100%;
    margin-bottom: var(--spacing-xs);
  }
  
  .slider-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .slider-container .numeric-input {
    flex: 1 1 auto;
  }
  
  .parameter-panel .panel-header {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
  
  .parameter-panel .panel-header h2 {
    flex: 1 1 100%;
  }

  
/* ==========================================================================
   KPI CIRCLE INTEGRATION FOR BENEFIT PANEL
   ========================================================================== */
/* ==========================================================================
   KPI CIRCLE INTEGRATION FOR BENEFIT PANEL
   ========================================================================== */

/* Adjust category header layout to accommodate KPI circle */
.benefit-category .category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  cursor: pointer;
  user-select: none;
}

/* Header content container - flex for KPI + title + value */
.benefit-category .header-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-right: var(--spacing-md);
}

/* Left side container for KPI + title */
.benefit-category .header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex: 1;
}

/* KPI Circle specific styling when inside benefit category */
.benefit-category .category-kpi-circle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Adjust the KPI solid circle size for the benefit panel */
.benefit-category .kpi-solid-circle {
  width: 40px;
  height: 40px;
}

/* Ensure the inner circle respects the container size */
.benefit-category .kpi-circle {
  max-width: 40px;
  max-height: 40px;
}

/* Category title styling - ensure it doesn't wrap */
.benefit-category .category-title {
  font-weight: 600;
  color: var(--primary-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Category value styling - align to the right */
.benefit-category .category-value {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--slate-black);
  margin-left: auto;
  white-space: nowrap;
}

/* Expand icon styling */
.benefit-category .expand-icon {
  color: var(--smoky-gray);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

/* Dark mode adjustments */
[data-theme="sleep"] .benefit-category .category-title {
  color: var(--primary-blue);
}

[data-theme="sleep"] .benefit-category .category-value {
  color: var(--slate-black);
}

/* Hover effects */
.benefit-category:hover .category-kpi-circle .kpi-circle {
  transform: scale(1.1) !important;
  transition: transform 0.2s ease;
}

/* Animation sync between KPI and category */
.benefit-category.updating .category-kpi-circle .kpi-percentage {
  animation: pulse 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .benefit-category .header-content {
    gap: var(--spacing-xs);
  }
  
  .benefit-category .header-left {
    gap: var(--spacing-xs);
  }
  
  .benefit-category .kpi-solid-circle {
    width: 32px;
    height: 32px;
  }
  
  .benefit-category .kpi-circle {
    max-width: 32px;
    max-height: 32px;
  }
  
  .benefit-category .category-title {
    font-size: 0.9rem;
  }
  
  .benefit-category .category-value {
    font-size: 1rem;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .benefit-category .header-content {
    flex-wrap: wrap;
  }
  
  .benefit-category .category-value {
    flex: 1 1 100%;
    margin-left: 0;
    margin-top: var(--spacing-xs);
    padding-left: calc(32px + var(--spacing-xs)); /* Indent to align with title */
  }
}

/* Loading state for KPI circles */
.benefit-category .category-kpi-circle.loading {
  opacity: 0.5;
}

.benefit-category .category-kpi-circle.loading .kpi-circle {
  animation: spin 1s linear infinite;
}

/* Ensure proper alignment when categories are expanded */
.benefit-category.expanded .category-header {
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--spacing-md);
}

/* Optional: Add connecting line from KPI to content when expanded */
.benefit-category.expanded .category-content {
  position: relative;
  padding-left: calc(40px + var(--spacing-md)); /* Align with title */
}

.benefit-category.expanded .category-content::before {
  content: '';
  position: absolute;
  left: 20px; /* Center of 40px KPI circle */
  top: calc(-1 * var(--spacing-md));
  bottom: var(--spacing-md);
  width: 1px;
  background-color: var(--border-color);
  opacity: 0.3;
}

[data-theme="sleep"] .benefit-category.expanded .category-content::before {
  background-color: var(--border-color);
  opacity: 0.2;
}

/* Smooth transitions for all interactive elements */
.benefit-category .category-kpi-circle,
.benefit-category .category-title,
.benefit-category .category-value,
.benefit-category .expand-icon {
  transition: all 0.3s ease;
}

/* Focus states for accessibility */
.benefit-category .category-header:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: -2px;
  border-radius: calc(var(--border-radius) / 2);
}

/* Print styles */
@media print {
  .benefit-category .category-kpi-circle {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* Add this to your styles.css file in the Calculation details section */

.calc-parameters {
  font-size: 0.85rem;
  margin-top: var(--spacing-xs);
  color: var(--smoky-gray);
  font-family: monospace;
}

[data-theme="sleep"] .calc-parameters {
  color: #888;
}

/* Optional: Style the parameters to stand out a bit more */
.calc-parameters::before {
  content: '➤ ';
  margin-right: 4px;
}


}

/* Add this to your styles.css file in the Calculation details section */

.calc-parameters {
  font-size: 0.85rem;
  margin-top: var(--spacing-xs);
  color: var(--smoky-gray);
  font-family: monospace;
}

[data-theme="sleep"] .calc-parameters {
  color: #888;
}

/* Optional: Style the parameters to stand out a bit more */
.calc-parameters::before {
  content: '➤ ';
  margin-right: 4px;
}

/* Calculation Steps Styling */
.calc-steps {
  margin-top: var(--spacing-sm);
  padding-left: var(--spacing-md);
  border-left: 2px solid var(--primary-blue);
}

[data-theme="sleep"] .calc-steps {
  border-left-color: var(--dark-teal);
}

.calc-step {
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
}

.calc-step.final-step {
  border-top: 1px solid var(--border-color);
  padding-top: var(--spacing-sm);
  margin-top: var(--spacing-xs);
}

.step-formula {
  font-size: 0.9rem;
  color: var(--smoky-gray);
  margin-bottom: 2px;
}

.step-label {
  font-weight: 500;
  color: var(--slate-black);
}

[data-theme="sleep"] .step-label {
  color: var(--slate-black);
}

.step-equals {
  color: var(--primary-blue);
  font-weight: 600;
}

.step-formula-text {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--smoky-gray);
}

.step-calculation {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--slate-black);
  background-color: rgba(0, 0, 0, 0.03);
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: var(--spacing-md);
}

[data-theme="sleep"] .step-calculation {
  background-color: rgba(255, 255, 255, 0.05);
  color: #d4d4d4;
}

.step-calc-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.final-step .step-calculation {
  background-color: var(--primary-blue-light);
  font-weight: 600;
}

[data-theme="sleep"] .final-step .step-calculation {
  background-color: rgba(0, 102, 165, 0.2);
}

/* Mobile adjustments for calculation steps */
@media (max-width: 768px) {
  .calc-steps {
    padding-left: var(--spacing-sm);
    font-size: 0.85rem;
  }
  
  .step-calculation {
    margin-left: var(--spacing-sm);
    font-size: 0.8rem;
  }
}

/* Add this to your styles.css file in the Calculation details section */

.calc-parameters {
  font-size: 0.85rem;
  margin-top: var(--spacing-xs);
  color: var(--smoky-gray);
  font-family: monospace;
}

[data-theme="sleep"] .calc-parameters {
  color: #888;
}

/* Optional: Style the parameters to stand out a bit more */
.calc-parameters::before {
  content: '➤ ';
  margin-right: 4px;
}

/* Calculation Steps Styling */
.calc-steps {
  margin-top: var(--spacing-sm);
  padding-left: var(--spacing-md);
  border-left: 2px solid var(--primary-blue);
}

[data-theme="sleep"] .calc-steps {
  border-left-color: var(--dark-teal);
}

.calc-step {
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
}

.calc-step.final-step {
  border-top: 1px solid var(--border-color);
  padding-top: var(--spacing-sm);
  margin-top: var(--spacing-xs);
}

.step-formula {
  font-size: 0.9rem;
  color: var(--smoky-gray);
  margin-bottom: 2px;
}

.step-label {
  font-weight: 500;
  color: var(--slate-black);
}

[data-theme="sleep"] .step-label {
  color: var(--slate-black);
}

.step-equals {
  color: var(--primary-blue);
  font-weight: 600;
}

.step-formula-text {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--smoky-gray);
}

.step-calculation {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--slate-black);
  background-color: rgba(0, 0, 0, 0.03);
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: var(--spacing-md);
}

[data-theme="sleep"] .step-calculation {
  background-color: rgba(255, 255, 255, 0.05);
  color: #d4d4d4;
}

.step-calc-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.final-step .step-calculation {
  background-color: var(--primary-blue-light);
  font-weight: 600;
}

[data-theme="sleep"] .final-step .step-calculation {
  background-color: rgba(0, 102, 165, 0.2);
}

/* Mobile adjustments for calculation steps */
@media (max-width: 768px) {
  .calc-steps {
    padding-left: var(--spacing-sm);
    font-size: 0.85rem;
  }
  
  .step-calculation {
    margin-left: var(--spacing-sm);
    font-size: 0.8rem;
  }


  /* Parameter hover highlighting */
.parameter-hover-highlight {
  border: 2px solid var(--dark-teal) !important;
  box-shadow: 0 0 8px rgba(0, 114, 124, 0.3) !important;
  transition: all 0.2s ease;
  position: relative;
}

.parameter-hover-highlight::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: rgba(0, 114, 124, 0.05);
  border-radius: var(--border-radius);
  pointer-events: none;
}

[data-theme="sleep"] .parameter-hover-highlight {
  border-color: var(--dark-teal) !important;
  box-shadow: 0 0 12px rgba(61, 142, 144, 0.5) !important;
}

[data-theme="sleep"] .parameter-hover-highlight::before {
  background: rgba(61, 142, 144, 0.1);
}

/* Make formula text more interactive on hover */
.step-formula-text[style*="cursor: help"]:hover,
.step-calc-text[style*="cursor: help"]:hover {
  color: var(--primary-blue);
  text-decoration: underline;
  text-decoration-style: dotted;
}

/* Smooth scroll behavior for parameter highlighting */
html {
  scroll-behavior: smooth;
}

/* Add animation for parameter highlight */
@keyframes parameterPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

.parameter-hover-highlight .form-group {
  animation: parameterPulse 0.5s ease-in-out;
}

/* Mobile adjustments for calculation steps */
@media (max-width: 768px) {
  .calc-steps {
    padding-left: var(--spacing-sm);
    font-size: 0.85rem;
  }
  
  .step-calculation {
    margin-left: var(--spacing-sm);
    font-size: 0.8rem;
  }
}


/* Parameter hover highlighting */
.form-group.parameter-hover-highlight {
  border: 2px solid var(--dark-teal) !important;
  box-shadow: 0 0 8px rgba(0, 114, 124, 0.3) !important;
  transition: all 0.2s ease;
  position: relative;
  padding: var(--spacing-md);
  margin: calc(var(--spacing-md) * -1);
  margin-bottom: var(--spacing-lg);
}

[data-theme="sleep"] .form-group.parameter-hover-highlight {
  border-color: #5db3b6 !important;
  box-shadow: 0 0 12px rgba(93, 179, 182, 0.5) !important;
}

/* Make formula text more interactive on hover */
.step-formula-text[style*="cursor: help"]:hover,
.step-calc-text[style*="cursor: help"]:hover {
  color: var(--dark-teal);
  text-decoration: underline;
  text-decoration-style: dotted;
  font-weight: 600;
}

[data-theme="sleep"] .step-formula-text[style*="cursor: help"]:hover,
[data-theme="sleep"] .step-calc-text[style*="cursor: help"]:hover {
  color: #5db3b6;
}


/* Individual parameter name hover styling */
.param-hover {
  transition: all 0.2s ease;
  cursor: help;
  display: inline-block;
}

.param-hover:hover {
  color: var(--dark-teal) !important;
  font-weight: 600;
  transform: scale(1.05);
}

[data-theme="sleep"] .param-hover:hover {
  color: #5db3b6 !important;
}


}


/* Parameter hover highlighting - OUTSIDE the media query */
.form-group.parameter-hover-highlight {
  border: 3px solid var(--dark-teal) !important;
  box-shadow: 0 0 12px rgba(0, 114, 124, 0.4) !important;
  background-color: rgba(0, 114, 124, 0.05) !important;
  transition: all 0.2s ease;
  transform: scale(1.02);
}


/* Click feedback animation */
.form-group.parameter-clicked {
  animation: parameterClick 0.5s ease;
}

@keyframes parameterClick {
  0% {
    transform: scale(1);
    background-color: transparent;
  }
  50% {
    transform: scale(1.05);
    background-color: rgba(0, 114, 124, 0.2);
  }
  100% {
    transform: scale(1);
    background-color: transparent;
  }
}

/* Make parameter names look clickable on hover */
.param-hover {
  cursor: pointer !important;
}

.param-hover:hover {
  text-decoration: underline;
  text-decoration-style: dotted;
}

/* ==========================================================================
   CALCULATED VARIABLE HIGHLIGHTING
   ========================================================================== */

/* Calculated variable hover styles */
.calc-var-hover {
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-block;
  position: relative;
  z-index: 1;
}

.calc-var-hover:hover {
  color: #0077c5 !important;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
  transform: scale(1.05);
}

[data-theme="sleep"] .calc-var-hover:hover {
  color: #4da3d9 !important;
}

/* Tooltip on calc-var-hover */
.calc-var-hover:hover::after {
  content: "Click to see definition";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.9;
  z-index: 10;
  margin-bottom: 4px;
}

[data-theme="sleep"] .calc-var-hover:hover::after {
  background: #555;
}

/* Highlight the step when hovering over a calculated variable */
.calc-step.step-highlighted {
  background-color: rgba(0, 119, 197, 0.1);
  border-radius: 4px;
  padding: var(--spacing-xs);
  margin: calc(var(--spacing-xs) * -1);
  transition: all 0.2s ease;
}

[data-theme="sleep"] .calc-step.step-highlighted {
  background-color: rgba(77, 163, 217, 0.1);
}

/* Flash animation when clicking on a calculated variable */
@keyframes step-flash {
  0% { background-color: rgba(0, 119, 197, 0.1); }
  50% { background-color: rgba(0, 119, 197, 0.3); }
  100% { background-color: rgba(0, 119, 197, 0.1); }
}

@keyframes step-flash-dark {
  0% { background-color: rgba(77, 163, 217, 0.1); }
  50% { background-color: rgba(77, 163, 217, 0.3); }
  100% { background-color: rgba(77, 163, 217, 0.1); }
}

.calc-step.step-flashed {
  animation: step-flash 1s ease-in-out;
}

[data-theme="sleep"] .calc-step.step-flashed {
  animation: step-flash-dark 1s ease-in-out;
}

/* Variable referenced state (when hovering over the label) */
.variable-referenced {
  color: #0077c5 !important;
  font-weight: 600 !important;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

[data-theme="sleep"] .variable-referenced {
  color: #4da3d9 !important;
}

.variable-referenced-param {
  color: #0077c5 !important;
  font-weight: 600 !important;
}

[data-theme="sleep"] .variable-referenced-param {
  color: #4da3d9 !important;
}

/* Interactive calculated variable labels */
.calc-var-label {
  transition: all 0.2s ease;
  cursor: pointer !important;
  display: inline-block;
}

.calc-var-label:hover {
  color: #0077c5 !important;
  font-weight: 600 !important;
  transform: scale(1.05);
}

[data-theme="sleep"] .calc-var-label:hover {
  color: #4da3d9 !important;
}

/* Ensure consistent highlighting for all variable references */
.variable-referenced,
.variable-referenced-param,
.calc-var-hover.variable-referenced,
.param-hover.variable-referenced-param {
  color: #0077c5 !important;
  font-weight: 600 !important;
  background-color: rgba(0, 119, 197, 0.05);
  padding: 0 2px;
  border-radius: 2px;
  transition: all 0.2s ease;
}

[data-theme="sleep"] .variable-referenced,
[data-theme="sleep"] .variable-referenced-param,
[data-theme="sleep"] .calc-var-hover.variable-referenced,
[data-theme="sleep"] .param-hover.variable-referenced-param {
  color: #4da3d9 !important;
  background-color: rgba(77, 163, 217, 0.1);
}

/* Ensure step labels maintain their highlighting when hovered */
.step-label:hover {
  color: #0077c5 !important;
  font-weight: 600 !important;
}

/* ==========================================================================
   HOVER STABILITY FIXES - UPDATED FOR PROPER ALIGNMENT
   ========================================================================== */

/* Remove transform scale from hover effects to prevent position shifts */
.calc-var-hover:hover {
  color: #0077c5 !important;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.calc-var-label:hover {
  color: #0077c5 !important;
  font-weight: 600 !important;
}

.param-hover:hover {
  color: var(--dark-teal) !important;
  font-weight: 600;
}

/* For the highlighted step, use box-shadow instead of padding/margin changes */
.calc-step.step-highlighted {
  background-color: rgba(0, 119, 197, 0.1);
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(0, 119, 197, 0.2);
  transition: all 0.2s ease;
}

[data-theme="sleep"] .calc-step.step-highlighted {
  background-color: rgba(77, 163, 217, 0.1);
  box-shadow: inset 0 0 0 2px rgba(77, 163, 217, 0.3);
}

/* Stable highlighting for variable references */
.variable-referenced,
.variable-referenced-param,
.calc-var-hover.variable-referenced,
.param-hover.variable-referenced-param {
  color: #0077c5 !important;
  font-weight: 600 !important;
  border-bottom: 2px solid rgba(0, 119, 197, 0.3);
  transition: all 0.2s ease;
}

[data-theme="sleep"] .variable-referenced,
[data-theme="sleep"] .variable-referenced-param,
[data-theme="sleep"] .calc-var-hover.variable-referenced,
[data-theme="sleep"] .param-hover.variable-referenced-param {
  color: #4da3d9 !important;
  border-bottom-color: rgba(77, 163, 217, 0.4);
}

/* Better approach: Use letter-spacing to prevent layout shift */
.calc-var-hover,
.param-hover,
.calc-var-label {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  /* Add tiny letter-spacing to accommodate bold without layout shift */
  letter-spacing: 0.02em;
}

/* Add invisible padding to hover targets for larger hit area */
.calc-var-hover::before,
.param-hover::before,
.calc-var-label::before {
  content: '';
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -2px;
  right: -2px;
  /* This creates a larger hover area without visual or layout changes */
}

/* Remove the problematic ::after pseudo-elements */
.step-label::after,
.calc-var-hover::after,
.param-hover::after {
  display: none !important;
}

/* Ensure proper baseline alignment */
.step-formula-text,
.step-calc-text {
  line-height: 1.5;
  vertical-align: baseline;
}

.step-formula-text > *,
.step-calc-text > * {
  vertical-align: baseline;
}

/* Smooth transitions for all hover effects */
.calc-var-hover,
.param-hover,
.calc-var-label,
.step-label {
  transition: color 0.2s ease, font-weight 0.2s ease, border-color 0.2s ease;
}

/* Debounced hover effect using animation delay */
@keyframes delayedHighlight {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.calc-step.step-highlighted {
  animation: delayedHighlight 0.1s ease-in;
}

/* Fix any lingering alignment issues */
.step-label {
  display: inline;
  vertical-align: baseline;
}

/* ==========================================================================
   ALTERNATIVE: SHADOW TEXT TECHNIQUE
   ========================================================================== */

/* Use text-shadow to simulate bold without changing metrics */
.calc-var-hover {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  transition: all 0.2s ease;
}

.calc-var-hover:hover {
  color: #0077c5 !important;
  /* Use text-shadow instead of font-weight for bold effect */
  text-shadow: 0 0 0.01px #0077c5, 0 0 0.01px #0077c5;
  /* Or use multiple shadows for stronger effect */
  text-shadow: 
    0.3px 0 0 currentColor,
    -0.3px 0 0 currentColor,
    0 0.3px 0 currentColor,
    0 -0.3px 0 currentColor;
  text-decoration: underline;
  text-decoration-style: dotted;
  /* Explicitly NOT changing font-weight */
  font-weight: normal !important;
}

.step-label {
  display: inline-block;
  vertical-align: baseline;
  transition: all 0.2s ease;
}

.step-label:hover,
.calc-var-label:hover {
  color: #0077c5 !important;
  /* Use text-shadow for bold effect */
  text-shadow: 
    0.3px 0 0 currentColor,
    -0.3px 0 0 currentColor,
    0 0.3px 0 currentColor,
    0 -0.3px 0 currentColor;
  font-weight: normal !important;
}

/* Apply shadow technique to highlighted states */
.variable-referenced,
.calc-var-hover.variable-referenced {
  color: #0077c5 !important;
  text-shadow: 
    0.3px 0 0 currentColor,
    -0.3px 0 0 currentColor,
    0 0.3px 0 currentColor,
    0 -0.3px 0 currentColor;
  font-weight: normal !important;
  border-bottom: 2px solid rgba(0, 119, 197, 0.3);
}

/* Dark theme adjustments */
[data-theme="sleep"] .calc-var-hover:hover,
[data-theme="sleep"] .step-label:hover,
[data-theme="sleep"] .calc-var-label:hover,
[data-theme="sleep"] .variable-referenced {
  color: #4da3d9 !important;
  text-shadow: 
    0.3px 0 0 currentColor,
    -0.3px 0 0 currentColor,
    0 0.3px 0 currentColor,
    0 -0.3px 0 currentColor;
}

