/* =========================================================
   MINIMUM CSS - BASE STABLE
========================================================= */

html,
body {
  zoom: 96%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body > .container-fluid,
.bslib-page-fill {
  height: 100%;
  min-height: 0;
}

.app-container {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* =========================================================
   HEADER
========================================================= */

.admin-banner {
  display: flex;
  align-items: stretch;
  background: #f3f3f3;
  border-top: 1px solid #e6e6e6;
  border-bottom: 1px solid #d7d7d7;
  height: 72px;
  flex: 0 0 72px;
  width: 100%;
  box-sizing: border-box;
}

.admin-banner-left {
  width: 252px;
  min-width: 252px;
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 14px;
  border-right: 1px solid #cfcfcf;
  box-sizing: border-box;
}

.admin-logo-full {
  display: block;
  height: 78px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.admin-banner-right {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 14px 18px 0 14px;
  box-sizing: border-box;
}

.admin-banner-right span {
  font-size: 15px;
  line-height: 1.1;
  font-weight: 700;
  color: #0d223f;
}

.banner-link,
.banner-link:focus,
.banner-link:active,
.banner-link:visited {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.banner-link:hover {
  color: inherit;
  text-decoration: none;
}

.header-title-below {
  padding: 6px 12px;
  font-size: 36px;
  color: #005ca9;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  flex: 0 0 auto;
}

.fb-bold {
  font-weight: 800;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
  width: 300px;
  flex: 0 0 300px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-right: 2px solid #d0d0d0;
  background: #fff;
  box-sizing: border-box;
  overflow: hidden;
}

.sidebar-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex: 0 0 auto;
}

.sidebar-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  width: 100%;
  flex: 0 0 auto;
}

.sidebar.collapsed {
  width: 40px;
  flex-basis: 40px;
  padding: 6px;
}

.sidebar.collapsed .sidebar-content,
.sidebar.collapsed .lang-box {
  display: none;
}

.sidebar.collapsed .sidebar-topbar {
  justify-content: flex-start;
}

.toggle-btn.chevron {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.toggle-btn.chevron::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(135deg);
  border-right: 3px solid #005ca9;
  border-bottom: 3px solid #005ca9;
}

.sidebar.collapsed .toggle-btn.chevron::before {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* =========================================================
   MAIN PANEL
========================================================= */

.main-panel {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-fill {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Logos accueil : ne réservent aucun espace */
.partner-logos-bottom-right {
  position: absolute;
  right: 28px;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 24px;
  z-index: 5;
}

.partner-logos-bottom-right a {
  pointer-events: auto;
}

.partner-logo {
  width: auto;
  object-fit: contain;
  display: block;
}

.ufag-logo {
  max-height: 20px;
}

.eurofins-logo {
  max-height: 52px;
}

/* =========================================================
   PAGE REFERENCES - ONGLET PARTENAIRES / LIENS / TEAM
========================================================= */

/* La page référence doit pouvoir scroller si le contenu dépasse */
.reference-page {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  display: flex;
  flex-direction: column;

  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 12px 0;
}

/* Zone des onglets sous les références */
.reference-tabs-zone {
  flex: 0 0 auto;
  margin-top: auto;
  max-width: none;
  width: 100%;
}
.reference-tabs-zone > .card,
.reference-tabs-zone .card {
  height: 300px;
  min-height: 300px;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  box-shadow: none;
  overflow: hidden;
}

/* En-tête des onglets */
.reference-tabs-zone .nav-tabs {
  border-bottom: 1px solid #d9e1ea;
}

.reference-tabs-zone .nav-tabs .nav-link {
  color: #555;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
}

.reference-tabs-zone .nav-tabs .nav-link:hover {
  color: #005ca9;
  border-bottom-color: #b7d4eb;
}

.reference-tabs-zone .nav-tabs .nav-link.active {
  color: #005ca9;
  font-weight: 700;
  background: #fff;
  border-bottom-color: #005ca9;
}


/* Le corps de l'onglet remplit la hauteur disponible */
.reference-tabs-zone .card-body {
  height: calc(300px - 48px);
  min-height: 0;
  padding: 18px 20px;
  overflow-y: auto;
}

.reference-main-content {
  /* Keep file links before the information tabs, even on short viewports. */
  flex: 1 0 auto;
  min-height: auto;
  overflow: visible;
  padding-left: 12px;
  padding-right: 12px;
  box-sizing: border-box;
}

/* Onglet Partenaires */
.reference-partner-logos {
  display: flex;
  align-items: center;
  gap: 38px;
  padding: 12px 4px;
  flex-wrap: wrap;
}

.reference-partner-logos a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.reference-partner-logo {
  display: block;
  width: auto;
  object-fit: contain;
}

.reference-partner-logo.ufag-logo {
  max-height: 28px;
}

.reference-partner-logo.eurofins-logo {
  max-height: 60px;
}

/* Onglet Liens */
.reference-links-section {
  padding: 4px 0;
}

.reference-links-section h4 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #222;
}

.reference-links-section ul {
  margin: 0;
  padding-left: 20px;
}

.reference-links-section li {
  margin-bottom: 8px;
}

.reference-links-section a {
  color: #005ca9;
  text-decoration: underline;
}

.reference-links-section a:hover {
  color: #003f73;
}

/* Onglet Team */
.reference-team-section {
  padding: 4px 0;
}

.reference-team-section h4 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #222;
}


.team-grid {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.team-card {
  flex: 1 1 260px;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  padding: 15px 18px;
  background: #fff;
  box-sizing: border-box;
}

.team-card h5 {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 700;
  color: #005ca9;
}

.team-card p {
  margin: 0 0 7px 0;
  font-size: 14px;
  line-height: 1.35;
  color: #333;
}

.reference-team-section a {
  color: #005ca9;
  text-decoration: underline;
}

.reference-team-section a:hover {
  color: #003f73;
}

.reference-copyright-title {
  text-decoration: underline;
  font-weight: bold;
}


/* Responsive : les onglets prennent toute la largeur sur petit écran */
@media (max-width: 900px) {
  .reference-tabs-zone {
    max-width: 100%;
  }

  .reference-partner-logos {
    gap: 24px;
  }

  .team-card {
    flex-basis: 100%;
  }
}

/* =========================================================
   MAIN AREA - STRETCH TO FULL HEIGHT
========================================================= */

#mainTabsZone,
#mainTabsZone > .shiny-bound-output {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainTabsZone .navset-container {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainTabsZone .navset-container > .card,
#mainTabsZone .navset-container .card {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainTabsZone .navset-container .card-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainTabsZone .tab-content,
#mainTabsZone .tab-pane,
#mainTabsZone .bslib-navs-card-title,
#mainTabsZone .bslib-navs-card-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.navset-container {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.expanded-div {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.table-zone {
  flex: 1 1 auto;
  /* Keep the table and pagination usable; the surrounding panel scrolls
     when the chart and nutrient controls exceed the available height. */
  min-height: 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-zone > .card,
.table-zone > .bslib-card,
.table-zone > .card-fill {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-zone > .card > .card-body,
.table-zone > .bslib-card > .card-body,
.table-zone > .card-fill > .card-body,
.card-fill .card-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-fill {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chart-zone {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.chart-nutrient-controls {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 12px 0;
}

.chart-nutrient-controls > button {
  flex: 0 0 auto;
  margin-left: auto;
  margin-top: 2px;
  white-space: nowrap;
}

.chart-nutrient-rows {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 0;
}

.chart-nutrient-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.chart-nutrient-row label {
  margin: 0;
  white-space: nowrap;
}

.chart-nutrient-row select {
  width: auto;
  min-width: 0;
  max-width: 240px;
}

.chart-zone > .card,
.chart-zone > .bslib-card {
  flex: 0 0 auto;
}

/* =========================================================
   BUTTONS
========================================================= */

.btn-classic,
.search-button {
  width: 100%;
  padding: 6px 14px;
  border-radius: 4px;
  border: 2px solid #005ca9;
}

.btn-classic {
  background: #fff;
  color: #005ca9;
}

.search-button {
  background: #005ca9;
  color: #fff;
}

/* =========================================================
   LANGUAGE / RADIO
========================================================= */

.lang-box {
  margin-left: auto;
  margin-right: 2px;
}

.lang-box .shiny-options-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  margin: 0;
}

.lang-box .radio-inline {
  margin: 0;
  padding: 0;
}

.lang-box label {
  margin: 0;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

#Languageslct input[type="radio"],
#QueryType input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#Languageslct .shiny-options-group {
  display: inline-flex;
  gap: 14px;
  margin: 0;
}

#Languageslct .radio-inline {
  margin: 0;
  padding: 0;
}

#QueryType {
  width: 100%;
  margin-bottom: 0;
}

#QueryType .shiny-options-group {
  display: flex;
  gap: 8px;
  width: 100%;
  margin: 0;
}

#QueryType label.radio-inline {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 10px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #005ca9;
  background: #fff;
  border: 2px solid #005ca9;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

#QueryType label.radio-inline:hover {
  background: #eaf3fb;
}

#QueryType label.radio-inline:has(input[type="radio"]:checked) {
  color: #fff;
  background: #005ca9;
}

#QueryType label.radio-inline:has(input[type="radio"]:focus-visible) {
  outline: 3px solid #003568;
  outline-offset: 3px;
}

