/* Rafraîchissement progressif, après le thème historique.
   Les couleurs des graphiques, la police et les logos restent inchangés. */
:root {
  --st-canvas: #fff;
  --st-surface: #fff;
  --st-border: #e3e8eb;
  --st-text: #263238;
  --st-muted: #526168;
  --st-shadow: 0 4px 20px rgba(38, 50, 56, .055);
  --st-radius: 16px;
}

html { margin: 0; scroll-padding-top: 90px; }
body { background: var(--st-canvas); color: var(--st-text); line-height: 1.5; }
body > .container-fluid { padding: 0 clamp(16px, 3vw, 48px) 32px; }
.navbar.navbar-default.navbar-static-top {
  margin: 0 0 24px !important;
  padding: 6px clamp(12px, 2vw, 32px) 0;
  box-shadow: none;
  z-index: 1030;
}
.navbar-nav > li:nth-child(5) { float: none; right: auto; }
.navbar-default .navbar-nav > li > a {
  border-radius: 10px 10px 0 0;
  margin: 0 2px;
  font-weight: 500;
  transition: background-color .16s ease, color .16s ease;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:active,
.navbar-default .navbar-nav > .active > a:focus {
  background: white;
  color: var(--st-text);
}
.navbar .dropdown-menu {
  min-width: 250px;
  padding: 6px;
  border: 1px solid var(--st-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(38, 50, 56, .14);
}
.navbar-default .navbar-nav .dropdown-menu > li > a,
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
  padding: 11px 14px;
  border-radius: 7px;
  background: white;
  color: var(--st-text);
}
.navbar-default .navbar-nav .dropdown-menu > .active > a,
.navbar-default .navbar-nav .open .dropdown-menu > .active > a {
  background: #b5e9ec;
  color: var(--st-text);
  font-weight: 600;
}
.navbar-default .navbar-toggle { border-color: rgba(255,255,255,.7); border-radius: 8px; }
.navbar-toggle:has(.st-menu-label) { min-height: 44px; padding-right: 65px; }
.st-menu-label { position: absolute; right: 12px; top: 10px; color: white; font-weight: 500; }
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus { background: rgba(255,255,255,.2); }

/* Restaurer uniquement les gouttières de la grille, pas celles des widgets. */
.row > [class^="col-"], .row > [class*=" col-"] { padding: 8px; }
.row { margin-left: -8px; margin-right: -8px; }
h1 { line-height: 1.25; margin-top: 16px; margin-bottom: 20px; }
h2, h3, .box-header .box-title { line-height: 1.35; }
p { text-indent: 0; margin-bottom: 10px; }
hr { border-top: 1px solid var(--st-border); margin: 20px 0; }
.form-group { margin-bottom: 14px; }
.control-label { margin-bottom: 7px; font-weight: 500; }

.box, .nav-tabs-custom {
  background: var(--st-surface);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 20px;
}
.box-header { padding: 18px 18px 10px; }
.box-body { padding: 16px 18px; }
.small-box.bg-blue {
  height: auto !important;
  min-height: 22.5rem;
  background: white !important;
  border: 1px solid var(--st-border);
  border-top: 3px solid var(--color-theme-princ);
  box-shadow: var(--st-shadow) !important;
}
.small-box > .inner { padding: 16px; }

/* Onglets stables au survol : aucune modification de géométrie. */
.nav-tabs-custom > .nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-bottom: 0;
  border-radius: 0;
}
.nav-tabs-custom > .nav-tabs > li,
.nav-tabs-custom > .nav-tabs > li.active { margin: 0; border: 0; }
.nav-tabs-custom > .nav-tabs > li > a,
.nav-tabs-custom > .nav-tabs > li:hover > a,
.nav-tabs-custom > .nav-tabs > li.active > a,
.nav-tabs-custom > .nav-tabs > li.active:hover > a {
  top: 0;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 13px;
  transition: background-color .16s ease;
}
.nav-tabs-custom > .nav-tabs > li > a { background: var(--st-canvas); color: var(--st-muted); }
.nav-tabs-custom > .nav-tabs > li:hover > a { background: #b5e9ec; color: var(--st-text); }
.nav-tabs-custom > .nav-tabs > li.active > a,
.nav-tabs-custom > .nav-tabs > li.active:hover > a {
  background: var(--color-theme-princ);
  color: var(--st-text);
  font-weight: 600;
}
.nav-tabs-custom > .tab-content { border-radius: 0 0 var(--st-radius) var(--st-radius); padding: 16px; }

.form-control, .selectize-input, .pickerinput.btn, .rt-search {
  border: 1px solid #cbd5da;
  border-radius: 9px;
  box-shadow: none;
}
.form-control, .selectize-input, .pickerinput.btn { min-height: 40px; }
.rt-search { padding: 12px 16px; margin-bottom: 16px; background: white; }
.rt-search::placeholder { color: var(--st-muted); font-style: normal; }
.rt-filter, .rt-filter:hover, .rt-filter:focus {
  height: 32px !important;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  padding: 4px 6px;
  background: white;
}
.range-input-reactable { color: var(--st-text); border: 1px solid #cbd5da; border-radius: 5px; min-height: 30px; }
.Reactable { border-radius: 12px; }
.bttn-fill.bttn-success { min-height: 42px; transition: box-shadow .16s ease; }
.bttn-fill.bttn-success:hover { box-shadow: 0 4px 12px rgba(38,50,56,.12); }
.bttn-fill.bttn-success:focus-visible,
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--st-text) !important;
  outline-offset: 3px;
}
.modal .modal-content { border: 1px solid var(--st-border); border-radius: 18px; box-shadow: 0 20px 60px rgba(38,50,56,.2); }
.modal-header, .modal-body, .modal-footer { padding: 20px 24px; }
.tooltip > .tooltip-inner { border-color: var(--st-border); border-radius: 10px; box-shadow: var(--st-shadow); text-align: left; }
.fade_in { animation-duration: .25s; }

