/* ========================================
   BARRE DES SERVICES (à droite, pages internes)
   Couleurs en variables : sombre par défaut, claires avec data-theme="light".
   ======================================== */

:root {
  --onglet-bg: rgba(2, 6, 23, 0.94);
  --onglet-border: rgba(var(--gold-rgb), 0.25);
  --onglet-icon: var(--gold);
  --onglet-accent: var(--gold);
  --onglet-accent-text: #020617;
  --onglet-popup-bg: #0b1222;
  --onglet-popup-text: rgba(255, 255, 255, 0.85);
  --onglet-popup-title: #ffffff;
  --onglet-arrow-bg: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  --onglet-bg: rgba(255, 255, 255, 0.96);
  --onglet-border: rgba(15, 23, 42, 0.08);
  --onglet-icon: var(--accent);
  --onglet-accent: var(--accent);
  --onglet-accent-text: #ffffff;
  --onglet-popup-bg: #ffffff;
  --onglet-popup-text: #232323;
  --onglet-popup-title: #111827;
  --onglet-arrow-bg: #f3f3f3;
}

/* ===== STRUCTURE PRINCIPALE ===== */
.sidebar-onglet-sidebar {
  position: fixed;
  top: 50%;
  right: 16px; /* décalée du bord : la barre de défilement ne la recouvre plus */
  transform: translateY(-50%);
  z-index: 1040;
  background: var(--onglet-bg);
  border: 1px solid var(--onglet-border);
  border-radius: 1.5em;
  box-shadow: -2px 2px 16px rgba(0, 0, 0, 0.18);
  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: var(--onglet-popup-text);
  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: var(--onglet-icon);
  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: var(--onglet-accent);
  color: var(--onglet-accent-text);
  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: var(--onglet-accent);
  color: var(--onglet-accent-text);
  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: var(--onglet-accent-text);
}

/* 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: var(--onglet-popup-bg);
  border: 1px solid var(--onglet-border);
  border-radius: 1.2em;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  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 var(--onglet-popup-bg);
  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: var(--onglet-popup-bg);
  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: var(--onglet-popup-text);
}

.sidebar-onglet-inner h2,
.sidebar-onglet-inner h4,
.sidebar-onglet-inner strong {
  color: var(--onglet-popup-title);
}

.sidebar-onglet-inner .btn-primary {
  background: var(--onglet-accent);
  border-color: var(--onglet-accent);
  color: var(--onglet-accent-text);
}

.sidebar-onglet-inner .btn-outline-primary {
  border-color: var(--onglet-accent);
  color: var(--onglet-accent);
}

.sidebar-onglet-inner .btn-outline-primary:hover {
  background: var(--onglet-accent);
  color: var(--onglet-accent-text);
}

/* Titre dans le popup d'aperçu */
.popup-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--onglet-accent);
  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: var(--onglet-arrow-bg);
  color: var(--onglet-popup-text);
  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: var(--onglet-accent);
  color: var(--onglet-accent-text);
}

.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: var(--onglet-popup-text);
  display: none;
  z-index: 3;
  transition: color 0.2s ease;
}

.sidebar-onglet-close:hover {
  color: var(--onglet-accent);
}

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


/* ===== RESPONSIVE ===== */
/* Écrans peu hauts : boutons plus compacts pour que les 14 services tiennent */
@media (max-height: 860px) {
  .sidebar-onglet-sidebar { gap: 0.15em; padding: 0.35em 0.2em; }
  .sidebar-onglet-sidebar .sidebar-onglet-link { width: 40px; min-width: 40px; height: 40px; font-size: 1.05rem; padding: 0.5em; }
}

@media (max-height: 640px) {
  .sidebar-onglet-sidebar .sidebar-onglet-link { width: 34px; min-width: 34px; height: 34px; font-size: 0.95rem; }
}

@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);
  }
}
