/* =====================================================================
   MIFF 2026 Price Calculator — Stylesheet
   ===================================================================== */

/* --- Reset & Base ---------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy:       #1a2e4a;
  --navy-light: #243a5e;
  --blue:       #2563eb;
  --blue-hover: #1d4ed8;
  --gold:       #d4a017;
  --green:      #16a34a;
  --red:        #dc2626;
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --border-mid: #cbd5e1;
  --text:       #1e293b;
  --muted:      #64748b;
  --radius:     0.75rem;
  --shadow:     0 4px 24px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================================================================
   LOGIN SCREEN
   ===================================================================== */
.login-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
}

.logo-area {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.logo-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: 0.05em;
}

.logo-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* =====================================================================
   TOP BAR
   ===================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  padding: 0.875rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-user {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

/* =====================================================================
   CALCULATOR LAYOUT
   ===================================================================== */
.calc-screen {
  background: var(--bg);
}

.calc-main {
  padding: 2rem 1.5rem;
  display: flex;
  justify-content: center;
}

.calc-card {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Card section — each step is its own card */
.card-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card-section--footer {
  box-shadow: none;
  background: transparent;
  padding: 0;
}

/* =====================================================================
   FORM ELEMENTS
   ===================================================================== */
.section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row--narrow {
  grid-template-columns: 200px;
}

@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row--narrow { grid-template-columns: 1fr; }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-input {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.field-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-input--error {
  border-color: var(--red);
}

.field-error {
  font-size: 0.8125rem;
  color: var(--red);
}

.field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath 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 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.field-input:disabled {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
}

/* =====================================================================
   MODEL IMAGE PREVIEW
   ===================================================================== */
.model-preview {
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  background: var(--navy);
  border-radius: var(--radius);
}

.model-img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 0.5rem;
  display: block;
}

.model-img-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* =====================================================================
   PIECES TABLE
   ===================================================================== */
.pieces-header {
  display: grid;
  grid-template-columns: 1fr 130px 120px 110px;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg);
  border-radius: 0.375rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.piece-row {
  display: grid;
  grid-template-columns: 1fr 130px 120px 110px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: background 0.1s;
}

.piece-row:hover {
  background: #f8fafc;
}

.piece-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.piece-unit {
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* +/- stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  width: fit-content;
}

.qty-btn {
  width: 32px;
  height: 34px;
  border: none;
  background: var(--bg);
  color: var(--navy);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  flex-shrink: 0;
  line-height: 1;
}

.qty-btn:hover  { background: var(--border); }
.qty-btn:active { background: var(--border-mid); }

.piece-qty {
  width: 44px;
  height: 34px;
  border: none;
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-radius: 0;
  padding: 0;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--navy);
  background: #fff;
  outline: none;
}

.piece-qty:focus { background: #eff6ff; }

/* Remove number input arrows */
.piece-qty::-webkit-outer-spin-button,
.piece-qty::-webkit-inner-spin-button { -webkit-appearance: none; }
.piece-qty[type=number] { -moz-appearance: textfield; }

.piece-sub {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.piece-sub--active {
  color: var(--navy);
}

/* Combination badge */
.combo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.875rem;
  padding: 0.5rem 0.75rem;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 0.5rem;
}

.combo-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.combo-value {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--navy);
}

@media (max-width: 560px) {
  .pieces-header,
  .piece-row {
    grid-template-columns: 1fr 90px 108px 80px;
    font-size: 0.8rem;
  }

  .piece-unit { font-size: 0.75rem; }
}

/* =====================================================================
   RESULT CARD
   ===================================================================== */
.result-card {
  border: 2px solid var(--border-mid);
  background: #f8fafc;
}

.result-meta {
  font-size: 0.8125rem;
  color: var(--muted);
  font-style: italic;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.result-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 0.9375rem;
  color: var(--muted);
  font-weight: 500;
}

.result-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-row--discount .result-label,
.result-value--discount {
  color: var(--red);
}

.result-row--final {
  padding-top: 0.875rem;
  margin-top: 0.25rem;
  border-top: 2px solid var(--navy);
}

.result-row--final .result-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}

.result-value--final {
  font-size: 1.5rem !important;
  color: var(--green) !important;
}

.result-row--qty {
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1.5px dashed var(--border-mid);
  border-bottom: none;
}