#Languageslct .shiny-options-group label {
  font-size: 18px;
}

#Languageslct label:has(input[type="radio"]:checked) {
  color: #005ca9;
  border-bottom-color: #005ca9;
  padding-bottom: 2px;
}

/* =========================================================
   REACTABLE STRUCTURE
========================================================= */

#mainTabsZone .reactable,
.table-zone .reactable,
#mainTabsZone .reactable-html-widget,
.table-zone .reactable-html-widget,
#mainTabsZone .html-widget,
.table-zone .html-widget {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#mainTabsZone .reactable .rt-table,
.table-zone .reactable .rt-table {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto !important;
  overflow-y: auto !important;
}

/* =========================================================
   REACTABLE - TOP/BOTTOM BAR
========================================================= */

#mainTabsZone .reactable .rt-search,
#mainTabsZone .reactable .rt-page-size {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 2px 0;
  min-width: 80px;
}

#mainTabsZone .reactable .rt-page-size-select,
#mainTabsZone .reactable .rt-search input {
  height: 32px;
  padding: 4px 8px;
  min-width: 80px;
  font-size: 14px;
}

#mainTabsZone .reactable .rt-search input {
  width: 160px;
}

#mainTabsZone .reactable .rt-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  padding: 6px 0 0 0;
  min-height: 0;
  line-height: 1;
  font-size: 14px;
  flex: 0 0 auto;
}

