/* ========================================
   SIDEBAR ONGLET - VERSION PROPRE
   ======================================== */

/* ===== STRUCTURE PRINCIPALE ===== */
.sidebar-onglet-sidebar {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 1040;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 1.5em 0 0 1.5em;
  box-shadow: -2px 2px 16px rgba(35, 37, 38, 0.1);
  padding: 0.5em 0.25em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  width: auto;
  align-items: flex-end;
}

/* ===== BOUTONS DE LA SIDEBAR ===== */
.sidebar-onglet-sidebar .sidebar-onglet-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-size: 1.25rem;
  color: #232323;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.75em;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  font-weight: 500;
  min-width: 48px;
  width: 48px;
  height: 48px;
  position: relative;
  box-sizing: border-box;
  margin: 0;
  overflow: visible;
}

/* Icônes */
.sidebar-onglet-sidebar .sidebar-onglet-link i.bi {
  color: #2563eb;
  font-family: 'bootstrap-icons';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  transition: color 0.3s;
}

/* Labels - cachés par défaut */
.sidebar-onglet-sidebar .sidebar-onglet-link .sidebar-onglet-label {
  position: absolute;
  right: calc(100% + 0.75em);
  white-space: nowrap;
  background: #2563eb;
  color: white;
  padding: 0.5em 1em;
  border-radius: 1em;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* État hover des boutons */
.sidebar-onglet-sidebar .sidebar-onglet-link:hover,
.sidebar-onglet-sidebar .sidebar-onglet-link:focus,
.sidebar-onglet-sidebar .sidebar-onglet-link.active {
  background: #2563eb;
  color: white;
  transform: scale(1.05);
}

.sidebar-onglet-sidebar .sidebar-onglet-link:hover i.bi,
.sidebar-onglet-sidebar .sidebar-onglet-link:focus i.bi,
.sidebar-onglet-sidebar .sidebar-onglet-link.active i.bi {
  color: white;
}

/* Afficher le label au survol */
.sidebar-onglet-sidebar .sidebar-onglet-link:hover .sidebar-onglet-label,
.sidebar-onglet-sidebar .sidebar-onglet-link:focus .sidebar-onglet-label {
  opacity: 1;
  transform: translateX(0);
}

/* ===== CONTENEUR DU POPUP ===== */
.sidebar-onglet-with-popup {
  position: relative;
}

/* ===== POPUP APERÇU (AU SURVOL) ===== */
/* Popup positionné à côté du label */
.sidebar-onglet-popup-content {
  position: absolute;
  right: calc(100% + 1.5em);
  top: 0;
  transform: translateY(0);
  z-index: 1060;
  min-width: 280px;
  max-width: 340px;
  width: 320px;
  box-sizing: border-box;
  background: white;
  border-radius: 1.2em;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 1.25em 1.25em 3em 1.25em;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  pointer-events: none;
}

/* Flèche pointant vers la droite (vers la sidebar) */
.sidebar-onglet-popup-content::before {
  content: '';
  position: absolute;
  top: 12px;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid white;
  filter: drop-shadow(2px 0 2px rgba(0, 0, 0, 0.05));
}

/* Affiche le popup au survol */
.sidebar-onglet-with-popup:not(.active-popup):hover .sidebar-onglet-popup-content {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ===== OVERLAY POUR LE MODE PLEIN ÉCRAN ===== */
.sidebar-onglet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-onglet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Cache la flèche en mode plein écran */
.sidebar-onglet-popup-content.popup-fullscreen::before {
  display: none !important;
}

/* ===== POPUP MODE PLEIN ÉCRAN ===== */
.sidebar-onglet-popup-content.popup-fullscreen {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  min-width: 320px;
  z-index: 9999;
  background: white;
  border-radius: 1.2em;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 2em 1.5em;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  opacity: 1;
  overflow-y: auto;
  box-sizing: border-box;
}


/* ===== CONTENU DU POPUP ===== */
.sidebar-onglet-inner {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  font-size: 1rem;
  color: #232323;
}

/* Titre dans le popup d'aperçu */
.popup-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #2563eb;
  margin: 0 0 0.75em 0;
  padding: 0;
  line-height: 1.3;
}

.sidebar-onglet-popup-content.popup-fullscreen .sidebar-onglet-inner {
  max-width: 900px;
}

/* Mode aperçu */
.sidebar-onglet-popup-content .popup-preview {
  display: block;
}

.sidebar-onglet-popup-content .popup-full {
  display: none;
}

/* Mode plein écran */
.sidebar-onglet-popup-content.popup-fullscreen .popup-preview {
  display: none !important;
}

.sidebar-onglet-popup-content.popup-fullscreen .popup-full {
  display: block !important;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* ===== FLÈCHE D'EXPANSION ===== */
.sidebar-onglet-expand-arrow {
  position: absolute;
  bottom: 0.5em;
  right: 0.5em;
  background: #f3f3f3;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.2s ease;
  z-index: 2;
}

.sidebar-onglet-expand-arrow:hover {
  background: #2563eb;
  color: white;
}

.sidebar-onglet-popup-content.popup-fullscreen .sidebar-onglet-expand-arrow {
  display: none !important;
}

/* ===== BOUTON DE FERMETURE ===== */
.sidebar-onglet-close {
  position: absolute;
  top: 1em;
  right: 1em;
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #666;
  display: none;
  z-index: 3;
  transition: color 0.2s ease;
}

.sidebar-onglet-close:hover {
  color: #333;
}

.sidebar-onglet-popup-content.popup-fullscreen .sidebar-onglet-close {
  display: block !important;
}


/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
  .sidebar-onglet-sidebar {
    display: none;
  }
}

@media (max-width: 600px) {
  .sidebar-onglet-popup-content.popup-fullscreen {
    width: 95% !important;
    padding: 1.5em 1em !important;
  }
  
  .sidebar-onglet-inner {
    font-size: 0.95rem;
  }
  
  .sidebar-onglet-popup-content {
    width: 280px;
    max-width: calc(100vw - 80px);
  }
}
