/* ============================================================
   🎨 Calque d'annotations & panneau outils
   Palette bois / cuir pour MHG
============================================================ */
#mhg-me-pdf-container {
  position: relative;
  display: inline-block;
}

#mhg-pdf-render {
  position: relative;
  z-index: 1;
  display: block;
}

#mhg-annotation-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: auto;
  cursor: crosshair;
}

/* ------------------------------------------------------------
   Panneau latéral
------------------------------------------------------------ */
.mhg-me-annotation-panel {
  position: fixed;
  right: 18px;
  top: 80px;
  width: 260px;
  background: rgba(34, 22, 12, 0.92);
  color: #f1e0c5;
  border-radius: 16px;
  box-shadow: 0 10px 35px rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 10px 14px 14px;
  z-index: 100002;
  backdrop-filter: blur(4px);
  cursor: default;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.mhg-me-annotation-panel.expanded:not(:hover) {
  opacity: 0.8;
}

.mhg-me-annotation-panel.dragging {
  opacity: 0.95;
  cursor: grabbing;
}

.mhg-me-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.mhg-me-annotation-panel .mhg-me-drag-handle {
  position: static;
  top: auto;
  right: auto;
  margin-right: 10px;
}

.mhg-me-drag-handle {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #f6d69f;
  border-radius: 10px;
  padding: 6px 8px;
  cursor: grab;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
}

.mhg-me-toggle-btn {
  background: linear-gradient(145deg, #3c2a1a, #2a1b10);
  color: #f8f1df;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
  transition: transform 0.15s ease, background 0.2s ease;
}

.mhg-me-toggle-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #46301d, #312014);
}

.mhg-me-panel-content { margin-top: 4px; }

/* ------------------------------------------------------------
   🔀 Switch Annotations ON/OFF
   Inspiré du métronome flottant
------------------------------------------------------------ */
.mhg-annotations-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 12px;
}

.mhg-annotations-label {
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #f5d49a;
}

.mhg-annotations-switch-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mhg-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  transition: opacity 0.2s ease;
}

.mhg-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mhg-slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 24px;
  border: 1px solid #d0b68a;
  transition: 0.3s;
}

.mhg-slider-round::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 2.5px;
  background-color: #ffe8cc;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.mhg-switch input:checked + .mhg-slider-round,
.mhg-switch.on .mhg-slider-round {
  background: #ba8225;
}

.mhg-switch input:checked + .mhg-slider-round::before,
.mhg-switch.on .mhg-slider-round::before {
  transform: translateX(22px);
}

.mhg-switch.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.mhg-switch-status {
  font-size: 12px;
  font-weight: 700;
  color: #d8c39a;
  letter-spacing: 0.4px;
}

.mhg-switch-status.off { color: #c4b9a5; }
.mhg-switch-status.on { color: #f6d69f; }

.mhg-annotations-toolbar.disabled {
  /* Les annotations doivent rester visibles même lorsque le bloc est désactivé */
  opacity: 1;
  pointer-events: none;
}

.mhg-me-annotation-panel.collapsed {
  width: 220px;
  padding: 10px 12px;
  background: rgba(34, 22, 12, 0.9);
  cursor: pointer;
}

.mhg-me-annotation-panel.collapsed .mhg-me-panel-content {
  display: none;
}

.mhg-me-annotation-panel.collapsed .mhg-me-toggle-btn.mhg-me-reduce {
  display: none;
}

.mhg-me-panel-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #f5d49a;
  margin-bottom: 10px;
  flex: 1;
}

.mhg-me-tool-group,
.mhg-me-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mhg-me-tool-btn {
  background: linear-gradient(145deg, #3c2a1a, #2a1b10);
  color: #f8f1df;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 0;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

.mhg-me-tool-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #46301d, #312014);
}

.mhg-me-tool-btn.active {
  outline: 2px solid #f6d69f;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 10px 18px rgba(0,0,0,0.45);
}

.mhg-me-subgroup {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.mhg-me-subtitle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #f6d69f;
  margin-bottom: 8px;
}

.mhg-me-color-row,
.mhg-me-size-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mhg-me-color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 2px 6px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.mhg-me-color-dot.active,
.mhg-me-size-chip.active {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 0 2px #f6d69f, 0 6px 12px rgba(0,0,0,0.35);
}

.mhg-me-color-dot:hover,
.mhg-me-size-chip:hover {
  transform: translateY(-1px);
}

.mhg-me-size-chip {
  background: rgba(255,255,255,0.08);
  color: #f1e0c5;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.mhg-me-actions .mhg-me-tool-btn {
  font-size: 16px;
  padding: 10px;
}

.mhg-me-reduce-row {
  display: flex;
  justify-content: flex-end;
}

.mhg-me-tool-btn.active-off {
  background: #4d201c;
  color: #fddede;
}

.mhg-me-annotations-disabled #mhg-annotation-layer {
  pointer-events: none;
  opacity: 1;
  visibility: visible;
}

.mhg-me-text-input {
  position: fixed;
  z-index: 100003;
  background: #2d1c10;
  border: 1px solid #f6d69f;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.mhg-me-text-field {
  width: 200px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #f6d69f;
  font-size: 14px;
  background: #f8f1df;
  color: #3a2a1a;
}

.mhg-me-text-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.mhg-me-text-actions button {
  background: #4a2e14;
  color: #f1e0c5;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}

.mhg-me-text-actions button:hover {
  transform: translateY(-1px);
  background: #56361a;
}

@media (max-width: 1024px) {
  .mhg-me-annotation-panel {
    width: 220px;
    right: 10px;
    top: 70px;
  }
}

@media (max-width: 780px) {
  .mhg-me-annotation-panel {
    width: calc(100% - 30px);
    left: 15px;
    right: 15px;
    top: auto;
    bottom: 20px;
  }
}
