/* ═══════════════════════════════════════════════
   Savcurv Calculator Primitives
   v1.0 (2026-06-05)

   Consistent layout + component classes for ALL calculators.
   Use these instead of one-off Tailwind classes in templates.

   SECTIONS:
   1. Shell & Layout
   2. Typography
   3. Inputs
   4. Buttons (extends existing calc-btn-*)
   5. Results & Cards
   6. Gauges
   7. Charts
   8. Tables (extends existing calc-table)
   9. Tabs / Modes
   10. Presets
   ═══════════════════════════════════════════════ */

/* ── 1. Shell & Layout ─────────────────────────── */

.calc-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  padding-left: 1rem;
  padding-right: 1rem;
  background-color: #f1f5f9;
  border-radius: 0.5rem;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  width: 100%;
}
@media (min-width: 768px) {
  .calc-shell {
    padding-top: 1.75rem;
    padding-bottom: 1.75rem;
  }
}

.calc-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-left: 1rem;
  padding-right: 1rem;
  max-width: 32rem;
}

.calc-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}
@media (min-width: 768px) {
  .calc-header h2 {
    font-size: 1.875rem;
  }
}

.calc-header p {
  font-size: 1rem;
  color: #4b5563;
  line-height: 1.5;
  margin: 0;
}

.calc-content {
  width: 100%;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 768px) {
  .calc-content {
    max-width: 36rem;
  }
}

.calc-content-wide {
  width: 100%;
  max-width: 80rem;
  margin-left: 1rem;
  margin-right: 1rem;
}

.calc-grid-2 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 768px) {
  .calc-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.calc-grid-3 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 768px) {
  .calc-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── 2. Typography ──────────────────────────────── */

.calc-label {
  display: block;
  font-weight: 700;
  font-size: 1.125rem;
  color: #374151;
  margin-bottom: 0.5rem;
}

.calc-label-sm {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.calc-help {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.calc-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.calc-value-lg {
  font-size: 2.25rem;
  font-weight: 700;
  color: #0f172a;
}

.calc-value-xl {
  font-size: 3rem;
  font-weight: 700;
  color: #0f172a;
}

/* ── 3. Input Groups ───────────────────────────── */

.calc-input-group {
  margin-bottom: 1rem;
}

.calc-input-group:last-child {
  margin-bottom: 0;
}

/* Select dropdown primitive */
.calc-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  color: #374151;
  background-color: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}
.calc-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Radio button group (modern, accessible) */
.calc-radio-group {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.calc-radio-group input[type="radio"] {
  accent-color: #0f172a;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}
.calc-radio-group label {
  cursor: pointer;
  font-weight: 600;
  color: #374151;
}

/* Checkbox primitive */
.calc-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.calc-checkbox input[type="checkbox"] {
  accent-color: #0f172a;
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}
.calc-checkbox span {
  font-weight: 600;
  color: #374151;
}

/* ── 4. Buttons (already in calculator.css) ───────
   .calc-btn-primary, .calc-btn-outline, .calc-pill
   Just add .calc-btn-block for full-width */

.calc-btn-block {
  display: block;
  width: 100%;
}

/* ── 5. Results & Cards ────────────────────────── */

/* Result card — colored header result */
.calc-result-card {
  text-align: center;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
}
.calc-result-card .calc-result-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}
.calc-result-card .calc-result-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: #1e40af;
}

/* Result card variants */
.calc-result-card--green {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
}
.calc-result-card--green .calc-result-value {
  color: #047857;
}

.calc-result-card--red {
  background-color: #fef2f2;
  border-color: #fecaca;
}
.calc-result-card--red .calc-result-value {
  color: #b91c1c;
}

.calc-result-card--yellow {
  background-color: #fefce8;
  border-color: #fde047;
}
.calc-result-card--yellow .calc-result-value {
  color: #a16207;
}

/* Result grid — 2-col or 3-col result blocks */
.calc-result-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 768px) {
  .calc-result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.calc-result-grid-3 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 768px) {
  .calc-result-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.calc-result-item {
  background-color: #f9fafb;
  border-radius: 0.375rem;
  padding: 0.75rem;
  text-align: center;
}
.calc-result-item .calc-result-label {
  font-size: 0.875rem;
  color: #6b7280;
}
.calc-result-item .calc-result-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
}

/* Result row — label + value inline */
.calc-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 0.5rem;
}
.calc-result-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* ── 6. Gauges ─────────────────────────────────── */

.calc-gauge {
  width: 100%;
  margin-bottom: 1rem;
}

.calc-gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.calc-gauge-track {
  width: 100%;
  background-color: #e5e7eb;
  border-radius: 9999px;
  height: 0.75rem;
  position: relative;
  overflow: hidden;
}
.calc-gauge-track--lg {
  height: 1rem;
}

.calc-gauge-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 500ms ease-out, background-color 300ms ease-out;
}

/* Gauge segments (multi-color track) */
.calc-gauge-segments {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  overflow: hidden;
}
.calc-gauge-segment {
  flex: 1;
  height: 100%;
}

/* Gauge marker (triangle) */
.calc-gauge-marker {
  position: absolute;
  top: -10px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid #171717;
  transform: translateX(-50%);
  transition: left 500ms ease-out;
}

/* Gauge tick marks (40%, 60%, etc.) */
.calc-gauge-tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 2px;
  background-color: rgba(255, 255, 255, 0.8);
}

/* ── 7. Charts ──────────────────────────────────── */

.calc-chart {
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 80rem;
  margin-left: 1rem;
  margin-right: 1rem;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  padding: 1rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.calc-chart-header {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
@media (min-width: 640px) {
  .calc-chart-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.calc-chart-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.calc-chart-header p {
  font-size: 0.75rem;
  color: #6b7280;
  margin: 0;
}

.calc-chart-frame {
  position: relative;
  width: 100%;
  height: 320px;
}

/* ── 8. Tables (already in calculator.css) ─────────
   .calc-table, .calc-table thead, .calc-table tbody, etc.
   Add responsive wrapper: */

.calc-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 1rem;
}

/* ── 9. Tabs / Mode Switcher ───────────────────── */

.calc-tab-group {
  display: flex;
  background-color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  border-radius: 0.5rem;
  overflow: hidden;
  margin-bottom: 1rem;
  width: 100%;
}

.calc-tab {
  flex: 1;
  text-align: center;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}
@media (min-width: 768px) {
  .calc-tab {
    padding: 0.75rem 1.5rem;
  }
}

.calc-tab:hover {
  background-color: #f1f5f9;
}
.calc-tab.is-active {
  background-color: #0f172a;
  color: #ffffff;
  border-bottom-color: #0f172a;
}

/* Radio-based tab variant (peer-checked) */
input[type="radio"].calc-tab-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
input[type="radio"].calc-tab-radio:checked + .calc-tab {
  background-color: #0f172a;
  color: #ffffff;
  border-bottom-color: #0f172a;
}

/* ── 10. Presets ────────────────────────────────── */

.calc-preset-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-width: 42rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ── 11. Utility ───────────────────────────────── */

.hidden, .calc-hidden {
  display: none;
}
.calc-mt-2 {
  margin-top: 0.5rem;
}
.calc-mt-4 {
  margin-top: 1rem;
}
.calc-mb-4 {
  margin-bottom: 1rem;
}
.calc-px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}
.calc-text-center {
  text-align: center;
}
.calc-text-left {
  text-align: left;
}
.calc-text-right {
  text-align: right;
}
