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

html, body {
  height: 100%;
  background: #ffffff;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#pdf-viewer {
  width: 100%;
  background: #525659;
  overflow-y: auto;
}

#pdf-viewer canvas {
  display: block;
  margin: 0.5rem auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  z-index: 100;
  padding: 4rem 1rem 1rem;
}

.modal-overlay.visible { display: flex; }

.modal-box {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  pointer-events: all;
  animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2d2d2d;
  margin-bottom: 0.25rem;
}

.modal-box .subtitle {
  font-size: 0.8rem;
  color: #737373;
  margin-bottom: 1.5rem;
}

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

.form-row.full   { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }

.form-row.triple input {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.4rem;
  font-size: 0.82rem;
}

.form-row.triple label {
  font-size: 0.65rem;
  white-space: nowrap;
}

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

/* ── Autocomplete ── */
.ac-wrap { position: relative; }

.ac-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 8px 8px;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 300;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.ac-list li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.ac-list li:last-child { border-bottom: none; }

.ac-list li:hover,
.ac-list li.ac-active {
  background: #0d2b45;
  color: #fff;
}

.ac-nom { font-weight: 600; }
.ac-tel { font-size: 0.78rem; opacity: 0.7; }

label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #737373;
}

input[type="date"] {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: #2d2d2d;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

input[type="date"]:focus {
  border-color: #404040;
  background: rgba(255,255,255,0.9);
}

input[type="text"], input[type="tel"], input[type="number"], input[type="email"] {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: #2d2d2d;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

input::placeholder { color: #aaa; }

input:required { background: #ddeeff; }

input[type="text"]:focus, input[type="tel"]:focus,
input[type="number"]:focus, input[type="email"]:focus {
  border-color: #404040;
  background: rgba(255,255,255,0.9);
}

button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.65rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #2d2d2d;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

button[type="submit"]:hover { opacity: 0.8; }

.btn-nav-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn-nav-row button {
  flex: 1;
  padding: 0.65rem 0.5rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #0d2b45;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-nav-row button:hover { opacity: 0.8; }

.equip-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.25rem;
}

.equip-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #2d2d2d;
  cursor: pointer;
}

.equip-group input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; cursor: pointer;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 400;
  margin-top: 0.25rem;
  cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; cursor: pointer;
}

.din-field {
  background: #e8f0e8 !important;
  color: #0d2b45;
  font-weight: bold;
  cursor: default;
  max-width: 120px;
}

.niveau-group {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
}

.niveau-group label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #2d2d2d;
  cursor: pointer;
}

.niveau-group input[type="radio"] {
  width: 15px; height: 15px; padding: 0; cursor: pointer;
}

/* ── Bouton Assistant ── */
.btn-questions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.35rem 0.85rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: #0d2b45;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(13,43,69,0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.02em;
}
.btn-questions:hover {
  background: #1a4a6e;
  box-shadow: 0 4px 12px rgba(13,43,69,0.45);
  transform: translateY(-1px);
}

.modal-box { position: relative; }

/* ── Wizard questions dans le modal ── */
.modal-form-content { display: block; }

.qwiz-panel {
  display: none;
  flex-direction: column;
  margin: -2rem -2.5rem;
  border-radius: 12px;
  overflow: hidden;
}

.qwiz-panel.active { display: flex; }

.qwiz-p-header {
  background: #7a1e1e;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  gap: 0.75rem;
  flex-shrink: 0;
}

.qwiz-p-back-btn, .qwiz-p-menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.qwiz-p-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
}

