/* Page « Créer une facture » — overlay depuis le tableau de bord Service client */

.af-page {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink-1);
  caret-color: var(--accent);
}
.af-page ::selection { background: var(--accent-soft); color: var(--ink-1); }
.af-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(14px + var(--safe-top, 0px)) 22px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-1);
  box-shadow: var(--sh-1);
}
.af-top-text { flex: 1; min-width: 0; }
.af-top-text h1 {
  margin: 0;
  font-size: var(--t-18);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}
.af-top-text p { margin: 3px 0 0; color: var(--ink-3); font-size: var(--t-12); }
.af-close {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  cursor: pointer;
}
.af-close:hover { background: var(--surface-2); }
.af-close:focus-visible,
.af-btn:focus-visible,
.af-input:focus-visible,
.af-agent:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.af-body { flex: 1; overflow: auto; padding: 18px 22px 40px; }
.af-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  grid-template-areas: "main side";
  gap: 16px;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}
.af-main { grid-area: main; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.af-side {
  grid-area: side;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.af-card {
  background: var(--surface);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: 16px 16px 18px;
  box-shadow: var(--sh-1);
}
.af-card h2 {
  margin: 0 0 4px;
  font-size: var(--t-15);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-tight);
}
.af-lead { margin: 0 0 12px; color: var(--ink-3); font-size: var(--t-13); line-height: var(--lh-normal); max-width: 68ch; }
.af-muted { margin: 0; color: var(--ink-3); font-size: var(--t-13); line-height: var(--lh-normal); }
.af-error, .af-form-error { margin: 0; color: var(--danger); font-size: var(--t-13); }
.af-warn { color: var(--warn); }
.af-hint { margin: 6px 0 0; color: var(--ink-3); font-size: var(--t-12); }
.af-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.af-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.af-search .af-input { flex: 1; min-width: 140px; }
.af-input {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--t-14);
}
.af-input::placeholder { color: var(--ink-3); }
.af-input:focus { outline: none; border-color: var(--accent); }
.af-date { margin-top: 6px; width: 100%; max-width: 220px; }
.af-combo { position: relative; margin-top: 6px; }
.af-combo .af-input { width: 100%; }
.af-combo-list {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
}
.af-combo-list[hidden] { display: none; }
.af-combo-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.af-combo-item.is-active { background: var(--accent-soft); }
.af-combo-name {
  min-width: 0;
  font-size: var(--t-13);
  font-weight: var(--w-medium);
  color: var(--ink-1);
}
.af-combo-side {
  flex: none;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--t-11);
  color: var(--ink-3);
}
.af-combo-empty { padding: 8px 10px; font-size: var(--t-12); color: var(--ink-3); }
.af-note { height: auto; padding: 10px 12px; resize: vertical; width: 100%; margin-top: 6px; }
.af-label {
  display: block;
  margin-top: 14px;
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  color: var(--ink-2);
}
.af-label span { font-weight: var(--w-medium); color: var(--ink-3); }

.af-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  cursor: pointer;
}
.af-btn:hover { background: var(--surface-2); }
.af-btn:disabled { opacity: 0.55; cursor: default; }
.af-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-foreground); }
.af-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.af-generate { width: 100%; height: 44px; font-size: var(--t-14); }
.af-ready { margin: 0; color: var(--ink-2); font-size: var(--t-13); font-weight: var(--w-semibold); font-variant-numeric: tabular-nums; }

