:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --accent: #f97316;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-sm: 0 1px 6px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── HEADER ── */
.calc-header {
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow);
}

.calc-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left { display: flex; align-items: center; gap: 0.75rem; }

.back-link {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}
.back-link:hover { color: white; }

.header-sep { color: rgba(255,255,255,0.3); }

.header-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: default;
  user-select: none;
}

.btn-settings {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-settings:hover { background: rgba(255,255,255,0.22); }
.btn-settings.hidden { display: none; }

/* ── SETTINGS PANEL ── */
.settings-panel {
  background: white;
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.settings-panel.hidden { display: none; }

.settings-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.settings-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.settings-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type { border-bottom: none; }

.settings-section h3 {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.settings-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.settings-field input {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  width: 100%;
}
.settings-field input:focus { outline: none; border-color: var(--primary-light); }

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.input-euro {
  display: flex;
  align-items: center;
  gap: 0;
}
.input-euro input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-euro span {
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.settings-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── MAIN ── */
.calc-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── STEPS ── */
.calc-step { margin-bottom: 2rem; }
.calc-step.hidden { display: none; }

.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
}

.btn-step-back {
  margin-left: auto;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-step-back:hover { border-color: var(--primary); color: var(--primary); }

/* ── SEARCH ── */
.search-bar-wrap {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
.search-bar:focus-within { border-color: var(--primary-light); }

.search-icon { font-size: 1.1rem; flex-shrink: 0; }

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: background 0.15s;
}
.search-clear:hover { background: var(--bg); }
.search-clear.hidden { display: none; }

/* ── BRAND DROPDOWN ── */
.brand-dropdown {
  padding: 0.65rem 2rem 0.65rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-dropdown:focus { outline: none; border-color: var(--primary-light); }

/* ── STATUS ── */
.status-msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.status-info    { background: #dbeafe; color: var(--primary); border: 1px solid #93c5fd; }
.status-success { background: #dcfce7; color: var(--success); border: 1px solid #86efac; }
.status-warn    { background: #fef3c7; color: var(--warning); border: 1px solid #fcd34d; }
.status-error   { background: #fee2e2; color: var(--danger);  border: 1px solid #fca5a5; }

/* ── PRODUCTS GRID ── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.product-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: var(--shadow-sm);
  text-align: left;
  padding: 0;
}
.product-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.product-card.out-of-stock { opacity: 0.6; }

.product-img-wrap {
  position: relative;
  aspect-ratio: 1;
  background: #f8fafc;
  overflow: hidden;
}
.product-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.75rem;
}
.product-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--border);
}
.stock-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.product-info {
  padding: 0.85rem;
}
.product-brand {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}
.product-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 0.4rem;
}
.variant-count {
  font-size: 0.72rem;
  background: #eff6ff;
  color: var(--primary-light);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
}
.product-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 0.5rem;
}

.empty-products {
  grid-column: 1/-1;
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }

/* ── MODAL VARIANTE ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal-box h3 { font-size: 1.15rem; font-weight: 800; color: var(--primary); margin-bottom: 0.4rem; }
.modal-sub { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.variant-modal-box { max-width: 480px; }

.variant-list { display: flex; flex-direction: column; gap: 0.6rem; }

.variant-btn {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.variant-btn:hover { border-color: var(--primary-light); background: #eff6ff; }
.variant-name { font-weight: 600; font-size: 0.9rem; }
.variant-price { font-weight: 800; color: var(--primary); font-size: 0.95rem; }
.variant-stock { font-size: 0.75rem; white-space: nowrap; }
.in-stock { color: var(--success); }
.no-stock { color: var(--danger); }

/* ── SELECTED PHONE CARD ── */
.selected-phone-card {
  background: white;
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.selected-phone-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.selected-phone-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 0.4rem;
  flex-shrink: 0;
}
.selected-phone-placeholder {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.selected-vendor { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.selected-title  { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.selected-variant{ font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }
.selected-base-price { font-size: 1.25rem; font-weight: 900; color: var(--text); margin-top: 0.3rem; }

/* ── PIN MODAL ── */
.pin-modal-box { max-width: 320px; text-align: center; }
.pin-inputs {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 1.25rem 0;
}
.pin-digit {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}
.pin-digit:focus { border-color: var(--primary-light); }
.pin-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.pin-error.hidden { display: none; }

/* ── FORFAITS SETTINGS ── */
.forfait-setting-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.forfait-setting-row:last-child { border-bottom: none; }

.forfait-setting-name {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
}
.forfait-setting-name:focus { outline: none; border-color: var(--primary-light); }

.btn-delete-forfait {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-delete-forfait:hover { background: #fee2e2; }

.forfait-setting-block {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #f8fafc;
}
.forfait-setting-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.forfait-setting-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.option-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}
.option-toggle input { display: none; }
.option-toggle.active {
  background: #eff6ff;
  border-color: var(--primary-light);
  color: var(--primary-light);
}

/* ── OPTION BADGES (cartes forfait) ── */
.forfait-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin: 0.5rem 0;
  min-height: 1rem;
}
.option-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary-light);
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

/* ── FORFAITS GRID ── */
.forfaits-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.forfait-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.forfait-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.13);
}

.forfait-icon    { font-size: 2.5rem; }
.forfait-label   { font-size: 1rem; font-weight: 800; color: var(--primary); }
.forfait-sublabel{ font-size: 0.78rem; color: var(--text-muted); }
.forfait-remise  {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--success);
  background: #dcfce7;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-top: 0.25rem;
}
.forfait-no-remise {
  color: var(--text-muted);
  background: #f1f5f9;
}
.forfait-prix-final {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
  margin-top: 0.5rem;
  line-height: 1;
}
.forfait-ttc-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.forfait-commentaire {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.25rem 0;
  text-align: center;
}
.forfait-setting-comment {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text);
  margin-top: 0.5rem;
}
.forfait-setting-comment:focus { outline: none; border-color: var(--primary-light); }

/* ── RESULT CARD ── */
.result-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
  max-width: 560px;
}

.result-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.result-header-left { display: flex; align-items: center; gap: 1rem; }
.result-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  flex-shrink: 0;
}
.result-img-placeholder {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.result-vendor  { font-size: 0.72rem; color: rgba(255,255,255,0.7); text-transform: uppercase; font-weight: 600; }
.result-title   { font-size: 1.1rem; font-weight: 800; color: white; }
.result-variant { font-size: 0.82rem; color: rgba(255,255,255,0.75); margin-top: 0.15rem; }
.result-badge-forfait {
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.3);
  white-space: nowrap;
}

.result-breakdown { padding: 1.5rem; }

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { color: var(--text-muted); }
.breakdown-val   { font-weight: 600; }

.breakdown-remise .breakdown-label { color: var(--success); }
.breakdown-remise .breakdown-val   { color: var(--success); font-weight: 700; }

.breakdown-total {
  background: #eff6ff;
  margin: 0 -1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 0;
}
.breakdown-total .breakdown-label { font-size: 1rem; font-weight: 700; color: var(--primary); }
.breakdown-total .breakdown-val   { font-size: 1.75rem; font-weight: 900; color: var(--primary); }

.result-savings {
  background: #dcfce7;
  color: var(--success);
  padding: 0.85rem 1.5rem;
  font-size: 0.88rem;
  border-top: 1px solid #86efac;
}
.result-footer {
  padding: 0.65rem 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f8fafc;
  border-top: 1px solid var(--border);
  text-align: right;
}

/* ── BUTTONS ── */
.btn {
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

/* ── ALERT ── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.85rem; }
.alert-success { background: #dcfce7; color: var(--success); border: 1px solid #86efac; }
.alert-danger  { background: #fee2e2; color: var(--danger);  border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: var(--primary); border: 1px solid #93c5fd; }

/* ── PRINT ── */
.print-only { display: none; }

@media print {
  .calc-header,
  .settings-panel,
  #step-phone,
  #step-forfait,
  .btn,
  .btn-step-back { display: none !important; }

  .print-only { display: block !important; }
  #step-result { display: block !important; }
  #result-card { display: none; }

  .print-header { text-align: center; margin-bottom: 2rem; }
  .print-header h1 { font-size: 1.5rem; }
  .print-header p  { color: #666; }
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .forfaits-grid { grid-template-columns: 1fr; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .result-header { flex-direction: column; }
  .calc-main { padding: 1rem; }
}
@media (max-width: 400px) {
  .products-grid { grid-template-columns: 1fr; }
}