#mainTabsZone .reactable .rt-pagination .rt-page-info,
#mainTabsZone .reactable .rt-pagination .rt-page-button-group {
  margin: 0;
  padding: 0;
  line-height: 1;
  white-space: nowrap;
}

#mainTabsZone .reactable .rt-page-button {
  padding: 4px 8px;
  margin: 0 1px;
  font-size: 14px;
}

#mainTabsZone .reactable .rt-search,
#mainTabsZone .reactable .rt-page-size {
  font-size: 14px;
}

#mainTabsZone .reactable .rt-page-size {
  gap: 6px;
}

#mainTabsZone .reactable .rt-page-size::before {
  content: "  ";
  white-space: pre;
}

#mainTabsZone .reactable .rt-search {
  margin-left: auto !important;
}

#mainTabsZone .feed-reactable .rt-table {
  border: 1px solid #dfe5eb;
  border-radius: 6px;
  width: 100%;
}

#mainTabsZone .feed-reactable .rt-tr-group:last-child .rt-tr {
  border-bottom: none;
}

/* =========================================================
   HEADER RENDERING LIGHT
========================================================= */

.dt-head-wrap {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  line-height: 1.1;
  cursor: help;
}

.dt-head-main {
  font-size: 14px;
  font-weight: 600;
  color: #222;
}

.dt-head-unit {
  font-size: 12px;
  font-weight: 400;
  color: #888;
  white-space: nowrap;
  line-height: 1.15;
  padding-bottom: 1px;
}

.dt-head-sub {
  font-size: 10px;
  font-weight: 500;
  color: #4f6b7a;
  white-space: nowrap;
}

/* =========================================================
   REACTABLE LOOK
========================================================= */

#mainTabsZone .feed-reactable .rt-td.col-date,
#mainTabsZone .feed-reactable .rt-th.col-date {
  min-width: 70px;
  white-space: nowrap;
  font-size: 14px;
}

#mainTabsZone .feed-reactable .rt-td.col-aliment,
#mainTabsZone .feed-reactable .rt-th.col-aliment {
  min-width: 140px;
  white-space: nowrap;
  font-size: 14px;
}

#mainTabsZone .feed-reactable .rt-td.col-npa,
#mainTabsZone .feed-reactable .rt-th.col-npa {
  min-width: 40px;
  white-space: nowrap;
  text-align: right;
  font-size: 14px;
}

#mainTabsZone .feed-reactable .rt-td.col-canton,
#mainTabsZone .feed-reactable .rt-th.col-canton {
  min-width: 50px;
  word-break: break-word;
  font-size: 14px;
}

#mainTabsZone .feed-reactable .rt-td.col-altitude,
#mainTabsZone .feed-reactable .rt-th.col-altitude {
  min-width: 50px;
  word-break: break-word;
  font-size: 14px;
}

#mainTabsZone .feed-reactable .rt-td.col-nutrient,
#mainTabsZone .feed-reactable .rt-th.col-nutrient {
  width: 110px;
  min-width: 40px;
  white-space: nowrap;
}

.cell-aliment {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   EXPORT BUTTONS
========================================================= */

.export-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0 0 0;
  background: #fff;
  flex: 0 0 auto;
}

.export-buttons .btn,
.export-buttons .btn-default {
  background: #fff;
  color: #005ca9;
  border: 2px solid #005ca9;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.1;
}

/* =========================================================
   FOOTER
========================================================= */

.header-bottom {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 12px;
  flex: 0 0 auto;
}

.footer-links {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex: 1;
}

.results-client-wait {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
}

.results-client-wait[hidden] { display: none; }

.results-client-wait-card {
  width: min(330px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 8px;
  background: white;
  color: #222;
  text-align: center;
}

.results-client-wait-card p { margin: 15px 0 0; font-weight: bold; }

.app-version {
  display: block;
  width: 100%;
  font-size: 10px;
  color: #777;
  white-space: nowrap;
  text-align: right;
  padding-right: 10px;
}
