/* Bayān 10.14 — stabilité tactile, contraste des états actifs, filtres/lecture sans débordement. */

/* Palette dédiée aux éléments sélectionnés : contraste garanti dans les 8 thèmes. */
html[data-bayaan-theme="current"]{--bayaan-selected-bg:#0d5b4d;--bayaan-selected-text:#ffffff}
html[data-bayaan-theme="dark"]{--bayaan-selected-bg:#79d7bb;--bayaan-selected-text:#071a14}
html[data-bayaan-theme="pastel"]{--bayaan-selected-bg:#6d485b;--bayaan-selected-text:#ffffff}
html[data-bayaan-theme="luxury"]{--bayaan-selected-bg:#d8b96f;--bayaan-selected-text:#171208}
html[data-bayaan-theme="amber"]{--bayaan-selected-bg:#7f3008;--bayaan-selected-text:#fffaf1}
html[data-bayaan-theme="nautical"]{--bayaan-selected-bg:#0b6970;--bayaan-selected-text:#ffffff}
html[data-bayaan-theme="solaria"]{--bayaan-selected-bg:#20231e;--bayaan-selected-text:#ffffff}
html[data-bayaan-theme="bordeaux"]{--bayaan-selected-bg:#f1e7e2;--bayaan-selected-text:#42101c}

/* Navbars d'applications + onglets Research/Travail : jamais texte sombre sur fond sombre. */
html[data-bayaan-theme] body :is(.app-local-nav > .nav-button.active,.app-local-nav > .nav-btn.active,
  .v100-tabs button.active,.v90-tabs button.active,.v90c-tabs button.active,
  #researchWorkView .v7-tabs button.active,.v7-workspace-tabs button.active,
  .bayaan-mobile-tabs-list > button.active){
  background:var(--bayaan-selected-bg)!important;
  color:var(--bayaan-selected-text)!important;
  border-color:var(--bayaan-selected-bg)!important;
  opacity:1!important;
}
html[data-bayaan-theme] body :is(.app-local-nav > .nav-button.active,.app-local-nav > .nav-btn.active,
  .v100-tabs button.active,.v90-tabs button.active,.v90c-tabs button.active,
  #researchWorkView .v7-tabs button.active,.v7-workspace-tabs button.active,
  .bayaan-mobile-tabs-list > button.active) :is(span,b,strong,i,small,.nav-icon,.nav-label){
  color:var(--bayaan-selected-text)!important;
  opacity:1!important;
}
html[data-bayaan-theme] body .app-local-nav > :is(.nav-button,.nav-btn):not(.active){
  color:var(--bayaan-nav-text)!important;
  opacity:1!important;
}
html[data-bayaan-theme] body .app-local-nav > :is(.nav-button,.nav-btn):not(.active) :is(span,i,.nav-icon,.nav-label){
  color:inherit!important;
  opacity:1!important;
}

/* Les panneaux de choix restent stables et lisibles pendant le scroll. */
html[data-bayaan-theme] body :is(.reading-options-panel,.verse-options-panel,.search-options-panel,.v89-work-options-panel,.v89-note-options-panel){
  box-sizing:border-box!important;
  background:var(--bayaan-surface)!important;
  color:var(--bayaan-text)!important;
  border-color:var(--bayaan-border-strong)!important;
}
html[data-bayaan-theme] body :is(.reading-options-panel,.verse-options-panel,.search-options-panel,.v89-work-options-panel,.v89-note-options-panel) :is(label,span,strong,b){
  color:var(--bayaan-text)!important;
}
html[data-bayaan-theme] body :is(.reading-options-panel,.verse-options-panel,.search-options-panel,.v89-work-options-panel,.v89-note-options-panel) :is(select,input,textarea,button){
  box-sizing:border-box!important;
  min-width:0!important;
  max-width:100%!important;
}

@media(max-width:760px){
  html,body{max-width:100%!important;overflow-x:hidden!important}
  .app-quran .app-shell,.app-quran main,.app-quran .view{max-width:100%!important;overflow-x:clip!important}

  /* Filtres de recherche : toujours à l'intérieur du panneau mobile. */
  .app-quran :is(.search-panel,.filters-row,.search-control-group,.numeric-controls,.segmented-control,.field,.switch-field){
    box-sizing:border-box!important;
    min-width:0!important;
    max-width:100%!important;
  }
  .app-quran .search-panel{overflow:visible!important}
  .app-quran .filters-row{
    width:100%!important;
    max-width:100%!important;
    grid-template-columns:1fr!important;
    overflow-x:hidden!important;
    padding:10px!important;
  }
  .app-quran .filters-row > *{grid-column:1!important;width:100%!important;min-width:0!important;max-width:100%!important}
  .app-quran .filters-row :is(select,input,button){max-width:100%!important;min-width:0!important}
  .app-quran .segmented-control{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:5px!important;overflow:hidden!important}
  .app-quran .segmented-control button{min-width:0!important;width:100%!important;padding-inline:6px!important;white-space:normal!important}

  /* Lecture : le panneau Options devient un accordéon dans le flux du document.
     Il pousse le contenu au lieu de le recouvrir et la page reste scrollable jusqu'en bas. */
  .app-quran .v89-reading-toolbar,
  .app-quran .surah-toolbar,
  .app-quran .surah-toolbar-main{overflow:visible!important;max-width:100%!important}
  .app-quran .surah-toolbar-main{display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;width:100%!important}
  .app-quran .surah-toolbar-main .back-to-results{grid-column:1/-1!important}
  .app-quran .reading-options-menu{position:relative!important;min-width:0!important;max-width:100%!important;width:100%!important}
  .app-quran .reading-options-menu[open]{grid-column:1/-1!important;width:100%!important}
  .app-quran .reading-options-menu > summary{width:100%!important;max-width:100%!important;box-sizing:border-box!important}
  .app-quran .reading-options-menu[open] > summary{margin-bottom:8px!important}
  .app-quran .reading-options-panel{
    position:static!important;
    inset:auto!important;
    left:auto!important;right:auto!important;top:auto!important;bottom:auto!important;
    transform:none!important;
    width:100%!important;
    max-width:100%!important;
    max-height:none!important;
    overflow:visible!important;
    margin:0!important;
    padding:12px!important;
    grid-template-columns:1fr!important;
    gap:9px!important;
    box-shadow:none!important;
    border-radius:14px!important;
  }
  .app-quran .reading-options-panel :is(label,select,button){width:100%!important;min-width:0!important;max-width:100%!important}
  .app-quran .reading-options-panel select{font-size:16px!important;text-overflow:ellipsis!important}
  .app-quran .reading-options-panel .toolbar-reciter-field,
  .app-quran .reading-options-panel .toolbar-french-voice-field{grid-column:1!important}

  /* Petits menus Options de versets : bornés à l'écran. */
  .app-quran .verse-options-panel,
  .app-quran .search-options-panel,
  .app-quran .v89-work-options-panel,
  .app-quran .v89-note-options-panel{
    max-width:calc(100vw - 24px)!important;
    width:min(360px,calc(100vw - 24px))!important;
  }

  /* Le contenu Lecture garde de l'espace sous la barre Safari / lecteur audio. */
  .app-quran #surahView,
  .app-quran .surah-reader-shell{padding-bottom:max(110px,env(safe-area-inset-bottom))!important}
}
