/* ===== PHOTO MODULE STYLES ===== */

/* --- Photo Controls (inside parent section-card) --- */
.photo-controls {
  position: static;
}

.photo-controls .btn-add-corner {
  position: absolute;
  top: -12px;
  right: -6px;
}

/* --- Photo Gallery --- */
.photo-gallery-section {
  margin-bottom: 12px;
}

.photo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
}

.photo-thumbnail {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.photo-thumbnail:hover {
  border-color: var(--color-accent, #D97757);
}

.photo-thumbnail.active {
  border-color: var(--color-accent, #D97757);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.3);
}

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

.photo-thumb-number {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
}

.photo-thumb-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

.photo-thumb-delete:hover {
  background: var(--color-danger, #d9534f);
}

.photo-controls-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Photo Toolbar in View Container --- */
.photo-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.photo-toolbar-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #666);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.photo-toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary, #333);
}

.photo-toolbar-btn.active,
.photo-toolbar-toggle.active {
  background-color: var(--color-accent, var(--accent-primary));
  color: white;
}

.photo-toolbar-toggle.active:hover {
  background-color: var(--color-accent-hover, var(--accent-primary-hover));
}

/* Recadrage sans objet (cadrage d'origine, pas de photo active) */
.photo-toolbar-btn:disabled,
.photo-toolbar-btn:disabled:hover {
  background: transparent;
  color: var(--text-secondary, #666);
  opacity: 0.35;
  cursor: default;
}

.photo-toolbar-remove:hover {
  background-color: var(--color-danger, #d9534f);
  color: white;
}

/* Thumbnail variant */
.view-container.thumbnail .photo-toolbar {
  top: 4px;
  right: 4px;
  padding: 2px;
  gap: 2px;
}

.view-container.thumbnail .photo-toolbar-btn {
  width: 22px;
  height: 22px;
}

.view-container.thumbnail .photo-toolbar-btn svg {
  width: 12px;
  height: 12px;
}

/* --- Inline Control (label + slider + value on same line) --- */
.photo-control-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.photo-control-inline .photo-control-label {
  flex: 0 0 auto;
  min-width: 70px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #666);
  margin-bottom: 0;
}

.photo-control-inline input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.photo-control-inline .control-value {
  flex: 0 0 auto;
  min-width: 45px;
  text-align: center;
}

.photo-zoom-row,
.photo-posx-row,
.photo-posy-row,
.photo-rotation-row {
  margin-bottom: 10px;
}

/* --- Alignment Section --- */
.photo-align-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e0e0e0);
}

.photo-btn-align {
  width: 100%;
}

.photo-align-status {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-info, #e3f2fd);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-info, #1976d2);
  text-align: center;
}

.photo-align-status.hidden {
  display: none;
}

/* Alignment mode cursor */
.view-container.alignment-mode {
  cursor: crosshair;
}

.view-container.alignment-mode .photo-image {
  pointer-events: auto;
}

/* Alignment markers */
.alignment-marker {
  pointer-events: none;
}

.alignment-marker-os {
  fill: var(--color-accent, #D97757);
  stroke: white;
  stroke-width: 2;
}

.alignment-marker-external {
  fill: var(--color-success, #4CAF50);
  stroke: white;
  stroke-width: 2;
}


/* --- View Toggle Button --- */
.btn-toggle-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--text-secondary, #666);
}

.btn-toggle-photo:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

.btn-toggle-photo.active {
  background: var(--color-accent, var(--accent-primary));
  color: white;
}

.btn-toggle-photo.active:hover {
  background: var(--color-accent-hover, var(--accent-primary-hover));
}

/* --- Photo Indicator --- */
.photo-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 10;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent, var(--accent-primary));
}

/* --- Photo Image in SVG --- */
.photo-image {
  pointer-events: none;
}

.photo-group {
  pointer-events: none;
}

/* --- View Container Photo Mode --- */
.view-container.photo-mode {
  position: relative;
}

.view-container.photo-mode .view-svg #layer-background,
.view-container.photo-mode .view-svg [id^="layer-background"] {
  display: none;
}

/* --- Drag & Drop --- */
.photo-drag-over {
  outline: 3px dashed var(--color-accent, #D97757);
  outline-offset: -3px;
  background-color: rgba(217, 119, 87, 0.05);
}

/* --- Thumbnail Photo Indicator --- */
.view-container.thumbnail .photo-indicator {
  width: 18px;
  height: 18px;
  bottom: 4px;
  right: 4px;
}

.view-container.thumbnail .photo-indicator svg {
  width: 10px;
  height: 10px;
}

.view-container.thumbnail .btn-toggle-photo {
  width: 24px;
  height: 24px;
  top: 4px;
  right: 4px;
}

.view-container.thumbnail .btn-toggle-photo svg {
  width: 14px;
  height: 14px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .btn-toggle-photo {
    width: 36px;
    height: 36px;
  }

  .btn-toggle-photo svg {
    width: 20px;
    height: 20px;
  }
}
