/* Fuel Poverty Analysis — styles */

:root {
  --primary: #ff4b4b;
  --primary-hover: #ff2b2b;
  --bg: #ffffff;
  --sidebar-bg: #f0f2f6;
  --text: #31333f;
  --muted: #6c757d;
  --border: #e0e0e0;
  --success-bg: #d4edda;
  --success-text: #155724;
  --warning-bg: #fff3cd;
  --warning-text: #856404;
  --error-bg: #f8d7da;
  --error-text: #721c24;
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans Pro", system-ui, -apple-system, Segoe UI, Roboto,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 100vh;
}

.main {
  padding: 2rem 2.5rem 3rem;
  max-width: 1200px;
}

.sidebar {
  background: var(--sidebar-bg);
  padding: 1.5rem 1.25rem;
  border-left: 1px solid var(--border);
}

.sidebar h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.sidebar-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sidebar-tab {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.sidebar-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sidebar-content {
  font-size: 0.9rem;
  color: var(--text);
}

.sidebar-content ul {
  padding-left: 1.2rem;
  margin: 0.5rem 0;
}

.sidebar-source {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.sidebar-source a {
  color: #1f5a96;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 2.25rem;
  font-weight: 700;
}

.caption {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.form-group {
  margin-bottom: 1rem;
  position: relative;
  overflow: visible;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #e8eef5;
  color: #1f5a96;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

.info-tip::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  bottom: auto;
  transform: translateX(-50%);
  width: min(320px, 70vw);
  padding: 0.6rem 0.75rem;
  background: #1f2937;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
  white-space: normal;
}

.info-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  bottom: auto;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #1f2937;
  border-top-color: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

.info-tip:hover::after,
.info-tip:hover::before,
.info-tip:focus::after,
.info-tip:focus::before {
  opacity: 1;
  visibility: visible;
}

.form-group input,
.form-group select {
  width: 100%;
  max-width: 320px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 2rem;
}

.household-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: visible;
}

.household-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #fafafa;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.household-header:hover {
  background: #f0f0f0;
}

.household-body {
  padding: 1rem;
  display: none;
  overflow: visible;
}

.household-card.open .household-body {
  display: block;
}

.household-card.open .toggle-icon {
  transform: rotate(90deg);
}

.toggle-icon {
  transition: transform 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin: 1rem 0;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.results-section {
  margin-top: 2rem;
}

.results-section h3 {
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

th {
  background: #fafafa;
  font-weight: 600;
}

.detail-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.detail-header {
  padding: 0.6rem 1rem;
  background: #fafafa;
  cursor: pointer;
  font-weight: 600;
}

.detail-body {
  padding: 0.75rem 1rem;
  display: none;
}

.detail-card.open .detail-body {
  display: block;
}

.metric {
  display: inline-block;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.chart-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  background: #fff;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1.25rem;
  }
}