.af-res {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--t-13);
  color: var(--ink-2);
}
.af-res-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.af-res strong { color: var(--ink-1); font-size: var(--t-14); }
.af-airbnb {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: #ff5a5f;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
}
.af-airbnb:hover { filter: brightness(1.08); }
.af-airbnb:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.af-res-room { color: var(--ink-1); font-weight: var(--w-semibold); }
.af-clean {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-1);
}
.af-clean-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.af-clean h3 {
  margin: 0;
  font-size: var(--t-13);
  font-weight: var(--w-bold);
  color: var(--ink-1);
}
.af-clean-score {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink-2);
}
.af-clean-score svg { width: 15px; height: 15px; display: block; }
.af-clean-score .is-on { fill: #f5b400; }
.af-clean-score .is-off { fill: var(--ink-3); }
.af-clean-photos {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0 0 2px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.af-clean-photos li { flex: none; scroll-snap-align: start; }
.af-clean-photos button {
  display: block;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
}
.af-clean-photos button:hover { border-color: var(--line-3); }
.af-clean-photos button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.af-clean-photos img,
.af-clean-photos video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.af-clean-notes {
  margin: 0;
  max-width: 68ch;
  max-height: 7.2rem;
  overflow: auto;
  color: var(--ink-1);
  font-size: var(--t-14);
  line-height: 1.55;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.af-clean-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0 12px;
  text-align: left;
}
.af-clean-open:hover {
  border-color: var(--accent);
  background: var(--surface);
}
.af-clean-count {
  color: var(--ink-2);
  font-size: var(--t-12);
  font-weight: var(--w-medium);
  font-variant-numeric: tabular-nums;
}
.af-clean-wait { margin: 14px 0 0; color: var(--ink-3); font-size: var(--t-12); }

.af-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.af-cat h3 {
  margin: 0 0 8px;
  font-size: var(--t-12);
  font-weight: var(--w-bold);
  color: var(--ink-2);
}
.af-cat { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.af-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
}
.af-agent:hover { border-color: var(--line-3); }
.af-agent:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.af-agent input { margin: 0; flex: none; accent-color: var(--accent); }
.af-agent-name { font-size: var(--t-13); font-weight: var(--w-semibold); min-width: 0; }
.af-agent-role { margin-left: auto; color: var(--ink-3); font-size: var(--t-11); }

.af-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.af-identity img {
  width: 72px;
  height: 48px;
  object-fit: contain;
  flex: none;
  background: #fff;
  border-radius: var(--r-sm);
}
.af-identity div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.af-identity strong { color: var(--ink-1); font-size: var(--t-14); }
.af-identity span { color: var(--ink-2); font-size: var(--t-12); }

.af-models { position: relative; margin: 0 0 16px; }
.af-models-btn::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.af-models-btn[aria-expanded="true"]::after { transform: translateY(1px) rotate(225deg); }
.af-models-menu {
  position: absolute;
  z-index: 4;
  top: calc(100% + 6px);
  left: 0;
  width: min(100%, 520px);
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  max-height: min(68vh, 480px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.af-models-menu[hidden] { display: none; }
.af-model {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px;
}
.af-model + .af-model { border-top: 1px solid var(--line-1); }
.af-model-text { flex: 1 1 100%; min-width: 0; }
.af-model .af-btn { height: 32px; padding: 0 10px; }
.af-tpl-name { display: block; font-size: var(--t-13); font-weight: var(--w-semibold); color: var(--ink-1); }
.af-tpl-sub { display: block; margin-top: 1px; font-size: var(--t-12); font-weight: var(--w-regular, 400); color: var(--ink-2); }
.af-model .af-select { width: auto; min-width: 132px; height: 32px; }
.af-hours { width: 56px; height: 32px; }
.af-tpl-price {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-1);
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.af-tpl-price input {
  width: 6.4rem;
  height: 32px;
  padding: 0 8px;
  font-size: var(--t-13);
  font-weight: var(--w-bold);
}
.af-composer > label {
  display: block;
  margin: 0 0 8px;
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
}
.af-element { width: 100%; margin-bottom: 8px; }
.af-composer-row {
  display: grid;
  grid-template-columns: 64px 72px 100px minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.af-composer-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  min-width: 0;
  font-size: var(--t-11);
  font-weight: var(--w-semibold);
  color: var(--ink-2);
}
.af-select { width: 100%; padding-right: 8px; }
.af-num { text-align: right; font-variant-numeric: tabular-nums; }
.af-elements-hint { margin: 10px 0 0; }
.af-elements { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.af-elements li.af-el {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 4px 8px;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid var(--line-1);
  border-radius: var(--r-md);
  font-size: var(--t-13);
}
.af-elements-empty {
  display: block;
  color: var(--ink-3);
  border-top: 0;
  padding: 10px 0 0;
  font-size: var(--t-13);
}
.af-grip {
  display: grid;
  place-items: center;
  width: 36px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  cursor: grab;
  touch-action: none;
}
.af-grip svg { display: block; fill: currentColor; }
.af-grip:hover { color: var(--ink-1); background: var(--surface-2); }
.af-grip:focus-visible,
.af-el-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.af-el-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 4px 4px 4px 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-user-drag: none;
}
.af-el-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.af-el-copy strong { overflow-wrap: anywhere; font-weight: var(--w-bold); }
.af-el:hover { background: var(--surface-2); }
.af-el-body:hover .af-el-copy strong { text-decoration: underline; text-underline-offset: 2px; }
.af-el.is-poised { background: var(--surface-2); }
.af-el.is-dragging {
  position: relative;
  z-index: 2;
  background: var(--surface);
  box-shadow: var(--sh-3);
  cursor: grabbing;
}
.af-elements.is-sorting,
.af-elements.is-sorting .af-grip,
.af-elements.is-sorting .af-el-body { cursor: grabbing; touch-action: none; user-select: none; }
.af-elements li.af-el-editing {
  display: block;
  padding-top: 10px;
  background: transparent;
}
.af-elements li.af-el-editing:hover { background: transparent; }
.af-el-edit { display: flex; flex-direction: column; gap: 8px; }
.af-el-edit .af-element { margin-bottom: 0; }
.af-el-edit-row { grid-template-columns: 64px 72px 100px minmax(140px, 1fr) auto; }
.af-el-edit-actions {
  grid-column: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.af-el-amt { font-weight: var(--w-bold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.af-just-added { animation: af-in 180ms var(--ease-out); }
@keyframes af-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.af-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.af-icon-btn:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.af-sheet {
  background: #fff;
  color: #141a21;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: 22px 22px 16px;
  max-height: calc(100vh - 168px);
  overflow: auto;
  scrollbar-color: #cfd4da transparent;
  font-variant-numeric: tabular-nums;
}
.af-sheet-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; min-height: 52px; }
.af-sheet-brand { min-width: 0; flex: 1; }
.af-sheet-brand img { display: block; width: 92px; height: 44px; object-fit: contain; object-position: left center; margin: 0; }
.af-sheet-who p, .af-sheet-dest p, .af-sheet-stay p { margin: 0; font-size: 12px; line-height: 1.45; color: #3d4654; overflow-wrap: break-word; }
.af-sheet-co { margin: 0; font-size: 14px; font-weight: var(--w-bold); color: #141a21; letter-spacing: var(--ls-tight); }
.af-sheet-meta { text-align: right; flex: none; max-width: none; }
.af-sheet-meta h2 { margin: 0 0 8px; font-size: 13px; font-weight: var(--w-bold); letter-spacing: 0; line-height: 1.25; white-space: nowrap; }
.af-sheet-meta p { margin: 0; font-size: 11px; line-height: 1.5; color: #3d4654; white-space: nowrap; }
.af-sheet-parties { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; }
.af-sheet-who { min-width: 0; }
.af-sheet-dest { text-align: right; flex: none; }
.af-sheet-stay { margin-top: 18px; }
.af-sheet-room, .af-sheet-depart { font-size: 13px; font-weight: var(--w-bold); color: #141a21; }
.af-sheet-wait { color: #3d4654; }
.af-sheet-table { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: 11px; }
.af-sheet-table th { text-align: left; font-weight: var(--w-semibold); color: #3d4654; background: #f4f5f6; padding: 6px 4px; }
.af-sheet-table th:nth-child(n + 3), .af-sheet-table td:nth-child(n + 3) { text-align: right; white-space: nowrap; padding-left: 10px; }
.af-sheet-table td:nth-child(2) { text-align: left; }
.af-sheet-table td { padding: 7px 4px; border-bottom: 1px solid #e8eaed; color: #141a21; vertical-align: top; }
.af-sheet-totals { margin: 18px 0 0 auto; width: max-content; min-width: 230px; }
.af-sheet-totals p { display: flex; justify-content: space-between; gap: 32px; margin: 0 0 6px; font-size: 12px; color: #141a21; }
.af-sheet-ttc { margin-top: 8px; margin-bottom: 0; font-size: 14px; }
.af-sheet-note { margin: 14px 0 0; font-size: 11px; color: #3d4654; white-space: pre-wrap; }
.af-sheet-legal { margin-top: 48px; font-size: 10px; line-height: 1.45; color: #3d4654; }
.af-sheet-legal p { margin: 0 0 4px; }
.af-sheet-foot { margin: 16px 0 0; font-size: 10px; line-height: 1.4; color: #3d4654; text-align: center; }

@media (max-width: 980px) {
  .af-layout { grid-template-columns: 1fr; grid-template-areas: "main" "side"; }
  .af-side { position: static; }
  .af-sheet { max-height: none; }
  .af-cats { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .af-body { padding: 12px; }
  .af-composer-row { grid-template-columns: 1fr 1fr; }
  .af-composer-row label:nth-child(3),
  .af-composer-row label:nth-child(4) { grid-column: span 1; }
  .af-composer-row .af-btn,
  .af-el-edit-actions { grid-column: 1 / -1; }
  .af-el-edit-actions .af-btn { flex: 1; }
  .af-sheet-head { flex-direction: column; }
  .af-sheet-meta { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .af-just-added { animation: none; }
}
