/* ====================================================================
   QualiRépar — Bon de reprise / réparation / don / SAV
   Préfixe : qr-
   ==================================================================== */

.page_qualirepar { padding: 12px; }

#id_qualirepar { max-width: 1200px; margin: 0 auto; }

/* ---- Header ---- */
.qr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.qr-header h1 {
  font-size: 18pt;
  margin: 0;
  color: var(--main-bg-color);
}
.qr-header h1 .fa { margin-right: 8px; }

/* ---- Boutons ---- */
.qr-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 10pt;
  background: #f0f0f0;
  color: #333;
  transition: background .15s;
}
.qr-btn:hover { background: #e3e3e3; }
.qr-btn .fa { margin-right: 5px; }
.qr-btn-primary { background: var(--main-bg-color); color: #fff; }
.qr-btn-primary:hover { filter: brightness(0.92); }
.qr-btn-success { background: #2e7d32; color: #fff; }
.qr-btn-success:hover { filter: brightness(0.92); }
.qr-btn-ghost { background: transparent; border: 1px solid #ddd; }
.qr-btn-block { display: block; width: 100%; margin-top: 12px; padding: 12px; font-size: 11pt; }
.qr-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Layout 2 colonnes ---- */
.qr-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.qr-form-col { flex: 1 1 auto; min-width: 0; }
.qr-photo-col { flex: 0 0 320px; }

/* ---- Cartes ---- */
.qr-card {
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.qr-card-title {
  font-size: 11pt;
  font-weight: 600;
  color: #444;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
}
.qr-card-title .fa { margin-right: 6px; color: var(--main-bg-color); }
.qr-sticky { position: sticky; top: 12px; }

/* ---- Champs ---- */
.qr-field { margin-bottom: 10px; }
.qr-field label {
  display: block;
  font-size: 8.5pt;
  font-weight: 600;
  color: #666;
  margin-bottom: 3px;
}
.qr-field input[type="text"],
.qr-field input[type="tel"],
.qr-field input[type="number"],
.qr-field input[type="email"],
.qr-field textarea,
.qr-field select {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  font-size: 10pt;
}
.qr-field textarea { resize: vertical; }
.qr-input-sm { max-width: 120px; }
.qr-field-inline { display: flex; align-items: center; gap: 8px; }
.qr-field-inline label { margin-bottom: 0; }
.qr-mt { margin-top: 6px; }

.qr-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qr-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.qr-hint { font-size: 8pt; color: #999; margin: 4px 0 0; }

/* ---- Source client ---- */
.qr-source-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.qr-source-tab {
  flex: 1;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  font-size: 9.5pt;
}
.qr-source-tab.active {
  background: var(--main-bg-color);
  color: #fff;
  border-color: var(--main-bg-color);
}
.qr-source-tab .fa { margin-right: 5px; }
.qr-ticket-row { display: flex; gap: 8px; align-items: flex-end; }
.qr-ticket-row input { flex: 1; }

.qr-client-recap {
  margin-top: 10px;
  background: #eef7ee;
  border: 1px solid #cfe6cf;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 9.5pt;
}
.qr-client-recap .fa { color: #2e7d32; margin-right: 6px; }
.qr-tiers-link { color: var(--main-bg-color); text-decoration: none; }
.qr-tiers-link:hover { text-decoration: underline; }
.qr-tiers-link .fa { color: var(--main-bg-color); font-size: 8pt; margin: 0 0 0 4px; }

/* ---- Cases à cocher / radios ---- */
.qr-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10pt;
  padding: 6px 0;
  cursor: pointer;
}
.qr-subchoice {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0 8px 24px;
}
.qr-subchoice-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 9.5pt;
}
.qr-radio {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5pt;
  cursor: pointer;
}

/* ---- Photos ---- */
.qr-photo-block { margin-bottom: 16px; }
.qr-photo-label { font-size: 9pt; font-weight: 600; color: #555; margin-bottom: 6px; }
.qr-photo-preview {
  position: relative;
  margin: 0 auto 8px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  width: 40%;
}
.qr-photo-preview img { width: 100%; display: block; cursor: zoom-in; transition: filter .2s; }
.qr-img-dim { filter: brightness(0.45) grayscale(0.4); }

/* Overlay d'analyse IA sur l'image */
.qr-photo-analyzing {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 9.5pt;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.qr-photo-analyzing .fa { font-size: 20pt; }

/* Lightbox (affichage 1er plan) */
.qr-lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  cursor: zoom-out;
  padding: 20px;
}
.qr-lightbox img {
  max-width: 95%;
  max-height: 95%;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  cursor: default;
}
.qr-lightbox-close {
  position: absolute;
  top: 16px; right: 22px;
  color: #fff;
  font-size: 24pt;
  cursor: pointer;
}
.qr-photo-remove {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
}
.qr-photo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f0f0;
  border: 1px dashed #bbb;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 9.5pt;
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
}
.qr-photo-btn:hover { background: #e8e8e8; }
.qr-photo-btn input[type="file"] { display: none; }
.qr-ia-row { margin-top: 8px; }
.qr-ia-row .qr-btn { width: 100%; font-size: 9pt; }
.qr-ia-row .qr-btn .fa { color: var(--main-bg-color); }

.qr-phone-hint {
  font-size: 8.5pt;
  color: #888;
  background: #f7f7f7;
  border-radius: 6px;
  padding: 8px;
  margin: 10px 0;
}
.qr-phone-hint .fa { margin-right: 5px; }

/* ---- Historique ---- */
.qr-history {
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.qr-history-empty { color: #aaa; font-size: 9.5pt; padding: 8px; }
.qr-history-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.qr-history-table th, .qr-history-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
}
.qr-history-table th { color: #666; font-weight: 600; }

/* ---- Bouton lier téléphone ---- */
.qr-btn-pair { margin-bottom: 10px; }

/* ====================================================================
   Modal liaison téléphone
   ==================================================================== */
.qr-modal-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 400; padding: 16px;
}
.qr-modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); overflow: hidden;
  display: flex; flex-direction: column; max-height: 92vh;
}
.qr-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #eee;
}
.qr-modal-header h3 { margin: 0; font-size: 13pt; color: var(--main-bg-color); }
.qr-modal-header .fa { margin-right: 6px; }
.qr-modal-close { background: none; border: none; font-size: 14pt; cursor: pointer; color: #888; }
.qr-modal-body { padding: 16px; overflow-y: auto; }
.qr-modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid #eee;
}

.qr-pair-body { text-align: center; }
.qr-pair-intro { font-size: 9.5pt; color: #555; margin: 0 0 14px; line-height: 1.5; }
.qr-pair-qr {
  display: inline-block; padding: 10px; background: #fff;
  border: 1px solid #eee; border-radius: 10px; min-height: 200px; min-width: 200px;
}
.qr-pair-qr img, .qr-pair-qr canvas { display: block; }
.qr-pair-url {
  margin: 12px 0 6px; font-size: 8pt; word-break: break-all;
}
.qr-pair-url a { color: var(--main-bg-color); }
.qr-pair-ttl { font-size: 9pt; color: #777; margin-bottom: 14px; }
.qr-pair-ttl .fa { margin-right: 4px; }
.qr-pair-expired { color: #c62828; font-weight: 600; }

.qr-pair-status { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.qr-pair-slot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: #f6f7f9; border: 1px solid #eceff1; font-size: 10pt; color: #607d8b;
}
.qr-pair-slot .fa { font-size: 13pt; color: #b0bec5; }
.qr-pair-slot.done { background: #e8f5e9; border-color: #c8e6c9; color: #2e7d32; }
.qr-pair-slot.done .fa { color: #2e7d32; }

/* ====================================================================
   Responsive
   ==================================================================== */
@media (max-width: 992px) {
  .qr-layout { flex-direction: column; }
  .qr-photo-col { flex: 1 1 auto; width: 100%; }
  .qr-sticky { position: static; }
}
@media (max-width: 768px) {
  .qr-header h1 { font-size: 14pt; }
  .qr-grid-2, .qr-grid-3 { grid-template-columns: 1fr; }
  .qr-source-tab { font-size: 8.5pt; padding: 10px 6px; }
  .qr-photo-btn { padding: 14px; }   /* cible tactile */
  .qr-check, .qr-radio { padding: 8px 0; }
}
