/* ===== RAPPORT PANEL - COLPOSCOPIE ===== */

/* ===== LAYOUT PRINCIPAL ===== */
.rapport-panel {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
  background: var(--bg-canvas);
  position: relative;
}

/* ===== SECTIONS ===== */
.rapport-section {
  margin-bottom: 16px;
}

/* Allow multi-select dropdown menus to overflow sections */
.rapport-section:has(.multi-select-dropdown) {
  overflow: visible;
}

.rapport-panel .section-title {
  margin: 24px 0 12px;
  padding: 8px 12px;
  background: var(--accent-primary);
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rapport-panel .section-title:first-of-type {
  margin-top: 0;
}

.subsection {
}

.subsection-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

/* ===== FORM GRID ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
  min-width: 0;
}

.form-grid:last-child {
  margin-bottom: 0;
}

.form-grid-3col {
  grid-template-columns: repeat(3, 1fr);
}

.form-grid-4col {
  grid-template-columns: repeat(4, 1fr);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Allow multi-select dropdown menus to overflow */
.form-group:has(.multi-select-dropdown) {
  overflow: visible;
}

.form-group.w-full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== INPUTS, SELECTS, TEXTAREAS ===== */
.rapport-panel input[type="text"],
.rapport-panel input[type="number"],
.rapport-panel input[type="date"],
.rapport-panel select,
.rapport-panel textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.rapport-panel input:focus,
.rapport-panel select:focus,
.rapport-panel textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}

.rapport-panel select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235C5C5C' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.rapport-panel textarea {
  resize: vertical;
  min-height: 60px;
}

/* ===== CHECKBOX ===== */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* Codes CCAM non cumulables (CR opératoire) : aide posée sous le libellé de la
   case désactivée, alignée sur son texte (case 18px + gap 8px). */
.checkbox-label:has(> .rap-op-ccam-aide) {
  flex-wrap: wrap;
  row-gap: 2px;
}

.checkbox-label:has(> .rap-op-ccam-aide) > span {
  flex: 1 1 0;
  min-width: 0;
}

.rap-op-ccam-aide {
  flex: 0 0 100%;
  padding-left: 26px;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
}

.checkbox-label:has(input[id^="rap-op-ccam-"]:disabled) {
  color: var(--text-muted);
  cursor: default;
}

/* Checkbox-only cells inside a form-grid have no top label, so align the
   checkbox vertically with the inputs of sibling cells and push it to the
   right edge of its grid cell. */
.form-grid .form-group:has(> .checkbox-label:only-child) {
  justify-content: flex-end;
  align-items: flex-end;
  padding-bottom: 10px;
}

/* ===== CHECKBOX GRID (for discussion section) ===== */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
}

/* ===== DISCUSSION INFO BUTTON + TOOLTIP ===== */
/* Rangée « case + bouton d'aperçu » : le bouton est frère du label, pas dedans. */
.checkbox-with-info {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.checkbox-with-info > .checkbox-label {
  min-width: 0;
}

.disc-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font-size: 0.95rem;
  line-height: 1;
  cursor: help;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}

.disc-info-btn:hover,
.disc-info-btn:focus-visible {
  color: var(--accent-primary, #2563eb);
  background: rgba(37, 99, 235, 0.08);
}

.disc-info-btn:focus-visible {
  outline: 2px solid var(--accent-primary, #2563eb);
  outline-offset: 1px;
}

.disc-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 380px;
  padding: 10px 12px;
  background: #1f2937;
  color: #f9fafb;
  font-size: 0.8rem;
  line-height: 1.45;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  text-align: left;
  white-space: normal;
}

.disc-tooltip[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== CONDITIONAL BLOCKS ===== */
.conditional-block {
  margin-top: 12px;
  padding: 12px;
  background: rgba(217, 119, 87, 0.05);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--accent-primary);
  overflow: hidden;
  min-width: 0;
}

/* ===== DYNAMIC LISTS ===== */
.dynamic-list-section {
  margin-top: 16px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.list-header span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-add-small {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-primary);
  background: transparent;
  border: 1px solid var(--accent-primary);
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-small:hover {
  background: var(--accent-primary);
  color: white;
}

.dynamic-list,
.dynamic-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  padding: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border-radius: var(--border-radius-md);
  border: 1px dashed var(--border-medium);
}

/* ===== HISTORY ITEMS (Examens antérieurs) ===== */
.history-item {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  min-width: 0;
}

.history-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(217, 119, 87, 0.08) 0%, rgba(217, 119, 87, 0.03) 100%);
  border-bottom: 1px solid var(--border-light);
}