.qwiz-p-tabs-wrap {
  background: #2a2a2a;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.qwiz-p-tabs-wrap::-webkit-scrollbar { display: none; }
.qwiz-p-locataire {
  background: #7a1e1e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  padding: 0.4rem 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qwiz-p-tabs { display: flex; min-width: max-content; }

.qwiz-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem 1rem 0;
  min-width: 66px;
  border-bottom: 2px solid transparent;
  color: #666;
  gap: 0.15rem;
  min-height: 64px;
}

.qwiz-tab.active { color: #fff; border-bottom-color: #fff; }
.qwiz-tab.done { color: #999; }

.qwiz-tab-icon { width: 26px; height: 26px; flex-shrink: 0; }

.qwiz-tab-label {
  font-size: 0.58rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  max-width: 60px;
  white-space: pre-line;
}

.qwiz-tab-value {
  font-size: 0.55rem;
  color: #aaa;
  text-align: center;
  line-height: 1.2;
  max-width: 60px;
}

.qwiz-p-cards {
  background: #3d3d3d;
  padding: 0.9rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.qwiz-card {
  background: #7a1e1e;
  border-radius: 8px;
  padding: 0.9rem 0.3rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  color: #fff;
  text-align: center;
  border: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
  min-height: 90px;
  user-select: none;
}

.qwiz-card:active { transform: scale(0.96); }
.qwiz-card:hover { background: #621818; }
.qwiz-card.selected { border-color: #fff; background: #a93226; box-shadow: 0 0 0 2px #fff; }
.qwiz-card.disabled { background: #555; color: #777; cursor: default; pointer-events: none; }
.qwiz-card.disabled svg { opacity: 0.4; }

.qwiz-card-icon { width: 40px; height: 40px; flex-shrink: 0; }

.qwiz-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

/* ── Guide panel ── */
#guide-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  bottom: 0;
  background: transparent;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem 1rem;
  transform: translateX(-100%);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s ease;
  overflow-y: auto;
  pointer-events: none;
}

#guide-content {
  pointer-events: all;
}

.guide-btn {
  display: block;
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  background: #0d2b45;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.guide-btn:hover {
  background: #0a2038;
}

body.guide-open #guide-panel {
  transform: translateX(0);
}

body.guide-open.modal-active #guide-panel {
  width: 50%;
}

/* Overlay plein écran, mais modal-box décalée à droite quand le guide est ouvert */
body.guide-open.modal-active .modal-overlay {
  padding-left: 50%;
}

#guide-content {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#guide-content h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2d2d2d;
  margin-bottom: 0.25rem;
}

#guide-content p {
  font-size: 1.75rem;
  line-height: 1.7;
  color: #555;
}

#guide-content .guide-extra {
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  background: #e8f4e8;
  border-left: 4px solid #2d6a4f;
  border-radius: 4px;
  font-size: 1.4rem;
  color: #1a4a30;
}

/* ── Toolbar ── */
#toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

#toolbar button {
  padding: 0.35rem 0.9rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #2d2d2d;
  background: #f0f0f0;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.15s;
}

#toolbar button:hover { background: #e0e0e0; }
#toolbar button.active { background: #2d2d2d; color: #fff; border-color: #2d2d2d; }
#btn-db  { background: #2d6a4f; color: #fff; border-color: #2d6a4f; margin-left: auto; }
#btn-db:hover  { background: #245a42; }
#btn-save { background: #6a4c2d; color: #fff; border-color: #6a4c2d; }
#btn-save:hover { background: #5a3e24; }
#btn-save.saved { background: #2d6a4f; border-color: #2d6a4f; }
#toolbar #btn-wizard { background: #c0392b; color: #fff; border-color: #c0392b; }
#toolbar #btn-wizard:hover { background: #a93226; border-color: #a93226; }
#btn-guide { background: #5a3472; color: #fff; border-color: #5a3472; }
#btn-guide:hover { background: #4a2860; }
#btn-guide.active { background: #7a4a9a; border-color: #7a4a9a; }
#btn-loueur { background: #0d2b45; color: #fff; border-color: #0d2b45; }
#btn-loueur:hover:not(:disabled) { background: #0a2038; }
#btn-loueur:disabled { background: #b0bec5; border-color: #b0bec5; opacity: 0.5; cursor: not-allowed; }


#apercu-content {
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Consolas', monospace;
  font-size: 0.82rem;
  padding: 1rem;
  border-radius: 6px;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre;
}

/* ── Groupe info (modal Responsable) ── */
.groupe-info[hidden] { display: none; }
.groupe-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: rgba(13,43,69,0.06);
  border: 1px solid rgba(13,43,69,0.18);
  border-radius: 8px;
  gap: 0.2rem;
  min-width: 0;
}
.gi-label {
  font-size: 0.60rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #0d2b45;
  opacity: 0.65;
}
.gi-nom {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0d2b45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gi-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.gi-code {
  font-size: 0.70rem;
  color: #666;
}
.gi-effectif {
  font-size: 0.68rem;
  font-weight: 700;
  color: #2d6a4f;
  background: rgba(45,106,79,0.12);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOutLeft {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}

.modal-overlay.closing .modal-box {
  animation: slideOutLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
