/* ============================================
   ToolGrit – Heat Load from Bills v2.0.8
   UX-Enhanced Design System
   ============================================ */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
  /* ===== Spacing Scale ===== */
  --space-1: 0.25rem;    /* 4px */
  --space-2: 0.5rem;     /* 8px */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.5rem;     /* 24px */
  --space-6: 2rem;       /* 32px */
  --space-7: 3rem;       /* 48px */
  --space-8: 4rem;       /* 64px */

  /* ===== Typography ===== */
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: var(--font-base);
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 2rem;      /* 32px */
  --font-size-4xl: 2.5rem;    /* 40px */

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ===== Border Radius ===== */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px */
  --radius-full: 9999px;

  /* ===== Shadows ===== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* ===== Light Mode Colors ===== */
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f5f9;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --muted: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #3b82f6;

  --accent: #8b6f47;
  --accent-hover: #6d5636;
  --accent-contrast: #ffffff;
  --accent-light: #f5f1ed;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #dbeafe;

  --success: #10b981;
  --success-bg: #d1fae5;
  --success-border: #6ee7b7;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-border: #fcd34d;

  --error: #ef4444;
  --error-bg: #fee2e2;
  --error-border: #fca5a5;

  --info: #3b82f6;
  --info-bg: #dbeafe;
  --info-border: #93c5fd;

  /* Status colors (for benchmarks) */
  --status-excellent: #16a34a;
  --status-excellent-bg: #dcfce7;

  --status-good: #22c55e;
  --status-good-bg: #d1fae5;

  --status-typical: #3b82f6;
  --status-typical-bg: #dbeafe;

  --status-high: #f59e0b;
  --status-high-bg: #fef3c7;

  --status-veryhigh: #ef4444;
  --status-veryhigh-bg: #fee2e2;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.3);
  --focus-ring-error: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* ============================================
   MAIN WRAPPER
   ============================================ */
.eec16-wrap {
  font-family: var(--font-base);
  color: var(--text);
  background: var(--bg);
  border-radius: var(--radius-2xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-xl);
  max-width: 1200px;
  margin: var(--space-5) auto;
  line-height: var(--line-height-normal);
}

@media (max-width: 768px) {
  .eec16-wrap {
    padding: var(--space-4);
    margin: var(--space-4) auto;
    border-radius: var(--radius-xl);
  }
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.eec16-title {
  font-family: var(--font-heading);
  font-size: clamp(var(--font-size-2xl), 4vw, var(--font-size-4xl));
  font-weight: var(--font-weight-bold);
  text-align: center;
  margin: 0 0 var(--space-5);
  color: var(--text);
  line-height: var(--line-height-tight);
}

.eec16-subtitle {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-4);
  color: var(--text);
  line-height: var(--line-height-tight);
}

/* ============================================
   LAYOUT & CARDS
   ============================================ */
.eec16-sections {
  display: grid;
  gap: var(--space-5);
}

.eec16-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.eec16-card:hover {
  border-color: var(--border-strong);
}

@media (max-width: 768px) {
  .eec16-card {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.eec16-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.eec16-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
}

.eec16-grid input,
.eec16-grid select {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3);
  font-size: var(--font-size-base);
  font-family: var(--font-base);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  line-height: var(--line-height-normal);
}

.eec16-grid input:hover:not(:disabled),
.eec16-grid select:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.eec16-grid input:focus,
.eec16-grid select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
}

.eec16-grid input:disabled,
.eec16-grid select:disabled {
  background: var(--card-hover);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.eec16-grid input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.eec16-grid input[readonly] {
  background: var(--card-hover);
  cursor: default;
}

/* ===== Help Text ===== */
.eec16-help {
  color: var(--text-tertiary);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-normal);
  margin-top: -var(--space-1);
}

/* ===== Label Variations ===== */
.eec16-labelline {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.eec16-muted {
  color: var(--muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
}

/* ============================================
   BUTTONS
   ============================================ */
.eec16-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-base);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.eec16-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.eec16-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.eec16-btn:focus {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-sm);
}

.eec16-btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.hl-calc-bottom {
  margin-top: var(--space-4);
}

/* ============================================
   RESULTS DISPLAY
   ============================================ */
.eec16-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.eec16-results > div {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.eec16-results strong {
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  font-size: var(--font-size-sm);
}

.eec16-results span {
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
}

/* ===== Highlighted Result Rows ===== */
.hl-avg-line {
  background: var(--accent-light);
  border: 2px solid var(--accent);
  padding: var(--space-4) !important;
}

.hl-avg-line strong {
  font-size: var(--font-size-base);
  color: var(--accent);
}

#hl-btu-hr-avg,
#hl-btu-hr-sf {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--accent);
}