.history-item-header .history-date,
.history-item-header .history-type {
  flex: 1 1 0;
  min-width: 0;
}

.btn-delete-history {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-delete-history:hover {
  background: rgba(244, 67, 54, 0.12);
  color: #D32F2F;
}

.history-item-details {
  padding: 12px;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  min-width: 0;
}

.history-item-details.frottis-details {
  grid-template-columns: repeat(2, 1fr);
}

.history-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-item-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== DYNAMIC CARDS (LESIONS / BIOPSIES) ===== */
.dynamic-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(217, 119, 87, 0.08) 0%, rgba(217, 119, 87, 0.03) 100%);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.card-header:hover {
  background: linear-gradient(135deg, rgba(217, 119, 87, 0.12) 0%, rgba(217, 119, 87, 0.06) 100%);
}

.card-content {
  padding: 12px;
  overflow: hidden;
  min-width: 0;
}

.dynamic-card.collapsed .card-content {
  display: none;
}

/* Header badges */

/* Biopsy specific */
.biopsy-num {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-primary);
  min-width: 24px;
}

.result-badge {
  margin-left: auto;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
  color: white;
}

.result-badge.pending {
  background: #9E9E9E;
}

.result-badge.normal {
  background: #4CAF50;
}

.result-badge.cin1 {
  background: #FFC107;
  color: #333;
}

.result-badge.cin2 {
  background: #FF9800;
}

.result-badge.cin3,
.result-badge.ais {
  background: #F44336;
}

.result-badge.carcinome,
.result-badge.adenocarcinome {
  background: #D32F2F;
}

/* Card controls */
.card-controls {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.btn-card {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-card:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.btn-card.btn-delete:hover {
  background: rgba(196, 92, 92, 0.1);
  color: var(--accent-danger);
}

/* ===== PHOTO GALLERY ===== */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.photo-thumbnail {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 2px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.photo-thumbnail:hover {
  border-color: var(--accent-primary);
  transform: scale(1.02);
}

.photo-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumbnail .photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.photo-thumbnail:hover .photo-delete {
  opacity: 1;
}

/* Aperçu d'une photo (clic sur une vignette) */
.rap-photo-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.8);
}

.rap-photo-modal img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--border-radius-md);
  background: var(--bg-canvas);
}

.rap-photo-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

/* Contour posé sur le voile sombre (rgba(0, 0, 0, 0.8)) : l'accent n'y donne que
   2,32:1 ; --bg-canvas (blanc) 12,6:1 (A11Y-08) */
.rap-photo-modal-close:focus-visible {
  outline: 3px solid var(--bg-canvas);
  outline-offset: 2px;
}

.btn-add-photo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: 1px dashed var(--border-medium);
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-photo:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(217, 119, 87, 0.05);
}

/* ===== FAB COPIE COMBINÉE (schéma + rapport) ===== */
.fab-combined-copy {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  z-index: 1000;
}

.fab-combined-copy:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.fab-combined-copy:active {
  transform: scale(0.98);
}

.fab-combined-copy[disabled] {
  opacity: 0.5;
  cursor: progress;
  pointer-events: none;
}

