/* ════════════════════════════════════════════════════════════════════════
   VOLUMA v65 — STYLES
   Design Stripe-inspired : sobre, premium, typographique
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --font-sans: 'Albert Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --bg: #F5F2EC;
  --bg-alt: #FAF7F1;
  --surface: #FFFFFF;
  --border: #E5E0D6;
  --border2: #D2CBC0;
  --ink: #1A1A1A;
  --ink2: #555;
  --ink3: #888;
  --ink4: #B0A89C;
  --gold: #C09A28;
  --green: #2A7A4A;
  --red: #CC2222;
  --orange: #B85C00;
  --blue: #4A78C8;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Screens génériques */
.screen {
  flex: 1;
  display: none;
  overflow-y: auto;
  background: var(--bg);
  min-height: 0;        /* Critical : permet au flex child de shrink */
}

.screen.active { display: flex; flex-direction: column; }

/* Screen plan : jamais de scroll, le canvas doit prendre toute la hauteur */
#screen-plan {
  overflow: hidden;
}

h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 14px;
}

p { margin-bottom: 12px; }
.lead { color: var(--ink2); margin-bottom: 28px; }
.muted { color: var(--ink3); font-size: 13px; }

/* ══ HEADER ══════════════════════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--ink);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-style: italic;
}

.brand-text { letter-spacing: 0.3px; font-style: italic; }

.nav-steps {
  display: flex;
  gap: 4px;
  font-size: 13px;
}

.nav-step {
  padding: 6px 12px;
  color: var(--ink3);
  border-radius: 6px;
  font-weight: 500;
}

.nav-step.active {
  color: var(--ink);
  background: var(--bg);
}

.header-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--ink2);
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--border2);
}

/* ══ SCREENS ════════════════════════════════════════════════════════ */
.screen {
  flex: 1;
  display: none;
  overflow-y: auto;
  background: var(--bg);
}

.screen.active { display: flex; flex-direction: column; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 32px;
  width: 100%;
}

.container.narrow { max-width: 680px; }

/* ══ ONBOARDING ═════════════════════════════════════════════════════ */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0 36px;
}

.shape-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.shape-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}

.shape-card.selected {
  border-color: var(--ink);
  background: var(--bg-alt);
}

.shape-icon {
  width: 100%;
  height: 60px;
  color: var(--ink3);
  margin-bottom: 10px;
}

.shape-card.selected .shape-icon { color: var(--ink); }

.shape-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.shape-desc { font-size: 13px; color: var(--ink3); }

.dim-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }

.dim-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.dim-row label {
  font-weight: 600;
  width: 80px;
}

.dim-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.dim-row input:focus {
  outline: none;
  border-color: var(--ink);
}

.unit { color: var(--ink3); font-family: var(--font-mono); }

/* ══ BUTTONS ════════════════════════════════════════════════════════ */
.btn {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.btn-primary:hover { background: #333; }
.btn-primary:disabled { background: #999; border-color: #999; }

.btn-lg { padding: 14px 28px; font-size: 15px; font-weight: 600; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.actions-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 32px;
}

/* ══ CONFIG ÉQUIPEMENTS ═════════════════════════════════════════════ */
.config-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.equip-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.equip-card:hover { border-color: var(--border2); }
.equip-card:has(input:checked) {
  border-color: var(--ink);
  background: var(--bg-alt);
}

.equip-card.required {
  border-color: var(--ink);
  background: var(--bg-alt);
  cursor: default;
}

.equip-card input { position: absolute; top: 8px; right: 8px; }

.equip-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  color: white;
  font-size: 22px;
  font-weight: 600;
}

.equip-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.equip-meta { font-size: 12px; color: var(--ink3); }

.warn-box, .ok-box {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
  font-weight: 500;
}

.warn-box { background: #FEF3E0; color: var(--orange); border: 1px solid #F0D8A8; }
.ok-box { background: #E8F4EC; color: var(--green); border: 1px solid #BCE0CB; }

/* ══ PLAN + SOFIA ═══════════════════════════════════════════════════ */
.plan-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100%;
  flex: 1;
  overflow: hidden;
}

.plan-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.plan-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#plan-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Sidebar : alertes + Sofia, scroll indépendant */
.plan-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.alerts-panel-sidebar {
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.alerts-panel-sidebar:empty {
  display: none;
  border-bottom: none;
}

.alert-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.alert-summary.ok { color: var(--green); border-color: #BCE0CB; }
.alert-summary.err { color: var(--red); border-color: #E8B0B0; background: #FEF0F0; }
.alert-summary.warn { color: var(--orange); border-color: #F0D8A8; background: #FEF8EE; }

.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.alert-item.err { border-left: 3px solid var(--red); }
.alert-item.warn { border-left: 3px solid var(--orange); }

/* Sofia section */
.sofia-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sofia panel */
.sofia-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sofia-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sofia-avatar {
  width: 36px;
  height: 36px;
  background: var(--ink);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-style: italic;
}

.sofia-name { font-weight: 600; }
.sofia-status { font-size: 12px; color: var(--ink3); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-msg-user {
  background: var(--ink);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg-sofia {
  background: var(--bg);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.typing { opacity: 0.5; font-style: italic; }

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
}

#chat-input:focus { outline: none; border-color: var(--ink); }

.btn-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--ink);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
}

.btn-send:hover { background: #333; }

.plan-footer-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  justify-content: space-between;
}

/* ══ DEVIS ══════════════════════════════════════════════════════════ */
.devis-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
}

.devis-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.devis-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.devis-group-name { color: var(--ink2); }

.devis-group-total {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 700;
}

.devis-item {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--bg-alt);
}

.devis-group .devis-item:last-child { border-bottom: none; }

.devis-item-label { font-weight: 500; }

.devis-item-meta {
  font-size: 12px;
  color: var(--ink3);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.devis-item-price {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
}

.devis-item-link {
  background: var(--bg);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border2);
  transition: all 0.15s;
}

.devis-item-link:hover { background: var(--ink); color: white; }

.devis-total-wrap {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}

.devis-total { font-size: 28px; font-weight: 700; font-family: var(--font-mono); }

/* ══ SETTINGS DIALOG ════════════════════════════════════════════════ */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog-backdrop.open { display: flex; }

.dialog {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  max-width: 480px;
  width: 90%;
}

.dialog h2 { margin-top: 0; }

.dialog input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  margin-top: 6px;
}

.dialog label { font-size: 13px; color: var(--ink2); margin-top: 12px; display: block; }
.dialog a { color: var(--blue); }

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ══ TOAST ══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: opacity 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ══ PLACEMENT ══════════════════════════════════════════════════════ */
.placement-room-preview {
  display: flex;
  justify-content: center;
  margin: 20px 0 28px;
}

.placement-room-preview svg {
  max-width: 400px;
  width: 100%;
  height: auto;
}

.placement-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.placement-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
}

.placement-row-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.placement-row-label {
  flex: 1;
  font-weight: 500;
}

.placement-row-select select {
  padding: 8px 14px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--surface);
  cursor: pointer;
  min-width: 120px;
}

.placement-row-select select:focus {
  outline: none;
  border-color: var(--ink);
}

/* ══ RESPONSIVE ═════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .nav-steps { display: none; }
  .container { padding: 24px 16px; }
  h1 { font-size: 24px; }
  .shape-grid { grid-template-columns: 1fr; }
  .plan-layout { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .plan-sidebar { border-left: none; border-top: 1px solid var(--border); }
  .alerts-panel-sidebar { max-height: 120px; }
  .placement-row { flex-wrap: wrap; }
}