/* Accueil : mêmes rubriques, deux accès immédiats et une annonce immobile. */
.st-home { max-width: 1440px; margin: 0 auto; }
.st-home-brand { display: flex; justify-content: center; padding: 12px 0 0; }
.st-home-brand img { width: 400px; max-width: 80vw; height: auto; margin: 0 !important; }
.st-welcome { text-align: center; max-width: 840px; margin: 0 auto 32px; padding: 4px 16px 12px; }
.st-eyebrow { font-size: 13px; font-weight: 600; color: var(--st-muted); letter-spacing: .04em; }
.st-welcome h1 { color: var(--st-text) !important; font-size: clamp(28px, 3vw, 40px); font-weight: 600; letter-spacing: -.025em; margin: 12px 0; }
.st-intro { font-size: 17px; line-height: 1.65; max-width: 670px; margin: 0 auto 24px; color: var(--st-muted); }
.st-quicklinks { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.st-entry { display: inline-flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 20px; border: 1px solid #cbd5da; border-radius: 10px; color: var(--st-text); font-size: 16px; font-weight: 600; background: white; transition: box-shadow .16s ease, background-color .16s ease; }
.st-entry-primary { background: var(--color-theme-second); border-color: var(--color-theme-second); }
.st-entry:hover, .st-entry:focus { text-decoration: none; color: var(--st-text); box-shadow: var(--st-shadow); background: #b5e9ec; }
.st-guestbook-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.st-guestbook-list { max-height: 38vh; overflow-y: auto; }
.st-guestbook-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.st-guestbook-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.st-guestbook-pagination .st-entry { padding: 8px 12px; font-size: 14px; }
.st-guestbook-pagination .st-entry:disabled { opacity: .45; cursor: default; box-shadow: none; background: white; }
.st-guestbook-title { display: flex; justify-content: center; align-items: center; gap: .3em; width: 100%; text-align: center; font-size: clamp(18px, 4vw, 32px); font-weight: 700; line-height: 1.25; }
.st-guestbook-title > span { white-space: nowrap; }
.st-guestbook-logo { display: block; width: 4.8em; max-width: 42%; height: auto; }
.st-guestbook-author { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 8px; }
.st-guestbook-date { color: #52616b; font-size: 14px; white-space: nowrap; }
.st-entry.st-guestbook-open { background: #f5df4d; border-color: #f5df4d; }
.st-entry.st-guestbook-open:hover, .st-entry.st-guestbook-open:focus { background: #efda42; border-color: #efda42; }
#shiny-notification-livre_or_confirmation { border: 2px solid #16706b; background: #e7f6f3; color: #173d39; padding: 20px; box-shadow: 0 4px 20px #0002; }
#scrolling-title-container { white-space: normal; overflow: visible; padding: 14px 20px; border: 1px solid var(--color-theme-second); border-radius: 12px; background: white; margin-bottom: 24px; }
#scrolling-title { display: block; animation: none; transform: none; font-size: 16px; line-height: 1.5; color: var(--st-text) !important; margin: 0; }
#scrolling-title .fa, #scrolling-title .fas { color: var(--color-theme-second); }
.st-home-details > .row > .col-sm-6 { padding: 20px; }
.st-home-details h3 { line-height: 1.6; margin-bottom: 20px; }
#carousel_accueil { background: white; border: 0; border-radius: 0; padding: 20px 16px 40px; box-shadow: none; }
.st-home-footer { border-top: 1px solid var(--st-border); margin-top: 40px; padding-top: 24px; }

@media (max-width: 1000px) {
  .navbar.navbar-default.navbar-static-top { padding: 4px 12px 0; }
  .navbar .navbar-collapse { max-height: calc(100dvh - 80px); overflow-y: auto; }
  .navbar .dropdown-menu { min-width: 0; box-shadow: none; border: 0; }
  .navbar-nav > li:nth-child(5) { float: none; right: auto; }
}

/* Menus de l'accueil : mêmes destinations que la navigation principale. */
.st-explore { position: relative; }
.st-explore .dropdown-menu {
  min-width: 100%;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--st-border);
  border-radius: 12px;
  box-shadow: var(--st-shadow);
  text-align: left;
}
.st-explore .dropdown-menu > li > a {
  padding: 12px 14px;
  border-radius: 7px;
  white-space: normal;
  color: var(--st-text);
}
.st-explore .dropdown-menu > li > a:hover,
.st-explore .dropdown-menu > li > a:focus { background: #b5e9ec; }

/* Titres géographiques : utiliser la largeur disponible, retour à droite. */
.st-page-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.st-page-heading::before, .st-page-heading::after,
.st-action-row::before, .st-action-row::after { display: none; }
.st-page-heading > [class*="col-"]:first-child { flex: 1 1 440px; width: auto; min-width: 0; }
.st-page-heading > [class*="col-"]:last-child { flex: 0 0 auto; width: auto; margin-left: auto; }
.st-page-heading h1 { margin: 12px 0; }
.st-page-heading .bttn { min-width: 130px; }

/* Actions de fin de page : même hauteur et même axe vertical. */
.st-action-row { display: flex; align-items: stretch; flex-wrap: wrap; gap: 12px; margin: 24px 0; }
.st-action-row > [class*="col-"],
.st-action-row > #bouton_comparaison_meme_filiere,
.st-action-row > #placeholder_top,
.st-action-row > #placeholder_trash { flex: 0 1 360px; width: auto; min-width: 0; padding: 0; display: flex; align-items: stretch; }
.st-action-row > div > [class*="col-"] { width: 100%; min-width: 0; float: none; padding: 0; display: flex; align-items: stretch; }
.st-action-row .bttn { height: auto; min-height: 54px; padding: 12px 20px; }
.st-action-row > #slider_top_10 { flex: 1 1 420px; padding: 0 16px; }
.st-action-row > #slider_top_10 > .col-sm-2 { display: none; }
.st-action-row > #slider_top_10 > .col-sm-6 { width: 100%; }

/* Carte et indicateurs partagent leur hauteur. Le descriptif peut dépasser
   dans une seconde ligne sans étirer les éléments de la première. */
.st-formation-summary .small-box h3 { white-space: normal; overflow-wrap: break-word; }
@media (min-width: 992px) {
  .st-formation-summary { display: grid; grid-template-columns: 3fr 2fr repeat(var(--st-summary-count, 3), minmax(0, var(--st-summary-track, 2.333fr))); grid-template-rows: min-content 1fr; align-items: stretch; }
  .st-summary-two { --st-summary-count: 2; --st-summary-track: 3.5fr; }
  .st-formation-summary::before, .st-formation-summary::after { display: none; }
  .st-formation-summary > .col-sm-7 { display: contents; }
  .st-formation-summary > .col-sm-3 { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .st-formation-summary > .col-sm-2,
  .st-formation-summary > .col-sm-7 > .shiny-html-output { grid-row: 1; }
  .st-formation-summary > .col-sm-3,
  .st-formation-summary > .col-sm-2,
  .st-formation-summary > .col-sm-7 > .shiny-html-output { width: auto; min-width: 0; float: none; padding: 8px; }
  .st-formation-summary > .col-sm-2,
  .st-formation-summary > .col-sm-7 > .shiny-html-output { display: flex; }
  .st-formation-summary .small-box { width: 100%; margin: 0; }
  .st-formation-summary > .col-sm-2 > .shiny-spinner-output-container { width: 100%; min-height: 22.5rem; padding: 0; }
  /* La carte Parcoursup géographique possède un conteneur supplémentaire. */
  .st-formation-summary > .col-sm-2 > #carte_academie { display: flex; width: 100%; padding: 0; }
  .st-formation-summary #carte_academie > .shiny-spinner-output-container { width: 100%; padding: 0; }
  .st-formation-summary .leaflet { height: 100% !important; min-height: 22.5rem; }
}
@media (min-width: 768px) and (max-width: 991px) {
  .st-formation-summary > .col-sm-3 { width: 60%; }
  .st-formation-summary > .col-sm-2 { width: 40%; }
  .st-formation-summary > .col-sm-7 { width: 100%; display: flex; align-items: stretch; }
  .st-formation-summary > .col-sm-7 > .shiny-html-output { display: flex; }
  .st-formation-summary .small-box { width: 100%; margin: 0; }
}
@media (max-width: 767px) {
  .st-explore, .st-explore .dropdown-menu { width: 100%; }
  .st-action-row > div { flex-basis: 100%; }
  .st-page-heading > [class*="col-"]:first-child { flex-basis: 100%; }
  .st-page-heading > [class*="col-"]:last-child { margin-left: 0; }
}

/* Les actions de l'application reprennent le bouton blanc de l'accueil.
   Les classes restent identiques pour les mises à jour Shiny existantes. */
.bttn.bttn-success,
.bttn.bttn-success:focus,
.bttn.bttn-success:active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 14px 20px;
  border: 1px solid #cbd5da;
  border-radius: 10px;
  background: white;
  color: var(--st-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-shadow: none;
  transform: none;
  transition: background-color .16s ease, box-shadow .16s ease;
}
.bttn.bttn-success:hover {
  color: var(--st-text);
  background: #b5e9ec;
  border-color: #cbd5da;
  box-shadow: var(--st-shadow);
}
.bttn.bttn-success::before, .bttn.bttn-success::after { display: none; }
.bttn.bttn-success > i { flex-shrink: 0; margin: 0; }

/* Les blocs de lecture se fondent dans la page ; seuls les indicateurs
   de synthèse gardent leur contour. Les onglets restent identifiables. */
.box-header.with-border { border: 0; }
.box-header, .box-body { padding-left: 0; padding-right: 0; }
.nav-tabs-custom > .tab-content { padding-left: 0; padding-right: 0; border-radius: 0; }
.texte_reactif_gauche, .texte_reactif_droite { margin-top: 0; }
.row:has(> .col-sm-5):has(> .col-sm-7),
.row:has(> .col-sm-4):has(> .col-sm-8) {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 24px;
}
.row:has(> .col-sm-5):has(> .col-sm-7)::before,
.row:has(> .col-sm-5):has(> .col-sm-7)::after,
.row:has(> .col-sm-4):has(> .col-sm-8)::before,
.row:has(> .col-sm-4):has(> .col-sm-8)::after { display: none; }
.row:has(> .col-sm-5):has(> .col-sm-7) > [class*="col-"],
.row:has(> .col-sm-4):has(> .col-sm-8) > [class*="col-"] { margin-top: 0 !important; }

/* Choix d'entrée : même disposition que les accès Parcoursup / Mon Master. */
#initialisation_specialites > .row,
#boutons_initialisation_spes > .row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  max-width: 960px;
  margin: 28px auto;
}
#initialisation_specialites > .row::before,
#initialisation_specialites > .row::after,
#boutons_initialisation_spes > .row::before,
#boutons_initialisation_spes > .row::after { display: none; }
#initialisation_specialites > .row > :empty,
#boutons_initialisation_spes > .row > :empty { display: none; }
#initialisation_specialites > .row > .col-sm-4,
#boutons_initialisation_spes > .row > .col-sm-4 { display: flex; min-width: 0; width: auto; padding: 0; }
#initialisation_specialites .bttn,
#boutons_initialisation_spes .bttn { height: auto; }

#select_academie, #select_academie_master {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  max-width: 1140px;
  margin: 28px auto;
}
#select_academie > .row, #select_academie_master > .row { margin: 0; }
#select_academie > .row > :empty,
#select_academie_master > .row > :empty { display: none; }
#select_academie > .row > .col-sm-4,
#select_academie_master > .row > .col-sm-4 { width: 100%; padding: 0; margin-top: 0 !important; }
#select_academie .bttn, #select_academie_master .bttn { min-height: 78px; }
#picker_geo_academie, #picker_geo_epci,
#picker_geo_academie_master, #picker_geo_epci_master { margin-top: 12px; }
@media (max-width: 767px) {
  #initialisation_specialites > .row, #boutons_initialisation_spes > .row { grid-template-columns: 1fr; }
  #select_academie, #select_academie_master { grid-template-columns: 1fr; }
  #select_academie .bttn, #select_academie_master .bttn { min-height: 54px; }
  .row:has(> .col-sm-5):has(> .col-sm-7) > [class*="col-"],
  .row:has(> .col-sm-4):has(> .col-sm-8) > [class*="col-"] { width: 100%; flex: 0 0 100%; }
}

/* Centrer les descriptifs dans leur ligne sans déplacer les titres.
   La hauteur reste déterminée par le contenu et le graphique, jamais fixée. */
@media (min-width: 768px) {
  .row:has(> .col-sm-5):has(> .col-sm-7),
  .row:has(> .col-sm-4):has(> .col-sm-8) { align-items: stretch; }

  /* Certains blocs Mon Master ont leurs colonnes dans un même box-body. */
  .box-body:has(> .col-sm-5 > .texte_reactif_droite):has(> .col-sm-7) {
    display: flex;
    align-items: center;
  }
  .box-body:has(> .col-sm-5 > .texte_reactif_droite):has(> .col-sm-7)::before,
  .box-body:has(> .col-sm-5 > .texte_reactif_droite):has(> .col-sm-7)::after { display: none; }

  /* Descriptif sans titre dans sa colonne : centrer la colonne entière. */
  .row > :is(.col-sm-4, .col-sm-5):has(> :is(.texte_reactif_gauche, .texte_reactif_droite)) {
    align-self: center;
  }

  /* Descriptif avec titre : étirer le panneau, garder son en-tête en haut
     et centrer seulement le corps dans l'espace restant. */
  .row > :is(.col-sm-4, .col-sm-5):has(> .col-sm-12 > .box > .box-body > :is(.texte_reactif_gauche, .texte_reactif_droite)),
  .row > :is(.col-sm-4, .col-sm-5) > .col-sm-12:has(> .box > .box-body > :is(.texte_reactif_gauche, .texte_reactif_droite)) {
    display: flex;
    min-width: 0;
  }
  .row > :is(.col-sm-4, .col-sm-5) > .col-sm-12 > .box:has(> .box-body > :is(.texte_reactif_gauche, .texte_reactif_droite)) {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: 0;
    min-width: 0;
  }
  .row > :is(.col-sm-4, .col-sm-5) > .col-sm-12 > .box > .box-body:has(> :is(.texte_reactif_gauche, .texte_reactif_droite)) {
    display: flex;
    align-items: center;
    flex: 1;
  }
  .box-body > :is(.texte_reactif_gauche, .texte_reactif_droite) { width: 100%; }
}
@media (max-width: 767px) {
  .Reactable .rt-td, .Reactable .rt-th, .Reactable .rt-pagination { font-size: 14px !important; }
  .st-home-brand img { width: 310px; }
  .st-welcome { padding: 0; margin-bottom: 20px; }
  .st-entry { width: 100%; }
  .st-home-details > .row > .col-sm-6 { padding: 8px; }
  .box-header, .box-body, .nav-tabs-custom > .tab-content { padding: 12px; }
  .nav-tabs-custom > .nav-tabs { gap: 4px; padding: 8px; }
  .nav-tabs-custom > .nav-tabs > li > a { padding: 10px; }
  .tooltip > .tooltip-inner { width: 80vw; }
  .modal-header, .modal-body, .modal-footer { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .fade_in { opacity: 1; }
}
