/*
 * FoodCare FoodBorne Pathogen Guide v0.19.6
 * Search reliability + genuine mobile containment.
 * Loaded last, intentionally overriding legacy grid specificity collisions.
 */

.fbp-assessment-bottom-action{
  display:grid!important;
  grid-template-columns:minmax(220px,auto) minmax(0,1fr)!important;
  gap:10px!important;
  align-items:center!important;
  margin-top:16px!important;
  padding:14px!important;
  border:1px solid #d7e1ef!important;
  border-radius:14px!important;
  background:linear-gradient(180deg,#f8fbff,#f2f6fc)!important;
}
.fbp-assessment-bottom-action .fbp-run-bottom{
  min-height:48px!important;
  padding:11px 20px!important;
  white-space:normal!important;
}
.fbp-assessment-bottom-action small{
  color:#65758d!important;
  line-height:1.45!important;
  font-size:12px!important;
}

/* Search result menus always sit over cards and are never clipped by a form section. */
.fbp-async-food-search,
.fbp-product-picker,
.fbp-food-search-wrap{overflow:visible!important}
.fbp-async-food-menu,
.fbp-saved-menu{z-index:2147482600!important}
.fbp-food-search-state,.fbp-saved-search-state{
  padding:14px!important;
  color:#64748b!important;
  font-weight:750!important;
  line-height:1.4!important;
}
.fbp-saved-menu .fbp-search-error,
.fbp-async-food-menu .fbp-search-error{color:#9f263b!important;background:#fff5f6!important;border-radius:9px!important}

@media (max-width:760px){
  /* The page itself must behave like a real phone UI: vertical scroll only. */
  html,
  body.fbp-guide-page{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow-x:hidden!important;
    overscroll-behavior-x:none!important;
  }
  body.fbp-guide-page{
    touch-action:pan-y pinch-zoom!important;
  }
  body.fbp-guide-page .fbp-app-shell,
  body.fbp-guide-page .fbp-workspace,
  body.fbp-guide-page .fbp-tool-view,
  body.fbp-guide-page .fbp-guide-main,
  body.fbp-guide-page .fbp-assessment-panel,
  body.fbp-guide-page .fbp-library-shell,
  body.fbp-guide-page .fbp-results-panel,
  body.fbp-guide-page .fbp-home-dashboard,
  body.fbp-guide-page .fbp-analysis-shell,
  body.fbp-guide-page .fbp-static-diagnostics{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin-left:0!important;
    margin-right:0!important;
    transform:none!important;
    translate:none!important;
    box-sizing:border-box!important;
    overflow-x:hidden!important;
  }
  body.fbp-guide-page .fbp-app-shell{padding-left:0!important;padding-right:0!important}

  /* Only purpose-built scientific tables/maps may own horizontal movement. */
  body.fbp-guide-page .fbp-table-wrap,
  body.fbp-guide-page .fbp-env-summary-table-wrap,
  body.fbp-guide-page .fbp-reg-table-wrap,
  body.fbp-guide-page .fbp-legal-table-wrap{
    max-width:100%!important;
    overflow-x:auto!important;
    -webkit-overflow-scrolling:touch!important;
    touch-action:pan-x pan-y!important;
    overscroll-behavior-inline:contain!important;
  }

  /* One-column scenario geometry. This explicitly wins over v0.18.3's later desktop rules. */
  .fbp-input-grid.main{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    width:100%!important;
    min-width:0!important;
    gap:12px!important;
  }
  .fbp-input-grid.main>*{grid-column:1!important;min-width:0!important;max-width:100%!important;width:100%!important}
  .fbp-form-section{min-width:0!important;max-width:100%!important;width:100%!important}
  .fbp-form-section>label,
  .fbp-food-hierarchy-search label{
    writing-mode:horizontal-tb!important;
    text-orientation:mixed!important;
    word-break:normal!important;
    overflow-wrap:normal!important;
    white-space:normal!important;
  }

  .fbp-food-hierarchy-search{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto!important;
    gap:8px!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    align-items:stretch!important;
  }
  .fbp-food-hierarchy-search>.fbp-food-category-field,
  .fbp-food-hierarchy-search>.fbp-food-product-field,
  .fbp-food-hierarchy-search>.fbp-search-with-clear,
  .fbp-food-hierarchy-search>.fbp-async-food-menu,
  .fbp-food-hierarchy-search>.fbp-food-search-help{
    grid-column:1!important;
    grid-row:auto!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    align-self:stretch!important;
  }
  .fbp-food-hierarchy-search>.fbp-food-category-field{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto auto!important;
    gap:5px!important;
  }
  .fbp-food-hierarchy-search select,
  .fbp-food-hierarchy-search input[type="search"],
  .fbp-product-picker input[type="search"],
  .fbp-product-name{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    box-sizing:border-box!important;
  }
  .fbp-food-hierarchy-search select{display:block!important}

  /* Native-feeling mobile result sheet above the on-screen keyboard. */
  .fbp-async-food-menu:not([hidden]),
  .fbp-saved-menu:not([hidden]){
    display:block!important;
    position:fixed!important;
    inset:auto!important;
    left:10px!important;
    right:10px!important;
    top:auto!important;
    bottom:calc(10px + env(safe-area-inset-bottom) + var(--fbp-mobile-keyboard-offset,0px))!important;
    width:auto!important;
    min-width:0!important;
    max-width:none!important;
    max-height:min(42dvh,360px)!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    padding:8px!important;
    border:1px solid #ced9e8!important;
    border-radius:18px!important;
    background:#fff!important;
    box-shadow:0 22px 70px rgba(13,32,75,.32)!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior:contain!important;
  }
  .fbp-async-food-menu button,
  .fbp-saved-menu button{
    min-height:54px!important;
    width:100%!important;
    padding:10px 12px!important;
    border-radius:10px!important;
    text-align:left!important;
  }
  .fbp-async-food-menu button span,
  .fbp-saved-menu button span,
  .fbp-saved-menu button b,
  .fbp-saved-menu button small{
    min-width:0!important;
    white-space:normal!important;
    overflow-wrap:anywhere!important;
  }

  .fbp-product-toolbar{padding:12px!important}
  .fbp-product-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .fbp-assessment-bottom-action{
    grid-template-columns:minmax(0,1fr)!important;
    gap:7px!important;
    padding:11px!important;
    margin-top:14px!important;
  }
  .fbp-assessment-bottom-action .fbp-run-bottom{width:100%!important;min-height:52px!important;font-size:15px!important}
  .fbp-assessment-bottom-action small{font-size:12px!important}
}

@media (max-width:380px){
  .fbp-product-actions{grid-template-columns:minmax(0,1fr)!important}
}
