/* Nabdi v1.15.1 — prescription field sizing + universal back navigation */

/* ---------- Prescription grid: give medication the intended width ---------- */
.rx-smart-form .rx-grid .span-5{grid-column:span 5}
.rx-smart-form .rx-grid .rx-medication{min-width:0}
.rx-smart-form .rx-grid .rx-medication .field-with-action{width:100%;min-width:0}
.rx-smart-form .rx-grid .rx-medication .search-select{min-width:260px}
.rx-smart-form .rx-grid .rx-medication .search-select-input{font-weight:700;color:#183149}

/* Keep chevron/clear buttons outside the selected text area. */
.search-select-input{
  padding-inline-start:14px!important;
  padding-inline-end:74px!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  white-space:nowrap!important;
}
.search-select-chevron{inset-inline-end:6px!important;inset-inline-start:auto!important;left:auto!important;right:auto!important}
.search-select-clear{inset-inline-end:36px!important;inset-inline-start:auto!important;left:auto!important;right:auto!important}
.search-select-box{min-width:0}
.search-select-menu{min-width:100%;width:max-content;max-width:min(460px,calc(100vw - 28px))}
.rx-medication .search-select-menu{min-width:min(360px,calc(100vw - 28px))}

/* Quick-add always owns its space and cannot slide below/behind the searchable text. */
.rx-smart-form .field-with-action{display:flex!important;align-items:stretch!important;min-width:0}
.rx-smart-form .field-with-action>.search-select{flex:1 1 auto!important;min-width:0}
.rx-smart-form .field-with-action>.quick-add-btn{position:relative!important;z-index:3;flex:0 0 46px!important;width:46px!important;min-width:46px!important;margin:0!important}

/* ---------- Universal back navigation ---------- */
.topbar-nav-actions{display:flex;align-items:center;flex:0 0 auto}
.app-back-button{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:42px;padding:8px 11px;
  border:1px solid #dfe7ec;background:#fff;color:#294155;border-radius:12px;font-weight:800;
  transition:background .16s ease,border-color .16s ease,color .16s ease,transform .16s ease,box-shadow .16s ease
}
.app-back-button:hover{background:#f1faf8;border-color:#bfe5df;color:#087f75;box-shadow:0 5px 14px rgba(11,31,51,.06)}
.app-back-button:active{transform:scale(.97)}
.app-back-button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.mobile-back-button{display:none}
body[data-route-dashboard="1"] .app-back-button{display:none!important}

/* A slightly more balanced desktop header after adding Back. */
@media(min-width:901px){
  .topbar{justify-content:flex-start!important}
  .topbar-nav-actions{order:1}
  .topbar-search{order:2;margin-inline:auto!important}
  .user-chip{order:3}
}

@media(max-width:1200px) and (min-width:901px){
  .rx-smart-form .rx-grid .span-5{grid-column:span 6}
  .rx-smart-form .rx-grid .rx-medication .search-select{min-width:220px}
}

@media(max-width:900px){
  .topbar-nav-actions{display:none!important}
  .mobile-toolbar{grid-template-columns:44px 44px 1fr 44px!important}
  .mobile-back-button{display:grid;width:44px;height:44px;min-height:44px;padding:11px;border-radius:12px;background:#f3f7f8;border-color:#e1e8ec;color:var(--brand-dark)}
  .mobile-back-button span{display:none}
  .rx-smart-form .rx-grid .span-5,.rx-smart-form .rx-grid .rx-medication{grid-column:1!important}
  .rx-smart-form .rx-grid .rx-medication .search-select{min-width:0;width:100%}
  .search-select-menu{width:100%;min-width:100%;max-width:100%}
}

@media(max-width:600px){
  .mobile-toolbar{grid-template-columns:42px 42px 1fr 42px!important;gap:6px!important}
  .mobile-back-button{width:42px;height:42px;min-height:42px}
  .rx-smart-form .field-with-action>.quick-add-btn{flex-basis:44px!important;width:44px!important;min-width:44px!important}
}

@media print{
  .app-back-button,.topbar-nav-actions{display:none!important}
}
