/* ============================================
   app.css — Layout principal & composants SaaS
   ============================================ */

/* ---- Layout deux colonnes ---- */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar navigation ---- */
#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #13151f;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 8px 12px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 16px;
}
.sidebar-logo-text {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.sidebar-logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 12px;
  margin: 16px 0 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.85);
}
.nav-item.active {
  background: rgba(108,99,255,0.18);
  color: #a78bfa;
}
.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
}
.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-username { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.7); }
.btn-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
  display: block;
  transition: color 0.15s;
}
.btn-logout:hover { color: #e74c3c; }

/* ---- Zone principale ---- */
#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Topbar ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #0f1117;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex: 1;
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.25);
  font-size: 14px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 13px;
  color: #e2e8f0;
  outline: none;
  transition: all 0.2s;
}
.search-input::placeholder { color: rgba(255,255,255,0.2); }
.search-input:focus {
  border-color: rgba(108,99,255,0.5);
  background: rgba(108,99,255,0.06);
}

/* ---- Contenu des pages ---- */
.page { display: none; padding: 24px; animation: fade-in 0.2s ease; }
.page.active { display: block; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Cards stats (dashboard) ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: #1a1d27;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 18px 20px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: rgba(108,99,255,0.3); }
.stat-label { font-size: 11px; color: rgba(255,255,255,0.4); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; color: #fff; line-height: 1; }
.stat-sub   { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 4px; }

/* ---- Section header ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title-text {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---- Boutons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108,99,255,0.35);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(108,99,255,0.5); opacity: 0.95; }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-danger {
  background: rgba(231,76,60,0.15);
  color: #e74c3c;
  border: 1px solid rgba(231,76,60,0.2);
}
.btn-danger:hover { background: rgba(231,76,60,0.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 6px; }

/* ---- Table devis ---- */
.data-table {
  background: #1a1d27;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  overflow: hidden;
}
.data-table-header {
  display: grid;
  grid-template-columns: 60px 1fr 160px 110px 100px 90px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.data-row {
  display: grid;
  grid-template-columns: 60px 1fr 160px 110px 100px 90px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center;
  transition: background 0.12s;
  cursor: pointer;
}
.data-row:last-child { border-bottom: none; }
.data-row:hover { background: rgba(255,255,255,0.03); }
.data-row-id { font-size: 11px; font-family: monospace; color: rgba(255,255,255,0.3); }
.data-row-main { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.data-row-sub  { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 2px; }
.data-row-price { font-size: 14px; font-weight: 700; color: #fff; }
.data-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- Messages CRM ---- */
.messages-list { display: flex; flex-direction: column; gap: 10px; }

.msg-card {
  background: #1a1d27;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px 16px;
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.msg-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255,255,255,0.1);
  transition: background 0.15s;
}
.msg-card.urgent::before { background: #e74c3c; }
.msg-card.traite::before { background: #2ecc71; }
.msg-card.rappeler::before { background: #3498db; }
.msg-card:hover { border-color: rgba(108,99,255,0.3); background: #1e2235; }

.msg-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.msg-card-name { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.msg-card-tel  { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 2px; }
.msg-card-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.msg-card-body   { font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.5; }
.msg-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.msg-card-meta { font-size: 11px; color: rgba(255,255,255,0.25); }
.msg-card-actions { display: flex; gap: 6px; }

/* ---- Wizard panel ---- */
#wizard-panel {
  position: fixed;
  top: 0; right: -660px;
  width: 640px;
  height: 100%;
  background: #13151f;
  border-left: 1px solid rgba(108,99,255,0.25);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
#wizard-panel.open { right: 0; }

#wizard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  display: none;
  backdrop-filter: blur(2px);
}
#wizard-overlay.show { display: block; }

.wizard-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  background: #13151f;
  z-index: 10;
}
.wizard-header-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.wizard-header-title { font-size: 16px; font-weight: 700; color: #fff; flex: 1; }
.wizard-step-pill {
  background: rgba(108,99,255,0.2);
  color: #a78bfa;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}
.wizard-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.5);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.wizard-close:hover { background: rgba(231,76,60,0.2); color: #e74c3c; }

.wizard-progress {
  padding: 16px 24px 0;
}
.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #a78bfa);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
}

.wizard-body { padding: 24px; flex: 1; }

.wizard-q-label {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.4;
}
.wizard-q-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 18px;
}

.opts-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.opt-btn {
  padding: 10px 18px;
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 30px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.03);
  transition: all 0.12s;
}
.opt-btn:hover {
  border-color: rgba(108,99,255,0.5);
  color: #a78bfa;
  background: rgba(108,99,255,0.08);
}
.opt-btn.sel {
  background: linear-gradient(135deg, #6c63ff, #764ba2);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(108,99,255,0.35);
}

.wiz-input {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  font-size: 14px;
  color: #e2e8f0;
  outline: none;
  transition: all 0.2s;
}
.wiz-input:focus {
  border-color: rgba(108,99,255,0.5);
  background: rgba(108,99,255,0.06);
}
.wiz-input-sm { width: 120px; }

.wiz-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.wiz-shortcut {
  padding: 6px 14px;
  border: 1.5px solid rgba(52,152,219,0.35);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #3498db;
  background: rgba(52,152,219,0.08);
  transition: all 0.12s;
}
.wiz-shortcut:hover { background: rgba(52,152,219,0.2); }

.dim-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dim-label { font-size: 13px; color: rgba(255,255,255,0.4); font-weight: 600; }

.groupe-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%;
  margin: 14px 0 6px;
}

.wizard-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #13151f;
  position: sticky;
  bottom: 0;
}
.btn-wiz-back {
  padding: 11px 22px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.4);
  transition: all 0.15s;
}
.btn-wiz-back:hover { border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.7); }
.btn-wiz-next {
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  color: #fff;
  box-shadow: 0 4px 15px rgba(108,99,255,0.4);
  transition: all 0.15s;
}
.btn-wiz-next:hover { box-shadow: 0 4px 22px rgba(108,99,255,0.55); }

/* ---- Résultat devis ---- */
.result-total {
  background: linear-gradient(135deg, #6c63ff, #764ba2);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.result-total-label { font-size: 13px; color: rgba(255,255,255,0.7); }
.result-total-sub   { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 3px; }
.result-total-val   { font-size: 34px; font-weight: 800; color: #fff; }

.result-lines {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.result-line:last-child { border-bottom: none; }
.result-line-label { color: rgba(255,255,255,0.5); }
.result-line-val   { font-weight: 600; color: #e2e8f0; }

/* ---- Modal message ---- */
#msg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  padding: 20px;
}
#msg-modal-overlay.show { display: flex; }

.msg-modal {
  background: #1a1d27;
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  animation: modal-in 0.25s cubic-bezier(0.4,0,0.2,1);
}
@keyframes modal-in {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
}
.form-row { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 7px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 9px;
  font-size: 13px;
  color: #e2e8f0;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}
.form-input::placeholder, .form-textarea::placeholder { color: rgba(255,255,255,0.2); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: rgba(108,99,255,0.5);
  background: rgba(108,99,255,0.06);
}
.form-select { cursor: pointer; }
.form-select option { background: #1a1d27; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.urgence-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(231,76,60,0.08);
  border: 1.5px solid rgba(231,76,60,0.15);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.urgence-toggle:hover { background: rgba(231,76,60,0.15); }
.urgence-toggle.active {
  background: rgba(231,76,60,0.2);
  border-color: rgba(231,76,60,0.4);
}
.urgence-toggle input { display: none; }
.urgence-label { font-size: 13px; font-weight: 700; color: #e74c3c; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ---- Client autocomplete ---- */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #21253a;
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: 9px;
  overflow: hidden;
  z-index: 100;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #e2e8f0;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: rgba(108,99,255,0.15); }
.autocomplete-item-nom { font-weight: 600; }
.autocomplete-item-tel { font-size: 11px; color: rgba(255,255,255,0.35); }

/* ---- Panier ---- */
#panier-bar {
  background: #13151f;
  border-bottom: 1px solid rgba(108,99,255,0.2);
  padding: 12px 24px;
  position: sticky;
  top: 57px;
  z-index: 40;
  display: none;
}
#panier-bar.show { display: block; }
.panier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panier-title { font-size: 13px; font-weight: 700; color: #a78bfa; }
.panier-items { display: flex; flex-wrap: wrap; gap: 8px; }
.panier-chip {
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.panier-chip-name  { color: #e2e8f0; font-weight: 600; }
.panier-chip-price { color: #a78bfa; font-weight: 700; }
.panier-chip-del {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  line-height: 1;
  transition: color 0.1s;
}
.panier-chip-del:hover { color: #e74c3c; }

/* ---- Empty states ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: rgba(255,255,255,0.2);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; }

/* ---- Scrollbar custom ---- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #sidebar { display: none; }
  .data-table-header,
  .data-row { grid-template-columns: 50px 1fr 100px 90px; }
  .data-row > *:nth-child(3),
  .data-table-header > *:nth-child(3) { display: none; }
}
@media (max-width: 768px) {
  #wizard-panel { width: 100%; right: -100%; }

  #wiz input[type="number"],
  #wiz input[type="text"],
  #wizard-panel input[type="number"],
  #wizard-panel input[type="text"] {
    font-size: 16px !important;
    padding: 13px 14px !important;
    box-sizing: border-box !important;
  }

  .wiz-input-sm { width: 100% !important; }
}
