/* ==========================================================================
   HealthRovia - Calculators & Interactive Tool Widgets CSS (Mobile-Perfect)
   ========================================================================== */

.hr-calc-widget {
  background: var(--brand-white);
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 24px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.hr-calc-widget:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px -4px rgba(13, 148, 136, 0.08);
}

.hr-hero-bmi-widget {
  padding: 20px;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.07), 0 4px 12px -2px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
}

.hr-calc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.hr-calc-header-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}

.hr-calc-icon-pill {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  background: #ecfdf5;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid var(--brand-mint-border);
}

.hr-calc-header-title h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-gray-900);
  margin-bottom: 4px;
  line-height: 1.3;
}

.hr-calc-subtitle {
  font-size: 13px;
  color: var(--brand-gray-500);
  line-height: 1.45;
  margin: 0;
}

/* Unit Switcher (Metric / Imperial) */
.hr-calc-unit-toggle {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: var(--radius-full);
  padding: 3px;
  flex-shrink: 0;
}

.hr-unit-btn {
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-gray-600);
  padding: 6px 13px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.hr-unit-btn.active {
  background: var(--brand-white);
  color: var(--brand-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Form Inputs */
.hr-calculator-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hr-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}

.hr-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.hr-form-group.full-width {
  grid-column: span 2;
}

.hr-form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-gray-700);
}

.hr-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.hr-input-wrap input,
.hr-form-group input[type="date"],
.hr-form-group input[type="time"],
.hr-select {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--brand-gray-900);
  font-family: var(--font-body);
  transition: var(--transition);
  outline: none;
  min-height: 44px;
  box-sizing: border-box;
}

.hr-input-wrap input:focus,
.hr-form-group input[type="date"]:focus,
.hr-form-group input[type="time"]:focus,
.hr-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.hr-input-unit {
  position: absolute;
  right: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-gray-400);
  pointer-events: none;
}

.hr-input-group-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.hr-radio-pills {
  display: flex;
  gap: 10px;
  width: 100%;
}

.hr-radio-pills label {
  flex: 1;
  cursor: pointer;
}

.hr-radio-pills input {
  display: none;
}

.hr-radio-pills span {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand-gray-600);
  background: #ffffff;
  transition: var(--transition);
}

.hr-radio-pills input:checked + span {
  background: #ecfdf5;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 700;
}

/* Submit Action Button */
.hr-btn-calculate {
  width: 100%;
  background-color: var(--brand-primary);
  color: var(--brand-white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.22);
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.hr-btn-calculate:hover {
  background-color: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.28);
}

/* ==========================================================================
   Results & Visual Gauge (Pixel-Perfect Matching Reference)
   ========================================================================== */
.hr-calc-results {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #f1f5f9;
  animation: hrFadeIn 0.3s ease-in-out;
}

@keyframes hrFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hr-result-summary-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.hr-res-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand-gray-500);
}

.hr-res-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.hr-res-big-number {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  color: #0f172a;
}

.hr-res-status-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
}

.hr-res-status-badge.status-normal,
.hr-res-status-badge.status-healthy {
  background-color: #ecfdf5;
  color: #10b981;
}

.hr-res-status-badge.status-underweight {
  background-color: #f0f9ff;
  color: #0284c7;
}

.hr-res-status-badge.status-overweight,
.hr-res-status-badge.status-elevated {
  background-color: #fffbeb;
  color: #d97706;
}

.hr-res-status-badge.status-obese,
.hr-res-status-badge.status-stage1,
.hr-res-status-badge.status-stage2,
.hr-res-status-badge.status-crisis {
  background-color: #fef2f2;
  color: #dc2626;
}

.hr-res-explanation {
  font-size: 13.5px;
  color: var(--brand-gray-600);
  line-height: 1.55;
  margin-bottom: 16px;
}

/* Visual Gauge Bar */
.hr-gauge-track {
  height: 8px;
  background: transparent;
  position: relative;
  margin: 18px 0 8px;
  display: grid;
  grid-template-columns: 22% 35% 25% 18%;
  gap: 4px;
  overflow: visible;
}

.hr-gauge-segment {
  height: 100%;
  border-radius: 4px;
}

.hr-gauge-segment.seg-under { background: #94a3b8; }
.hr-gauge-segment.seg-normal { background: #10b981; }
.hr-gauge-segment.seg-over { background: #f59e0b; }
.hr-gauge-segment.seg-obese { background: #ef4444; }

.hr-gauge-pin {
  position: absolute;
  top: -5px;
  width: 18px;
  height: 18px;
  background: #10b981;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 1.5px #10b981, 0 2px 6px rgba(0,0,0,0.22);
  transition: left 0.4s ease;
  z-index: 2;
}

.hr-gauge-labels {
  display: grid;
  grid-template-columns: 22% 35% 25% 18%;
  gap: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-gray-400);
}

/* Result Details Grid / Breakdown Cards */
.hr-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.hr-breakdown-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}

.hr-breakdown-card .title {
  font-size: 11.5px;
  color: var(--brand-gray-500);
  font-weight: 600;
  margin-bottom: 4px;
}

.hr-breakdown-card .val {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  font-family: var(--font-heading);
}

/* Actions Toolbar (Copy Results, Print Summary, Reset) */
.hr-calc-actions-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #e2e8f0;
}

.hr-action-pill-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}

.hr-action-pill-btn:hover {
  background: #f8fafc;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* Timeline Cards & Sleep Chips */
.hr-timeline-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.hr-timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-primary);
  font-size: 13px;
}

.hr-sleep-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hr-sleep-chip {
  background: #ecfdf5;
  color: #0f766e;
  border: 1px solid var(--brand-mint-border);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
}

/* Questions / Scoring Quiz Group */
.hr-quiz-group {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.hr-quiz-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  display: block;
  margin-bottom: 8px;
}

/* ==========================================================================
   Mobile Optimization (@media <= 640px)
   ========================================================================== */
@media (max-width: 640px) {
  .hr-calc-widget {
    padding: 16px 14px;
    border-radius: 14px;
  }

  .hr-calc-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .hr-calc-header-title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
  }

  .hr-calc-icon-pill {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    margin-top: 2px;
  }

  .hr-calc-header-title h3 {
    font-size: 16.5px;
  }

  .hr-calc-subtitle {
    font-size: 12.5px;
  }

  .hr-calc-unit-toggle {
    align-self: flex-start;
  }

  /* CRITICAL: Stack 2-column input rows on mobile so fields never cramp */
  .hr-input-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .hr-form-group.full-width {
    grid-column: span 1;
  }

  .hr-input-group-2 {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .hr-input-wrap input,
  .hr-form-group input[type="date"],
  .hr-form-group input[type="time"],
  .hr-select {
    padding: 11px 12px;
    font-size: 14.5px;
  }

  .hr-btn-calculate {
    padding: 13px 14px;
    font-size: 14.5px;
  }

  .hr-breakdown-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .hr-calc-actions-toolbar {
    justify-content: center;
    flex-wrap: wrap;
  }
}
