/* ── Instant Calculator Frontend ── */

/* ── Container: 100% width, no decoration ── */
.instant-calculator {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: #1e293b;
  line-height: 1.5;
  width: 100%;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.ic-title {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 20px;
}

/* ── Row + Column layout ── */
.ic-calculator-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ic-row {
  display: flex;
  flex-wrap: wrap;      /* wraps on small screens */
  gap: 20px;
  width: 100%;
}

.ic-col {
  flex: 1 1 0%;
  min-width: 0;         /* prevents flex blowout */
  box-sizing: border-box;
}

/* ── Responsive breakpoints (Bootstrap-like) ──
   Mobile  < 576px  → all columns stack (100%)
   Tablet  576-767px → quarters/thirds collapse to 2 cols
   Desktop ≥ 768px  → full layout                         */

@media (max-width: 575px) {
  .ic-row { flex-direction: column; gap: 0; }
  .ic-col { flex: 1 1 100% !important; width: 100%; }
  .ic-col + .ic-col { margin-top: 20px; }
}

@media (min-width: 576px) and (max-width: 767px) {
  /* 3 columns → wrap to 2+1 */
  .ic-layout-thirds .ic-col       { flex: 0 0 50%; max-width: 50%; }
  /* 4 columns → wrap to 2+2 */
  .ic-layout-quarters .ic-col     { flex: 0 0 50%; max-width: 50%; }
}

/* ── Fields ── */
.ic-fields { display: flex; flex-direction: column; gap: 18px; }
.ic-field   { display: flex; flex-direction: column; gap: 7px; }

.ic-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Number ── */
.ic-input-wrap { display: flex; align-items: center; }
.ic-input-group .ic-prefix + .ic-input { border-radius: 0 6px 6px 0; border-left: none; }
.ic-input-group .ic-input:not(:last-child) { border-radius: 6px 0 0 6px; }

.ic-addon {
  display: inline-flex; align-items: center; padding: 0 12px; height: 40px;
  background: #f1f5f9; border: 1px solid #e2e8f0; color: #64748b;
  font-size: 14px; font-weight: 500; flex-shrink: 0;
}
.ic-prefix { border-right: none; border-radius: 6px 0 0 6px; }
.ic-suffix  { border-left: none;  border-radius: 0 6px 6px 0; }

.ic-input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 15px; color: #1e293b; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
}
textarea.ic-input{
  height: auto;
}
.ic-input::-webkit-outer-spin-button,
.ic-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ic-input:focus { border-color: #2271b1; box-shadow: 0 0 0 3px rgba(34,113,177,.12); }
.ic-input--error { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important; }

/* ── Slider ── */
.ic-slider-wrap { display: flex; align-items: center; gap: 12px; }

.ic-slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px;
  border-radius: 3px; outline: none; cursor: pointer;
  /* fill is set dynamically via JS */
  background: linear-gradient(to right, #2271b1 0%, #2271b1 50%, #e2e8f0 50%, #e2e8f0 100%);
}
.ic-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: #2271b1; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 6px rgba(34,113,177,.4);
  transition: transform .1s;
}
.ic-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.ic-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: #2271b1;
  cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 6px rgba(34,113,177,.4);
}
.ic-slider-value-box {
  display: inline-flex; align-items: center; gap: 2px;
  height: 40px; padding: 0 12px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 15px; color: #1e293b; background: #fff;
  white-space: nowrap; min-width: 64px; justify-content: center;
  flex-shrink: 0;
}
.ic-slider-prefix, .ic-slider-suffix { font-size: 14px; color: #64748b; }

/* ── Checkbox (toggle) ── */
.ic-checkbox-wrap { display: flex; align-items: center; gap: 10px; position: relative; cursor: pointer; }
.ic-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.ic-checkbox-toggle {
  width: 46px; height: 26px; background: #e2e8f0; border-radius: 13px;
  position: relative; cursor: pointer; transition: background .2s; display: block;
}
.ic-checkbox-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform .2s;
}
.ic-checkbox:checked + .ic-checkbox-toggle { background: #2271b1; }
.ic-checkbox:checked + .ic-checkbox-toggle::after { transform: translateX(20px); }
.ic-checkbox-desc { font-size: 14px; color: #374151; line-height: 1.4; }

/* ── Radio ── */
.ic-radio-group { display: flex; flex-direction: column; gap: 8px; }
.ic-radio-label {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 8px;
  transition: all .15s; font-size: 14px; color: #374151;
}
.ic-radio-label:hover { border-color: #93c5fd; background: #f8fafc; }
.ic-radio { position: absolute; opacity: 0; width: 0; height: 0; }
.ic-radio-custom {
  width: 18px; height: 18px; border: 2px solid #d1d5db; border-radius: 50%;
  flex-shrink: 0; display: inline-block; position: relative; transition: border-color .15s;
}
.ic-radio:checked ~ .ic-radio-custom { border-color: #2271b1; }
.ic-radio:checked ~ .ic-radio-custom::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 8px; height: 8px; border-radius: 50%; background: #2271b1;
}
.ic-radio-label:has(.ic-radio:checked) {
  border-color: #2271b1; background: #eff6ff; font-weight: 600; color: #1e40af;
}

/* ── Formula result ── */
.ic-formula-result {
  display: flex; flex-direction: column;
  background: transparent;
  border: none; border-radius: 6px;
  padding: 0; gap: 6px;
}
.ic-formula-main {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.ic-formula-label {
  font-size: inherit; color: inherit;
}
.ic-formula-value {
  display: flex; align-items: baseline; justify-content: flex-end;
  gap: 3px; margin-left: auto; text-align: right;
}
.ic-formula-prefix { font-size: inherit; color: inherit; font-weight: 500; }
.ic-formula-number {
  font-size: inherit;  color: inherit; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.ic-formula-suffix { font-size: inherit; color: inherit; font-weight: 500; }
.ic-formula-description { font-size: 13px; color: #64748b; margin: 0; line-height: 1.5; }
/* When formula has inline border/bg, add padding */
.ic-formula-result[style] { padding: 14px 20px; border-radius: 10px; }

/* ── Header element ── */
.ic-field-header { display: flex; flex-direction: column; gap: 4px; }
.ic-header-field { margin: 0; line-height: 1.3; }
.ic-header-description { margin: 0; color: #64748b; line-height: 1.6; }
.ic-header-rule { border: none; border-top: 1px solid #e2e8f0; margin: 6px 0 0; }

/* ── Dropdown element ── */
.ic-select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 15px; color: #1e293b; background: #fff;
  outline: none; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.ic-select:focus { border-color: #2271b1; box-shadow: 0 0 0 3px rgba(34,113,177,.12); }

/* ── HTML element ── */
.ic-html-field { font-size: 15px; color: #374151; line-height: 1.7; }

/* ── Summary element ── */
.ic-summary { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.ic-summary-header {
  padding: 12px 16px; background: #f8fafc;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.ic-summary-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.ic-summary-header-desc { font-size: 13px; margin: 4px 0 0; line-height: 1.5; opacity: .85; }
.ic-summary-rows { /* font-size and color set via inline style from PHP */ }
.ic-summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
}
.ic-summary-label { font-size: inherit; color: inherit; }
.ic-summary-value { font-size: inherit; font-weight: 600; color: inherit; }

/* ── Paragraph element ── */
.ic-paragraph-field { font-size: 15px; color: #374151; margin: 0; line-height: 1.7; white-space: pre-wrap; }

/* ── Space element ── */
.ic-space-field { display: block; width: 100%; }

/* ── Button element ── */
.ic-field-button { display: flex; align-items: flex-start; }
.ic-button-field {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer;
  font-weight: 600; line-height: 1.3; text-decoration: none;
  transition: opacity .15s, background-color .2s, color .2s, border-color .2s;
  background-color: #2271b1; color: #fff; border: none;
}
.ic-button-field:hover { opacity: .85; }

/* ── Textarea ── */
.ic-textarea-input {
  height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6;
}

/* ── Date / Time ── */
.ic-date-input,
.ic-time-input { cursor: pointer; }

/* ── Field validation error ── */
.ic-field-error {
  display: flex; align-items: center; gap: 5px;
  color: #dc2626; font-size: 12px; margin-top: 5px;
  padding: 5px 10px; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: 5px;
}

/* ── Error ── */
.ic-error-msg { color: #dc2626; font-style: italic; }

/* ═══════════════════════════════════════
   MULTI-STEP
═══════════════════════════════════════ */

/* ══ HORIZONTAL layout ══════════════════ */
.ic-steps-wrap--horizontal {
  display: flex;
  flex-direction: column;
}

/* The track row: circles + connectors in one flex line */
.ic-steps-wrap--horizontal .ic-steps-track {
  display: flex;
  align-items: flex-start;   /* indicators + connectors top-aligned */
  width: 100%;
  margin-bottom: 32px;
  overflow-x: auto;
  padding-bottom: 4px;       /* room for box-shadow on active bubble */
}

/* Each step indicator: circle on top, label below */
.ic-steps-wrap--horizontal .ic-step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 80px;
  position: relative;
  z-index: 1;
}

/*
  Connector line — positioned to bisect the 44px bubble.
  44px bubble → center at 22px. 3px line → top must be at 22 - 1.5 = 20.5px.
  We use margin-top: 21px for a pixel-perfect result.
*/
.ic-steps-wrap--horizontal .ic-step-connector {
  flex: 1;
  min-width: 24px;
  height: 3px;
  border-radius: 2px;
  background: #e2e8f0;
  margin-top: 21px;
  align-self: flex-start;
  transition: background .35s ease;
}

/* ══ VERTICAL layout ═════════════════════ */
.ic-steps-wrap--vertical {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 28px;
}

.ic-steps-wrap--vertical .ic-steps-sidebar {
  flex-shrink: 0;
  width: 164px;
  padding-top: 4px;
}

.ic-steps-wrap--vertical .ic-steps-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Track column: circles + connectors stacked */
.ic-steps-wrap--vertical .ic-steps-track {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Each step indicator: circle on left, text group on right */
.ic-steps-wrap--vertical .ic-step-indicator {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

/*
  Vertical connector — a thin vertical bar centred under the 44px bubble.
  44px bubble → left edge of centre at (44 - 3) / 2 = 20.5px → margin-left: 21px.
*/
.ic-steps-wrap--vertical .ic-step-connector {
  width: 3px;
  min-height: 32px;
  border-radius: 2px;
  background: #e2e8f0;
  margin-left: 21px;
  transition: background .35s ease;
}

/* ── ic-step-text: wraps the label + optional desc inside the indicator ── */
.ic-step-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
/* Horizontal: center the text group under the bubble */
.ic-steps-wrap--horizontal .ic-step-text {
  align-items: center;
}

/* ── Step indicator description (inside the nav track) ── */
.ic-step-indicator-desc {
  font-size: 11px;
  font-weight: 400;
  color: #b0b9c6;
  line-height: 1.4;
  margin: 0;
  transition: color .3s ease;
}
.ic-steps-wrap--horizontal .ic-step-indicator-desc {
  text-align: center;
  max-width: 90px;
}
.ic-step-indicator--active .ic-step-indicator-desc { color: #6094c8; }
.ic-step-indicator--done   .ic-step-indicator-desc { color: #6b7280; }

/* ══ BUBBLE (circle) — shared ════════════ */
.ic-step-bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2.5px solid #d1d5db;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #9ca3af;
  flex-shrink: 0;
  transition: background .3s ease, border-color .3s ease,
              color .3s ease, box-shadow .3s ease;
  position: relative;
  z-index: 1;
  user-select: none;
}

/* Unvisited — plain border circle, shown above already */

/* Current step — blue filled, white number, soft glow */
.ic-step-indicator--active .ic-step-bubble {
  background: #2271b1;
  border-color: #2271b1;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(34, 113, 177, .16),
              0 4px 12px rgba(34, 113, 177, .35);
}

/* Done step — green filled, white checkmark */
.ic-step-indicator--done .ic-step-bubble {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, .28);
}

/* ══ STEP LABEL — shared ═════════════════ */
.ic-step-label {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  line-height: 1.4;
  transition: color .3s ease;
  white-space: nowrap;          /* prevents ugly wrapping on short labels */
}

/* Horizontal: centre-align label under bubble */
.ic-steps-wrap--horizontal .ic-step-label {
  text-align: center;
  max-width: 90px;
  white-space: normal;          /* allow wrap if the title is long */
}

.ic-step-indicator--active .ic-step-label {
  color: #2271b1;
  font-weight: 700;
}
.ic-step-indicator--done .ic-step-label {
  color: #374151;
}

/* ══ CONNECTOR DONE STATE ════════════════ */
.ic-step-connector--done {
  background: #16a34a;
}

/* ══ NAVIGATION ══════════════════════════ */
.ic-steps-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1.5px solid #e8ecf0;
}

.ic-steps-nav-back,
.ic-steps-nav-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease,
              color .18s ease, box-shadow .18s ease;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1;
}

/* Back / Prev — ghost style */
.ic-steps-nav-back {
  background: #fff;
  color: #4b5563;
  border: 1.5px solid #d1d5db;
}
.ic-steps-nav-back:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #111827;
}

/* Next — primary blue */
.ic-steps-nav-next {
  background: #2271b1;
  color: #fff;
  border: 1.5px solid #2271b1;
}
.ic-steps-nav-next:hover {
  background: #1a5f96;
  border-color: #1a5f96;
  box-shadow: 0 4px 12px rgba(34, 113, 177, .35);
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .ic-formula-number { font-size: 22px; }
  .ic-formula-main { flex-direction: column; align-items: flex-start; gap: 6px; }
  .ic-slider-wrap { flex-wrap: wrap; }
  .ic-slider { min-width: 0; }

  /* Vertical layout collapses to horizontal on very small screens */
  .ic-steps-wrap--vertical { flex-direction: column; gap: 0; }
  .ic-steps-wrap--vertical .ic-steps-sidebar { width: 100%; padding-top: 0; }
  .ic-steps-wrap--vertical .ic-steps-track { flex-direction: row; align-items: flex-start; overflow-x: auto; padding-bottom: 4px; }
  .ic-steps-wrap--vertical .ic-step-indicator { flex-direction: column; align-items: center; gap: 8px; min-width: 64px; }
  .ic-steps-wrap--vertical .ic-step-connector { width: auto; height: 3px; min-height: unset; min-width: 20px; flex: 1; margin-left: 0; margin-top: 21px; align-self: flex-start; }
  .ic-steps-wrap--vertical .ic-step-label { text-align: center; max-width: 80px; white-space: normal; }
  .ic-steps-wrap--vertical .ic-steps-sidebar { margin-bottom: 24px; }
}
