/* TERM-FIN Header Layout Fix V1
   Prevents the search box from colliding with cart/account/logout actions.
*/

.topbar,
.topbar *{
  box-sizing:border-box;
}

@media (min-width:901px){
  .topbar{
    display:flex!important;
    align-items:center!important;
    gap:12px!important;
    min-width:0!important;
    padding-left:16px!important;
    padding-right:16px!important;
  }

  .topbar > *{
    min-width:0;
  }

  .top-search{
    flex:1 1 360px!important;
    width:auto!important;
    max-width:none!important;
    min-width:160px!important;
  }

  .top-search input{
    width:100%!important;
    min-width:0!important;
  }

  .top-actions{
    flex:0 0 auto!important;
    min-width:0!important;
    max-width:58%!important;
    gap:5px!important;
    white-space:nowrap!important;
  }

  .top-actions > a,
  .top-actions > button{
    flex:0 0 auto!important;
    min-width:0!important;
  }

  .top-actions .gold-btn,
  .top-actions .outline-btn{
    padding-left:13px!important;
    padding-right:13px!important;
  }

  .top-actions .gold-btn span{
    display:block;
    max-width:115px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
  }

  .top-actions .tf-logout-btn{
    min-width:86px;
  }
}

@media (min-width:901px) and (max-width:1240px){
  .top-actions > a:not(.gold-btn):not(.outline-btn) span{
    display:none!important;
  }

  .top-actions > a:not(.gold-btn):not(.outline-btn){
    width:38px!important;
    height:38px!important;
    padding:0!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
  }

  .top-actions > a:not(.gold-btn):not(.outline-btn) i{
    margin:0!important;
  }

  .top-actions .gold-btn{
    padding-left:11px!important;
    padding-right:11px!important;
  }

  .top-actions .outline-btn{
    padding-left:11px!important;
    padding-right:11px!important;
  }
}

@media (min-width:901px) and (max-width:1060px){
  .top-actions .gold-btn span,
  .top-actions .tf-auth-trigger span,
  .top-actions .tf-logout-btn span{
    display:none!important;
  }

  .top-actions .gold-btn,
  .top-actions .tf-auth-trigger,
  .top-actions .tf-logout-btn{
    width:40px!important;
    padding:0!important;
  }

  .top-actions .gold-btn i,
  .top-actions .tf-auth-trigger i,
  .top-actions .tf-logout-btn i{
    margin:0!important;
  }

  .top-actions{
    max-width:52%!important;
  }
}

@media (max-width:900px){
  .top-search{
    width:100%!important;
    min-width:0!important;
  }

  .top-search input{
    width:100%!important;
    min-width:0!important;
  }
}

/* V2: hard-stop header search collisions */
.top-search{overflow:hidden!important;isolation:isolate!important}
.top-search input{display:block!important;min-width:0!important;max-width:100%!important;margin:0!important}
.top-search button{position:relative!important;z-index:2!important;flex:none!important}
@media (max-width:560px){
  .topbar{gap:7px!important}
  .top-search{height:42px!important;grid-template-columns:minmax(0,1fr) 42px!important}
  .top-search input{padding-left:13px!important;padding-right:7px!important;font-size:11px!important}
  .top-search button{width:42px!important;min-width:42px!important;padding:0!important}
  .hero-search{position:relative!important;z-index:7!important;overflow:hidden!important;grid-template-columns:34px minmax(0,1fr) 78px!important}
  .hero-search input{width:100%!important;min-width:0!important;margin:0!important;padding:0 4px!important}
  .hero-search button{width:78px!important;min-width:78px!important;padding:0 9px!important}
}

/* TERM-FIN V4.1: mobile account access */
.tf-mobile-account-direct{
  text-decoration:none;
}
.tf-mobile-account-direct span{
  display:none;
}
.tf-account-user-link{
  text-decoration:none;
  color:inherit;
}
.tf-account-user-link > .bi-chevron-right{
  margin-left:auto;
  color:#b77a0d;
  font-size:14px;
}
.tf-mobile-bottom-nav{
  display:none;
}

@media (max-width:900px){
  body{
    padding-bottom:calc(78px + env(safe-area-inset-bottom))!important;
  }

  .mobile-account.tf-mobile-account-direct{
    display:flex!important;
    width:44px;
    height:44px;
    padding:0;
    border:1px solid #ead29a;
    border-radius:14px;
    background:linear-gradient(180deg,#fffdf8,#fff4cf);
    align-items:center;
    justify-content:center;
    color:#9d6706;
    box-shadow:0 5px 14px rgba(148,94,7,.09);
  }
  .mobile-account.tf-mobile-account-direct i{
    font-size:23px;
  }

  .tf-mobile-bottom-nav{
    position:fixed;
    left:10px;
    right:10px;
    bottom:calc(8px + env(safe-area-inset-bottom));
    z-index:85;
    min-height:62px;
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    align-items:center;
    gap:4px;
    padding:6px;
    border:1px solid rgba(214,178,96,.45);
    border-radius:20px;
    background:rgba(255,253,248,.96);
    box-shadow:0 14px 38px rgba(78,49,5,.16);
    backdrop-filter:blur(16px);
    -webkit-backdrop-filter:blur(16px);
  }
  .tf-mobile-bottom-nav a,
  .tf-mobile-bottom-nav button{
    position:relative;
    min-width:0;
    height:50px;
    border:0;
    border-radius:15px;
    background:transparent;
    color:#826b49;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:2px;
    text-decoration:none;
    font:inherit;
    cursor:pointer;
  }
  .tf-mobile-bottom-nav i{
    margin:0!important;
    font-size:19px;
    line-height:1;
  }
  .tf-mobile-bottom-nav span{
    display:block;
    max-width:100%;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    font-size:9px;
    line-height:1.2;
    font-weight:700;
  }
  .tf-mobile-bottom-nav a.active,
  .tf-mobile-bottom-nav button.active{
    color:#6b4500;
    background:linear-gradient(180deg,#ffe88f,#f4c64c);
    box-shadow:0 5px 14px rgba(190,132,20,.15);
  }
  .tf-mobile-bottom-nav em{
    position:absolute;
    top:3px;
    left:calc(50% + 7px);
    min-width:17px;
    height:17px;
    padding:0 4px;
    display:grid;
    place-items:center;
    border-radius:999px;
    background:#d98c0c;
    color:#fff;
    font-size:8px;
    font-style:normal;
    font-weight:900;
    box-shadow:0 2px 7px rgba(149,88,0,.22);
  }

  /* Right drawer still works from links elsewhere, but Account is now one tap away. */
  .right-rail .tf-account-user-link{
    display:grid;
    grid-template-columns:42px minmax(0,1fr) 18px;
    align-items:center;
    gap:9px;
  }
}

@media (max-width:430px){
  .tf-mobile-bottom-nav{
    left:7px;
    right:7px;
    bottom:calc(6px + env(safe-area-inset-bottom));
    border-radius:18px;
  }
  .tf-mobile-bottom-nav span{font-size:8px}
}