.result-row--qty .result-label {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.result-value--qty {
  font-size: 0.9375rem !important;
  font-weight: 700 !important;
  color: var(--navy) !important;
  background: #eff6ff;
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  border: 1.5px solid #bfdbfe;
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-hover); }

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}

.btn--ghost:hover { background: var(--bg); color: var(--text); }

.btn--full { width: 100%; }

.btn--sm {
  padding: 0.4rem 0.875rem;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.3);
}

.btn--sm:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* =====================================================================
   TOPBAR NAVIGATION TABS
   ===================================================================== */
.topbar-nav {
  display: flex;
  gap: 0.25rem;
}

.topbar-tab {
  padding: 0.3rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.topbar-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.topbar-tab--active {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

@media (max-width: 400px) {
  .topbar-nav { display: none; }
}

/* =====================================================================
   CONTAINER MIX PLANNER — PAGE INTRO
   ===================================================================== */
.container-intro {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin-top: -0.25rem;
}

/* =====================================================================
   CONTAINER MIX PLANNER — SLOT CARDS
   ===================================================================== */

/* Gap between slot cards */
#slots-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.slot-card {
  border-left: 3px solid var(--blue);
}

.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.slot-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Piece rows inside a slot */
.slot-pieces-header {
  margin-top: 0.875rem;
  margin-bottom: 0.375rem;
}

.slot-piece-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  transition: background 0.1s;
}

.slot-piece-row:hover { background: #f8fafc; }

.slot-piece-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

/* Slot footer */
.slot-footer-row {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1.5px dashed var(--border-mid);
}

.slot-footer-cell {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.slot-cbm-per-set,
.slot-cbm-total {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* Add model dashed button */
.btn--dashed {
  border-style: dashed;
  margin-top: 0.25rem;
}

/* =====================================================================
   CONTAINER MIX PLANNER — CBM PROGRESS BAR
   ===================================================================== */
.cbm-bar-wrap {
  margin: 0.5rem 0 0.75rem;
}

.cbm-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.cbm-bar-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cbm-bar-numbers {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.cbm-bar-track {
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.cbm-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #22c55e);
  border-radius: 10px;
  transition: width 0.35s ease, background 0.35s ease;
  min-width: 0;
}

.cbm-bar-fill--over {
  background: linear-gradient(90deg, #f97316, var(--red));
}

/* =====================================================================
   CONTAINER MIX PLANNER — STATUS & BREAKDOWN
   ===================================================================== */
.cbm-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 0.25rem;
  margin-bottom: 0.875rem;
}

.cbm-status--ok   { background: #dcfce7; color: #15803d; }
.cbm-status--over { background: #fee2e2; color: var(--red); }

/* Breakdown rows */
.cbm-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cbm-bd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}

.cbm-bd-row:last-child { border-bottom: none; }

.cbm-bd-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.cbm-bd-combo {
  margin-left: 0.4rem;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

.cbm-bd-vals {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cbm-bd-sets { font-size: 0.8125rem; color: var(--muted); }

.cbm-bd-cbm {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.cbm-bd-pct {
  font-size: 0.8125rem;
  color: var(--muted);
  min-width: 2.75rem;
  text-align: right;
}

/* =====================================================================
   CONTAINER MIX PLANNER — REMAINING SPACE
   ===================================================================== */
.cbm-remaining {
  margin-top: 1rem;
  padding: 0.75rem 0.875rem;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 0.5rem;
}

.cbm-rem-title {
  font-size: 0.9rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.cbm-suggest {
  font-size: 0.875rem;
  color: var(--text);
  padding: 0.2rem 0;
}

.cbm-suggest-combo { color: var(--muted); }

.cbm-suggest-note {
  font-size: 0.8125rem;
  color: var(--muted);
}

.cbm-suggest-none {
  font-size: 0.875rem;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 560px) {
  .cbm-bd-row { flex-wrap: wrap; }
  .cbm-bd-name { flex-basis: 100%; }
  .slot-footer-row { gap: 1rem; }
}

/* --- Language Toggle -------------------------------------------------- */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}
.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--muted);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  transition: color 0.15s;
  line-height: 1.4;
}
.lang-btn:hover { color: var(--text); }
.lang-btn--active { color: var(--blue); font-weight: 600; }
.lang-sep { color: var(--border-mid); font-size: 0.75rem; }
.lang-toggle--login { justify-content: center; margin-top: 1.25rem; }