@media (max-width: 640px) {
  .fab-combined-copy {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

/* ===== BUTTONS ===== */
/* Utilisation des boutons partagés depuis shared/css/components.css */
/* .btn-primary, .btn-secondary sont disponibles via l'import dans colposcopie.css */

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .form-grid-4col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .rapport-panel {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-3col,
  .form-grid-4col {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 480px) {
  .rapport-panel .section-title {
    font-size: 0.75rem;
    padding: 6px 10px;
    margin: 16px 0 8px;
  }

  .photo-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== HIDDEN UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== LOCAL TAB BAR (J0 / Post-résultats) ===== */
.rap-tabs-bar {
  display: flex;
  gap: 4px;
  margin: 0 0 20px;
  border-bottom: 2px solid var(--border-color, #d8d8e0);
  padding: 0 4px;
}

.rap-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
}

.rap-tab:hover { color: var(--text-primary); }

.rap-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.rap-tab-panel[hidden] { display: none; }
.rap-tab-panel.active  { display: block; }

.rap-tab-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.btn-copy-rapport {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius-md, 6px);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-copy-rapport:hover  { filter: brightness(1.05); }
.btn-copy-rapport:active { transform: translateY(1px); }
.btn-copy-rapport .btn-icon { font-size: 1rem; }

/* ===== MINI-RÉCAP (haut onglet 2) ===== */
.rap-mini-recap-wrapper {
  background: var(--bg-surface, #faf8ff);
  border: 1px dashed var(--border-color, #d8d8e0);
  border-radius: var(--border-radius-md, 6px);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.rap-mini-recap-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.rap-mini-recap-empty {
  margin: 0;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.rap-mini-recap-grid {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-size: 0.85rem;
}

.rap-mini-recap-grid dt { font-weight: 600; color: var(--text-secondary); }
.rap-mini-recap-grid dd { margin: 0; color: var(--text-primary); }

/* ===== ZONE D'IMPORT (haut onglet 2) ===== */
.rap-import-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 16px;
  border: 1.5px dashed var(--accent-primary);
  border-radius: var(--border-radius-md, 8px);
  background: var(--bg-accent-soft, #FBF2EC);
  transition: background var(--transition-fast, 0.15s ease),
              border-style var(--transition-fast, 0.15s ease);
}

.rap-import-zone:focus-within,
.rap-import-zone.is-dragover {
  background: #F5E6DC;
  border-style: solid;
}

.rap-import-prefix {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.rap-import-icon {
  width: 22px;
  height: 22px;
  color: var(--accent-primary);
}

.rap-import-prefix strong {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.rap-import-input {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  border: 1px solid var(--border-medium, #D4CCC0);
  border-radius: var(--border-radius-md, 6px);
  background: white;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.rap-import-input::placeholder {
  color: var(--text-muted, #8C8C8C);
  font-style: italic;
}

.rap-import-input:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: -1px;
  border-color: transparent;
}

/* ===== IMPORT MODAL ===== */
.imp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.imp-modal {
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 780px;
  width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.imp-header strong { flex: 1; font-size: 1.05rem; }

.imp-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.imp-badge-detected { background: #e3f5ec; color: #2f9e6c; }
.imp-badge-low      { background: #fbf2db; color: #c98b00; }

.imp-body { padding: 18px 20px; overflow-y: auto; flex: 1; }

.imp-section { margin-bottom: 18px; }

.imp-section h4 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.imp-grid {
  display: grid;
  grid-template-columns: 160px 1fr 24px;
  gap: 8px 12px;
  font-size: 0.85rem;
  align-items: center;
}

.imp-grid label { color: var(--text-primary); }

.imp-grid input, .imp-grid select {
  padding: 5px 8px;
  border: 1px solid var(--border-color, #d8d8e0);
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
}

/* Sélecteur enveloppé avec sa phrase source : même largeur qu'un sélecteur posé dans la grille. */
.imp-grid > div > select { width: 100%; }

.imp-conf { font-size: 1.05rem; text-align: center; display: inline-block; width: 100%; }
.imp-conf-high { color: #2f9e6c; }
.imp-conf-low  { color: #c98b00; }
.imp-conf-none { color: var(--text-secondary); }

.imp-multi-check {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 4px 0;
}
.imp-multi-check-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
}
.imp-multi-check-item input { margin: 0; }

.imp-biopsies { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

.imp-biopsies th, .imp-biopsies td {
  padding: 6px 8px;
  border: 1px solid var(--border-color, #d8d8e0);
  text-align: left;
}

.imp-biopsies th       { background: #f5f3fa; font-weight: 600; }
.imp-biopsies tr.low-conf { background: #fffaf0; }

.imp-biopsies input, .imp-biopsies select {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  padding: 2px 4px;
}

.imp-index-readonly {
  display: inline-block;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: help;
}

.imp-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  margin: 6px 0 0;
}

.imp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #d8d8e0);
  background: #fafaff;
}

.imp-btn-cancel {
  padding: 7px 16px;
  background: white;
  border: 1px solid var(--border-color, #d8d8e0);
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.imp-btn-confirm {
  padding: 7px 16px;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ============================================================
   Section technique du CR opératoire — redesign 2026-05-21
   Pills façon app-card-popover (cf. shared/css/app-menu.css).
   Cf. docs/superpowers/specs/2026-05-21-rap-op-section-technique-redesign-design.md
   ============================================================ */

.rapport-panel {
  --rap-op-pill-bg: #FAF0E8;
  --rap-op-pill-bg-hover: #F4E0D0;
  --rap-op-pill-bg-modified: #E8F0E6;
}

/* Override overflow:hidden du panel pendant qu'un popover est ouvert.
   Mirrors le pattern existant `.rapport-section:has(.multi-select-dropdown)`. */
.rapport-section:has(.rap-op-pill.is-pinned),
.rapport-section:has(.rap-op-pill:hover),
.rapport-section:has(.rap-op-pill:focus-within) {
  overflow: visible;
}

/* Presets bar */
.rap-op-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border-light);
}
.rap-op-presets-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.rap-op-preset {
  background: var(--bg-main);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  border-radius: var(--border-radius-pill);
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
}
.rap-op-preset:hover {
  background: var(--rap-op-pill-bg);
  border-color: var(--accent-primary);
}
.rap-op-preset.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Avertissement AIS / micro-invasif hors plan dédié (onglet Post-conisation).
   Pas de `display` ici : l'attribut `hidden` doit continuer à masquer l'élément. */
.rap-cpo-alert {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid var(--accent-danger);
  border-left-width: 4px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Steps list (21 lignes) */
.rap-op-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.7;
}
.rap-op-step {
  position: relative;
  padding: 6px 0 6px 22px;
  border-bottom: 1px dashed var(--border-light);
  color: var(--text-primary);
}
.rap-op-step:last-child { border-bottom: none; }
.rap-op-step::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-weight: 500;
}
.rap-op-step--fixed {
  color: var(--text-secondary);
}
.rap-op-step--fixed::before {
  content: '✓';
  color: var(--accent-success);
  font-size: 0.85em;
  top: 7px;
}
.rap-op-step-label {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-right: 6px;
}
/* Case qui active une étape (hémostase locale) : ancien style en ligne (SEC-10) */
.rap-op-step .checkbox-label.rap-op-step-toggle {
  margin-right: 0.4rem;
  gap: 0.4rem;
}

/* Pill — trigger app-card-popover */
.rap-op-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--rap-op-pill-bg);
  color: var(--accent-primary);
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  padding: 1px 8px;
  margin: 0 1px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast),
              border-color var(--transition-fast);
  position: relative;
  white-space: nowrap;
  outline: none;
  user-select: none;
}
/* Onglet Post-conisation : certains libellés sont plus longs que le panneau
   (jusqu'à 87 caractères). La pastille passe à la ligne au lieu de sortir du
   panneau, coupée par son overflow-x. Les pastilles du CRO, plus courtes, restent
   sur une ligne au-dessus de 720 px (cf. le bloc @media en fin de section). */
.rap-op-pill[data-cpo-pill="true"] {
  white-space: normal;
  text-align: left;
}
/* Pastille sans valeur (« — à préciser ») : atténuée, pour ne pas se lire comme
   une valeur saisie. Placée avant :hover / .is-pinned, qui gardent la main. */
.rap-op-pill.is-unset {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border-medium);
  font-style: italic;
}
.rap-op-pill:hover,
.rap-op-pill:focus-visible,
.rap-op-pill.is-pinned {
  background: var(--rap-op-pill-bg-hover);
  border-color: var(--accent-primary);
}
.rap-op-pill.is-modified {
  background: var(--rap-op-pill-bg-modified);
  color: var(--accent-success);
}
.rap-op-pill-caret {
  font-size: 0.7em;
  opacity: 0.6;
  margin-left: 2px;
}

/* Rich popover (mirrors .app-card-popover de shared/css/app-menu.css) */
.rap-op-pill-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast),
              transform var(--transition-fast),
              visibility var(--transition-fast);
  z-index: 50;
  white-space: normal;
  font-weight: 400;
}
.rap-op-pill:hover > .rap-op-pill-popover,
.rap-op-pill:focus-within > .rap-op-pill-popover,
.rap-op-pill.is-pinned > .rap-op-pill-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
/* Override post-sélection : tient ~250ms pour éviter que le :hover (souris encore
   sur la pill) ou le :focus-within (item venant d'être cliqué) ne ré-ouvrent
   immédiatement le popover. Spécificité identique aux règles ci-dessus (0,3,0),
   donc l'ordre source l'emporte. */
.rap-op-pill.is-just-closed > .rap-op-pill-popover {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
}
.rap-op-pill-popover--align-right {
  left: auto;
  right: 0;
}

.rap-op-pill-popover-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.rap-op-pill-popover-item:hover,
.rap-op-pill-popover-item:focus-visible {
  background: var(--bg-sidebar);
  outline: none;
}
.rap-op-pill-popover-item.is-selected {
  background: var(--rap-op-pill-bg);
}
.rap-op-pill-popover-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.rap-op-pill-popover-item.is-selected .rap-op-pill-popover-item-title {
  color: var(--accent-primary);
}
.rap-op-pill-popover-item-title::before {
  content: '';
  width: 14px;
  display: inline-block;
}
.rap-op-pill-popover-item.is-selected .rap-op-pill-popover-item-title::before {
  content: '✓';
  color: var(--accent-primary);
  font-weight: 700;
}
.rap-op-pill-popover-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 20px;
  line-height: 1.4;
}

/* "Autre…" mini-input pour puissances coupe/coag */
.rap-op-pill-popover-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
}
.rap-op-pill-popover-custom-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.rap-op-pill-popover-custom-input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-sm);
  font-size: 13px;
}

@media (max-width: 720px) {
  .rap-op-pill-popover {
    position: static;
    min-width: 0;
    max-width: none;
    box-shadow: none;
    transform: none;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    overflow: hidden;
    transition: max-height var(--transition-normal),
                padding var(--transition-fast),
                border-color var(--transition-fast);
    margin-top: 4px;
  }
  .rap-op-pill.is-pinned > .rap-op-pill-popover {
    max-height: 420px;
    padding: 6px;
    border: 1px solid var(--border-light);
  }
  /* Le popover, statique sur téléphone, est un enfant de la pastille. Fermé, il
     ne doit pas lui donner sa largeur (la pastille sortait de sa section, ou son
     libellé se retrouvait à un mot par ligne) ; ouvert, il passe sous le libellé.
     Les libellés passent à la ligne au lieu de sortir du panneau. */
  .rap-op-pill {
    white-space: normal;
    text-align: left;
  }
  .rap-op-pill.is-pinned {
    flex-wrap: wrap;
  }
  .rap-op-pill > .rap-op-pill-popover {
    flex: 0 0 100%;
  }
  .rap-op-pill:not(.is-pinned) > .rap-op-pill-popover {
    display: none;
  }
}

/* === Sous-onglet Post-conisation (CPO) — styles inline narrative === */

.rap-op-narrative {
  font-size: 0.98rem;
  line-height: 1.85;
  color: var(--text-primary);
}
.rap-op-narrative p {
  margin: 0 0 10px;
}
.rap-op-narrative p:last-child {
  margin: 0;
}

.rap-op-text-input,
.rap-op-date-input {
  display: inline-block;
  width: auto;
  min-width: 120px;
  padding: 2px 8px;
  font-size: 0.95em;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  vertical-align: baseline;
}
.rap-op-date-input {
  min-width: 140px;
}

.rap-op-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  resize: vertical;
}

/* Encadré « Proposition de l'algorithme » (catPanel.js), au-dessus des champs
   de la CAT. Pas de `display` sur les blocs : `hidden` doit rester effectif. */
.rap-cat-proposition {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--border-radius-sm);
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.rap-cat-proposition p {
  margin: 0 0 8px;
}

.rap-cat-titre {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.rap-cat-phrase {
  font-weight: 600;
}

.rap-cat-source,
.rap-cat-version {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.rap-cat-reference {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.rap-cat-alerte {
  padding: 6px 10px;
  border-left: 3px solid var(--accent-danger);
}

/* Repli « Justification, sources et options » : fermé par défaut, résumé
   atteint au clavier (Tab, puis Entrée ou Espace). */
.rap-cat-repli {
  margin: 0 0 8px;
}

.rap-cat-repli-resume {
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.rap-cat-repli-resume:hover {
  color: var(--text-primary);
}

.rap-cat-repli-resume:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.rap-cat-repli-corps {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--border-light);
}

.rap-cat-note {
  color: var(--text-secondary);
}

.rap-cat-gele {
  font-style: italic;
  color: var(--text-secondary);
}

.rap-cat-manquants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.rap-cat-manquant {
  padding: 2px 10px;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-pill);
  background: var(--bg-input);
  color: var(--accent-primary);
  font: inherit;
  cursor: pointer;
}

.rap-cat-option {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px dashed var(--border-medium);
  border-radius: var(--border-radius-sm);
}

.rap-cat-option-titre {
  font-weight: 600;
}

.rap-cat-criteres {
  margin: 0 0 8px;
  padding-left: 18px;
}

/* Titre de l'encadré et bouton « Arbre N » (catPanel.js) : schéma de l'arbre
   2025 retenu, en grand au survol, au focus et au toucher (catArbre.js). */
.rap-cat-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}

.rap-cat-entete .rap-cat-titre {
  margin: 0;
}

.rap-cat-arbre-bouton {
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--accent-primary);
  border-radius: var(--border-radius-pill);
  background: var(--bg-canvas);
  color: var(--accent-primary);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.rap-cat-arbre-bouton:hover,
.rap-cat-arbre-bouton[aria-expanded="true"] {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.rap-cat-arbre-bouton:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Panneau en popover manuel : position posée par catArbre.js (CSSOM). Pas de
   `display` : `hidden` et `:popover-open` décident. */
.rap-cat-arbre-panneau {
  position: fixed;
  inset: auto;
  z-index: 1000;
  box-sizing: border-box;
  width: min(90vw, 960px);
  max-height: 85vh;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-md);
  background: var(--bg-canvas);
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  font-size: 0.9rem;
}

.rap-cat-arbre-panneau p {
  margin: 0 0 8px;
}

.rap-cat-arbre-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rap-cat-arbre-titre {
  font-weight: 600;
}

.rap-cat-arbre-fermer {
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-pill);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.rap-cat-arbre-fermer:focus-visible,
.rap-cat-arbre-lien:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.rap-cat-arbre-figure {
  margin: 0 0 8px;
  overflow-x: auto;
}

.rap-cat-arbre-svg {
  display: block;
  width: 100%;
  height: auto;
  /* Ordinateur : l'arbre entier tient dans le panneau, chemin, citation et lien sous lui. */
  max-height: max(24rem, calc(85vh - 10rem));
  font-family: inherit;
}

.rap-cat-arbre-note,
.rap-cat-arbre-citation {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.rap-cat-arbre-lien {
  color: var(--accent-primary);
  font-weight: 600;
}

/* Formes du schéma, en unités du repère de l'arbre (js/cat/arbreSchema.js :
   interligne 17 pour le bandeau, 14,5 ailleurs). */
.rap-cat-arbre-svg text {
  font-size: 12px;
  fill: var(--text-primary);
}

.rap-cat-arbre-svg .exposant {
  font-size: 8px;
}

.rap-cat-arbre-svg .souligne {
  text-decoration: underline;
}

.rap-cat-arbre-trait {
  fill: none;
  stroke: var(--accent-secondary);
  stroke-width: 1.4;
}

.rap-cat-arbre-pointe {
  fill: var(--accent-secondary);
}

.rap-cat-arbre-svg .pointille > rect,
.rap-cat-arbre-svg .pointille > polygon,
.rap-cat-arbre-trait.pointille {
  stroke-dasharray: 4 3;
}

.rap-cat-arbre-temps-ligne {
  stroke: var(--border-medium);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.forme-bandeau rect {
  fill: var(--accent-primary);
}

.rap-cat-arbre-svg .forme-bandeau text {
  font-size: 14px;
  font-weight: 600;
  fill: var(--text-on-accent);
}

.forme-rectangle rect {
  fill: var(--bg-sidebar);
  stroke: var(--accent-primary);
  stroke-width: 1.6;
}

.forme-losange polygon {
  fill: var(--bg-canvas);
  stroke: var(--accent-secondary);
  stroke-width: 1.3;
}

.forme-cadre rect {
  fill: var(--bg-main);
  stroke: var(--border-medium);
  stroke-width: 1.3;
}

.rap-cat-arbre-svg .forme-cadre text,
.rap-cat-arbre-svg .forme-temps text,
.rap-cat-arbre-svg .forme-etiquette text {
  fill: var(--text-secondary);
}

.forme-hexagone polygon {
  fill: var(--bg-canvas);
  stroke: var(--accent-primary);
  stroke-width: 2;
}

.rap-cat-arbre-svg .forme-hexagone text,
.rap-cat-arbre-svg .forme-temps text,
.rap-cat-arbre-svg .forme-etiquette text {
  font-weight: 600;
}

.forme-temps rect,
.forme-etiquette rect {
  fill: var(--bg-sidebar-hover);
  stroke: var(--border-medium);
  stroke-width: 1;
}

.forme-renvoi rect {
  fill: var(--bg-main);
  stroke: var(--accent-secondary);
  stroke-width: 1;
}

.rap-cat-arbre-svg .forme-renvoi text {
  font-style: italic;
}

/* Téléphone : pleine largeur ; le schéma garde une largeur lisible et défile. */
@media (max-width: 480px) {
  .rap-cat-arbre-panneau {
    width: 100%;
    padding: 10px 12px;
    border-radius: 0;
  }

  .rap-cat-arbre-svg {
    min-width: 560px;
    max-height: none;
  }
}
