/* main.css */

/* Variables globales */
:root {
  --primary: #0f1923;
  --secondary: #1e2d3d;
  --accent: #af9080;
  --text: #e6f1ff;
  --glass: rgba(30, 45, 61, 0.9);
  --glass-hover: rgba(50, 65, 81, 0.9);
  --overlay-bg: rgba(10, 20, 30, 0.97);
  --error: #ff4d4d;
}

/* Réinitialisation */
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: transparent;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* Conteneur principal */
#canvasContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background-color: #000;
  transition: filter 0.4s ease-out;
}

#canvasContainer.blurred {
  filter: blur(8px) brightness(0.7);
}

#slideshowCanvas, #maskCanvas, #highlightCanvas, #infoFrameCanvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: none; /* Masqué par défaut */
  object-fit: cover; /* Ajouté pour cohérence visuelle */
}

#slideshowCanvas {
  z-index: 10;
  background: var(--primary); /* Fond temporaire pour débogage */
}

#maskCanvas {
  z-index: 20;
  pointer-events: none;
  opacity: 0;
}

#highlightCanvas {
  z-index: 30;
  pointer-events: none;
  transition: opacity 200ms ease-in;
  opacity: 0;
}

#infoFrameCanvas {
  z-index: 40;
  pointer-events: none; /* Les cadres ne doivent pas interférer avec les interactions */
  transition: opacity 200ms ease-in;
}

/* Afficher les canvas après chargement */
#canvasContainer:not(.loading) #slideshowCanvas,
#canvasContainer:not(.loading) #maskCanvas,
#canvasContainer:not(.loading) #highlightCanvas,
#canvasContainer:not(.loading) #infoFrameCanvas {
  display: block;
}

#canvasContainer.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px; /* Plus grand pour visibilité */
  height: 80px;
  border: 8px solid var(--secondary);
  border-top: 8px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
  z-index: 100;
}

#canvasContainer.loading::after {
  content: attr(data-progress) '%';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem; /* Plus grand */
  z-index: 101;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Panneau de lots */
#lotPanel {
  position: fixed;
  top: 80px;
  bottom: 50px;
  left: 20px;
  right: 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: .2rem;
  display: none;
  z-index: 2000;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--secondary);
  margin: 0 auto;
  max-width: 1200px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  filter: none !important;
}

#lotPanel.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
}

.lot-panel-header {
  display: flex;
  justify-content: center; /* Center the entire content */
  align-items: center;
  padding: 1rem;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--secondary);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  position: relative; /* Allow absolute positioning of children */
}

.lot-panel-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  position: absolute;
  left: 1rem; /* Align title to the left */
  margin: 0; /* Remove default margins */
}

.lot-viewer-buttons {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
}

.lot-panel-btn {
  width: 100px;
  max-height: 40px;
  padding: 0.5rem;
  background: #182430;
  border: 1px solid var(--secondary);
  border-radius: 25px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.lot-panel-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
}

.lot-panel-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
}

.lot-close-btn {
  position: absolute;
  right: 1rem; /* Align close button to the right */
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.lot-close-btn:hover {
  background: var(--glass-hover);
  transform: scale(1.1);
  color: var(--primary);
}

/* New containers for 2D and 3D viewers */
.lot-2d-container,
.lot-3d-container {
  flex: 1;
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default */
  position: relative;
  overflow: hidden;
}

.lot-2d-container.active,
.lot-3d-container.active {
  display: flex; /* Show the active container */
}

#lotPdfViewer,
#lot3dViewer {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#lotPdfViewer {
  display: flex; /* Always flex, since it's inside an active container */
  justify-content: center;
  align-items: center;
  cursor: grab;
}

#lot3dViewer {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
}

#lotPdfViewer img {
  width: 100%;
  height: 100%;
  object-fit: fit;
  display: block;
  transform-origin: center center;
}

#lot3dViewer img {
  width: 100%;
  height: 100%;
  object-fit: fit;
  display: block;
}