#hl-wsf {
  border: 2px solid var(--accent);
  background: var(--accent-light);
}

#hl-wsf strong {
  color: var(--accent);
}

#hl-wsf-typ {
  display: block;
  margin-top: var(--space-2);
  font-style: italic;
}

/* ============================================
   CHART
   ============================================ */
#hl-chart {
  width: 100%;
  height: auto;
  max-height: 300px;
  display: block;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: var(--space-3);
  margin-top: var(--space-4);
}

/* ============================================
   STATUS & BENCHMARKS
   ============================================ */
.hl-status-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
}

.hl-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hl-icon svg {
  display: block;
}

.hl-status-text {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
}

.hl-chip-excellent { color: var(--status-excellent); }
.hl-chip-good { color: var(--status-good); }
.hl-chip-typical { color: var(--status-typical); }
.hl-chip-high { color: var(--status-high); }
.hl-chip-veryhigh { color: var(--status-veryhigh); }

/* ===== Gauge ===== */
.hl-gauge {
  position: relative;
  height: 16px;
  background: linear-gradient(
    90deg,
    var(--status-excellent-bg) 0%,
    var(--status-typical-bg) 50%,
    var(--status-high-bg) 80%,
    var(--status-veryhigh-bg) 100%
  );
  border-radius: var(--radius-full);
  overflow: visible;
  margin: var(--space-3) 0 var(--space-4);
  border: 1px solid var(--border);
}

.hl-gauge-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(139, 111, 71, 0.2);
  transition: width 0.5s ease;
}

.hl-gauge-marker {
  position: absolute;
  top: -6px;
  width: 4px;
  height: 28px;
  background: var(--text);
  left: 0%;
  border-radius: var(--radius-sm);
  transition: left 0.5s ease;
  box-shadow: var(--shadow-md);
}

.hl-gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
  font-weight: var(--font-weight-medium);
}

/* ===== Benchmark List ===== */
.eec16-bullets ul {
  margin: 0 0 var(--space-4) var(--space-5);
  padding: 0;
  list-style-type: disc;
}

.eec16-bullets li {
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

.eec16-bullets li::marker {
  color: var(--accent);
}

/* ============================================
   ROI / BEST BANG FOR BUCK
   ============================================ */
.hl-roi-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.hl-roi-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--bg-elevated);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.hl-roi-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.hl-roi-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.hl-roi-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text);
  flex: 1;
  min-width: 200px;
}

.hl-roi-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.hl-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.hl-roi-note {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  line-height: var(--line-height-relaxed);
  font-style: italic;
}

/* ============================================
   LINKS
   ============================================ */
.eec16-link {
  color: var(--primary);
  text-decoration: underline;
  font-weight: var(--font-weight-medium);
  transition: color 0.2s ease;
}

.eec16-link:hover {
  color: var(--primary-hover);
}

.eec16-link:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.eec16-rowhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.eec16-minibtn {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.eec16-minibtn:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
}

.eec16-minibtn:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
  .hl-roi-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hl-roi-name {
    min-width: auto;
  }

  .hl-roi-badges {
    width: 100%;
  }

  .eec16-results > div {
    flex-direction: column;
    align-items: flex-start;
  }

  #hl-btu-hr-avg,
  #hl-btu-hr-sf {
    font-size: var(--font-size-xl);
  }
}

@media (max-width: 480px) {
  .eec16-grid {
    grid-template-columns: 1fr;
  }

  .hl-badge {
    font-size: 0.7rem;
    padding: 0.125rem var(--space-2);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .eec16-actions,
  #hl-calc,
  #hl-calc-bottom {
    display: none !important;
  }

  .eec16-wrap {
    box-shadow: none;
    background: #fff;
    color: #000;
    max-width: 100%;
    padding: 0;
  }

  .eec16-card {
    page-break-inside: avoid;
    border: 1px solid #333;
  }

  .eec16-btn {
    display: none !important;
  }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */
/* Ensure all interactive elements have visible focus */
*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@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 support */
@media (prefers-contrast: high) {
  .eec16-wrap {
    border: 2px solid var(--text);
  }

  .eec16-card {
    border: 2px solid var(--border-strong);
  }

  .eec16-btn {
    border: 2px solid var(--text);
  }
}