/* Panneau latéral gauche */
.left-panel {
  position: fixed;
  top: 60px;
  bottom: 0;
  left: -200px;
  width: 165px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--secondary);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  z-index: 90;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  /* Style de la scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.left-panel::-webkit-scrollbar {
  width: 5px;
}

.left-panel::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 3px;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.left-panel::-webkit-scrollbar-track {
  background: transparent;
}

.left-panel:hover::-webkit-scrollbar-thumb {
  opacity: 0.8;
}

@keyframes scrollFade {
  0% { opacity: 0.5; }
  100% { opacity: 0.2; }
}

.left-panel:not(:hover)::-webkit-scrollbar-thumb {
  animation: scrollFade 1.5s ease-out forwards;
}

.left-panel.open {
  left: 0;
}

.panel-toggle {
  position: fixed;
  left: 1px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: var(--glass);
  backdrop-filter: blur(30px);
  border: 1px solid var(--secondary);
  border-radius: 0 12px 12px 0;
  cursor: pointer;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease, transform 0.3s ease;
  box-shadow: -3px 0 10px rgba(0, 0, 0, 0.2);
}

.panel-toggle:hover {
  background: var(--accent);
  transform: translateY(-50%) scale(1.1);
}

body:has(.left-panel.open) #leftPanelToggle {
  left: 190px;
}

.panel-toggle .toggle-icon {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease, filter 0.3s ease;
  display: block;
  filter: brightness(1) invert(1);
}

.panel-toggle:hover .toggle-icon {
  filter: hue-rotate(140deg) brightness(1.2) invert(0);
}

body:has(.left-panel.open) #leftPanelToggle .toggle-icon {
  transform: rotate(90deg);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-section h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.filter-section label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: var(--text);
}

.filter-section select,
.filter-section input {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--secondary);
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 0.3rem;
  width: 70%;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.filter-section select:hover,
.filter-section input:hover {
  border-color: var(--accent);
  background: var(--glass-hover);
}

.filter-section select:focus,
.filter-section input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 5px rgba(100, 244, 172, 0.5);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-group label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.checkbox-group input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--secondary);
  border-radius: 4px;
  background: var(--glass);
  cursor: pointer;
  align-items: center;
  transition: all 0.3s ease;
}

.checkbox-group input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-group input[type="checkbox"]:hover {
  border-color: var(--accent);
}

#resetFilters {
  margin-top: 4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--secondary);
  border: 1px solid var(--secondary);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  align-self: center;
}

#resetFilters:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
}

/* En-tête */
.header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  border-bottom: 1px solid var(--secondary);
  background: var(--glass);
  backdrop-filter: blur(10px);
  z-index: 1000;
}

.header-logo {
  max-height: 50px;
  width: auto;
  margin-right: auto;
}

.header-buttons {
  margin-left: auto;
  display: flex;
  gap: 0.8rem;
  padding-right: 5rem;
}

.main-btn {
  padding: 0.6rem 1.2rem;
  border-radius: 25px;
  background: #182430;
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-size: 0.9rem;
}

.main-btn:hover {
  background: var(--accent);
  color: var(--primary);
}

/* Styles pour l'indicateur d'image (numéro de page) */
.image-indicator {
  position: absolute; /* Positionnement absolu par rapport à .viewer-container */
  bottom: 10px;      /* 10px du bas du conteneur */
  left: 50%;         /* 50% du côté gauche du conteneur */
  transform: translateX(-50%); /* Décale de 50% de sa propre largeur vers la gauche pour centrer */
  color: var(--text);
  font-size: 1rem;
  background: var(--glass);
  padding: 5px 10px;
  border-radius: 12px;
  z-index: 10; /* Assurez-vous qu'il est au-dessus des images mais pas trop haut */
  /* Les transitions sont déjà gérées en JS ou dans .viewer-container si besoin */
}

.image-indicator:empty {
  display: none; /* Cache l'indicateur s'il est vide */
}

/* Contenu principal */
.main {
  height: calc(100vh - 60px);
  margin-top: 60px;
  padding-left: 0;
}

/* Boutons de navigation des étages */
.nav-buttons {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  z-index: 70;
  padding: 1rem 0.5rem;
  background: var(--glass);
  backdrop-filter: blur(10px);
  border-radius: 16px 0 0 16px;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #182430;
  backdrop-filter: blur(5px);
  border: 1px solid var(--secondary);
  color: var(--text);
  font-weight: 500;
  font-size: .7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: var(--accent);
  color: var(--primary);
  font-weight: 700;
  transform: scale(1.15);
  border-color: var(--accent);
  /*box-shadow: 0 0 8px rgba(100, 244, 172, 0.5);*/
}

.nav-btn.active {
  background: var(--accent);
  color: var(--primary);
  border: 1px solid var(--primary);
  transform: scale(1.1);
  /*box-shadow: 0 0 12px rgba(100, 244, 172, 0.7);*/
}

/* Panneaux de visualisation */
.view-panel {
  position: fixed;
  top: 80px;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 2rem;
  display: none;
  z-index: 2000;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--secondary);
  margin: 0 auto;
  max-width: 1200px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
}

.view-panel.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  z-index: 12;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.close-btn:hover, .lot-close-btn:hover {
  background: var(--accent);
  transform: scale(1.1);
  filter: brightness(1.3);
}

.viewer-container {
  width: 100%;
  height: 100%;
  background: transparent;
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewer-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border: none;
}

#video video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
}

.nav-arrows {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  padding: 0 1rem;
  box-sizing: border-box;
  z-index: 15;
}

.arrow-btn {
  width: 40px;
  height: 40px;
  background: var(--glass);
  border: 1px solid var(--secondary);
  border-radius: 50%;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.arrow-btn:hover {
  background: var(--glass-hover);
}

.arrow-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-arrows.hidden {
  display: none;
}

.image-indicator {
  transition: opacity 0.3s ease;
  opacity: 0.9;
}

.image-indicator:empty {
  display: none;
}

/* Messages d'erreur */
.error-message {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--secondary);
  font-size: 1.2rem;
  text-align: center;
  z-index: 100;
}

/* Style du bouton Reset All */
#resetAll {
  margin-top: .5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  background: var(--secondary);
  border: 1px solid var(--secondary);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 120px;
  text-align: center;
}

#resetAll:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
}

/* Style du footer */
.panel-footer {
  text-align: center;
  font-size: 0.5rem;
  font-weight: 100;
  color: var(--text);
  opacity: 0.5;
  padding-bottom: 0.5rem;
}

/* Classe pour masquer les éléments */
.hidden {
  display: none !important;
}

/* Style du bouton Fullscreen */
#fullscreenBtn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--glass);
  border: 1px solid var(--secondary);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
}

#fullscreenBtn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

#fullscreenBtn .fullscreen-icon {
  width: 24px;
  height: 24px;
  color: var(--text);
}

#fullscreenBtn:hover .fullscreen-icon {
  color: var(--primary);
}

/* Style de l'icône "no entry" */
#no-entry-icon {
  stroke: var(--error);
  fill: none;
}

/* Media Queries */
@media (max-width: 768px) {
  .left-panel {
    width: 150px;
    left: -180px;
  }
  .left-panel.open {
    left: 0;
  }
  .panel-toggle {
    left: 1px;
  }
  body:has(.left-panel.open) #leftPanelToggle {
    left: 170px;
  }
  .view-panel {
    left: 2vw;
    right: 2vw;
    bottom: 2vh;
  }
  .header {
    padding: 0 1rem;
  }
  .header-logo {
    max-height: 30px;
  }
  .header-buttons {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-right: 1rem;
  }
  .nav-buttons {
    padding: 0.5rem;
  }
  .nav-btn {
    width: 40px;
    height: 40px;
    font-size: 0.8rem;
  }
  .arrow-btn {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
}