/*
 * NextSure v69 — site-wide responsive hardening.
 * ------------------------------------------------------------
 * Purpose: make the existing UI behave consistently on phones, tablets,
 * laptops and desktops without changing business logic, rates or APIs.
 * Keep new device-specific layout fixes in this file so future edits remain
 * easy to find and maintain.
 */

:root{
  --ns69-page-pad:clamp(12px,2.2vw,28px);
  --ns69-card-gap:clamp(12px,1.8vw,20px);
  --ns69-control-h:46px;
}

html{width:100%;max-width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{width:100%;max-width:100%;margin:0;overflow-x:hidden}
*,*::before,*::after{box-sizing:border-box}
img,svg,video,canvas{max-width:100%;height:auto}
input,select,textarea,button{max-width:100%;min-width:0}
textarea{resize:vertical}

/* Generic content safety -------------------------------------------------- */
.container,.section,.header-inner,main,[class*="shell"],[class*="wrap"]{min-width:0}
.card,.panel,.modal,[class*="card"],[class*="panel"]{min-width:0}
.breakdown-table,.payment-table,.ns-user-table,.orders-table-wrap table{max-width:none}
.table-responsive,.table-wrap,.orders-table-wrap,.ns-user-table-wrap,.ns-bill-table-wrap,.ns-person-orders-table-wrap{
  width:100%;max-width:100%;overflow-x:auto!important;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
}

/* Do not let utility min-widths force normal cards/forms off-screen. */
@media(max-width:900px){
  .min-w-full:not(table){min-width:0!important}
  main:not(.invoice-sheet){max-width:100%!important}
  /* An older global rule hid every <aside> below 900px. Only the dashboard
     navigation should disappear; product summaries/profile panels must stack. */
  body:not(.ns-dashboard-page) aside{display:block!important;width:100%!important;max-width:100%!important}
}

/* Public header / navigation -------------------------------------------- */
@media(max-width:900px){
  .site-header .header-inner{width:100%;padding:10px 14px!important;gap:10px!important}
  .site-header .brand_logo,.site-header .brand{min-width:0!important}
  .site-header .brand_logo img{width:auto!important;max-width:132px!important;max-height:48px!important}
  .nav{max-width:100%;overflow-y:auto!important;overscroll-behavior:contain}
  .nav-list,.nav-list>li{max-width:100%}
  .nav-list a{white-space:normal!important;overflow-wrap:anywhere}
}
@media(max-width:520px){
  .site-header .header-inner{padding:9px 11px!important}
  .site-header .brand_logo img{max-width:116px!important}
}

/* Main public pages ------------------------------------------------------ */
@media(max-width:900px){
  .section,.ns-product-main,.ns-travel-shell,.ns-motor-shell,.ns-order-wrap,.ns-calc-page,.profile-shell{
    width:100%!important;max-width:100%!important;padding-left:var(--ns69-page-pad)!important;padding-right:var(--ns69-page-pad)!important;
  }
  .ns-wizard-panel,.ns-motor-panel,.ns-order-card,.premium-card,.profile-card,.auth-card{
    width:100%!important;max-width:100%!important;padding:clamp(14px,3vw,22px)!important;border-radius:clamp(16px,3vw,24px)!important;
  }
  .ns-form-grid,.ns-admin-grid,.ns-trip-grid,.ns-passport-manual-grid,.ns-feedback-grid,.contact_main{
    grid-template-columns:1fr!important;gap:12px!important;
  }
  .ns-panel-actions,.ns-motor-actions,.ns-form-actions,.action-row,.button-row{
    display:flex!important;flex-wrap:wrap!important;gap:9px!important;
  }
  .ns-panel-actions>*,.ns-motor-actions>*,.ns-form-actions>*{flex:1 1 160px;min-height:44px}
  input:not([type="checkbox"]):not([type="radio"]),select,textarea{width:100%;min-height:var(--ns69-control-h)}
}
@media(max-width:520px){
  .section,.ns-product-main,.ns-travel-shell,.ns-motor-shell,.ns-order-wrap,.ns-calc-page,.profile-shell{padding-left:11px!important;padding-right:11px!important}
  .ns-panel-actions>*,.ns-motor-actions>*,.ns-form-actions>*{flex-basis:100%}
}

/* Product cards ---------------------------------------------------------- */
@media(max-width:1100px) and (min-width:701px){
  #products .cards,.cards.product-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
@media(max-width:700px){
  #products .cards,.cards.product-grid{grid-template-columns:1fr!important;gap:14px!important}
  #products .card{min-height:0!important;height:auto!important;padding:20px!important}
  #products .card img{width:58px!important;height:58px!important;margin-bottom:16px!important}
  #products .card h3{font-size:22px!important}
  #products .card .btn-link{width:100%!important;justify-content:center!important;margin-top:14px!important}
}

/* Smart date widgets ----------------------------------------------------- */
@media(max-width:700px){
  .ns-date-picker-wrap{width:100%!important;max-width:100%!important}
  .ns-date-picker-selects{display:grid!important;grid-template-columns:minmax(72px,.75fr) minmax(110px,1fr) minmax(92px,.9fr)!important;gap:8px!important}
  .ns-date-picker-selects select{width:100%!important;min-width:0!important;padding-left:9px!important;padding-right:8px!important}
  .ns-date-picker-actions{display:flex!important;gap:8px!important;justify-content:flex-end!important;flex-wrap:wrap!important}
}
@media(max-width:370px){
  .ns-date-picker-selects{grid-template-columns:1fr 1fr!important}
  .ns-date-picker-selects select:last-child{grid-column:1/-1}
}

/* Dashboard responsive navigation -------------------------------------- */
/* The old CSS hid the desktop sidebar at 900px while Tailwind hid the
   mobile menu from 768px upward, leaving 768–900px with no navigation.
   v69 uses one clean breakpoint: mobile/tablet nav below 901px. */
@media(max-width:900px){
  body.ns-dashboard-page{height:100dvh!important;min-height:100dvh!important;overflow:hidden!important}
  body.ns-dashboard-page .mobile-top.md\:hidden{display:flex!important;position:sticky;top:0;z-index:90;min-height:56px}
  body.ns-dashboard-page .desktop-side{display:none!important}
  body.ns-dashboard-page #mobileMenu.md\:hidden:not(.hidden){display:block!important}
  body.ns-dashboard-page #mobileMenu>div{width:min(86vw,320px)!important;max-width:100%;height:100dvh!important;padding:18px!important}
  body.ns-dashboard-page .ns-dashboard-frame{height:calc(100dvh - 56px)!important;min-height:0!important;overflow:hidden!important}
  body.ns-dashboard-page .main-shell{
    height:100%!important;min-height:0!important;overflow:hidden!important;padding:10px!important;gap:10px!important;
  }
  body.ns-dashboard-page #dashboardHome,
  body.ns-dashboard-page #ordersView,
  body.ns-dashboard-page #billsView,
  body.ns-dashboard-page #peopleView,
  body.ns-dashboard-page #personOrdersView,
  body.ns-dashboard-page #systemReportsView,
  body.ns-dashboard-page #branchBillsView,
  body.ns-dashboard-page #claimsView{
    min-height:0!important;height:100%!important;max-height:100%!important;overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  }
  body.ns-dashboard-page .ns-dashboard-hero{padding:18px!important;border-radius:18px!important}
  body.ns-dashboard-page .ns-dashboard-hero h1{font-size:clamp(25px,7vw,34px)!important}
  body.ns-dashboard-page .ns-dashboard-actions{width:100%;display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important}
  body.ns-dashboard-page .ns-dashboard-actions>*{width:100%!important;justify-content:center!important}
}
@media(min-width:901px){
  body.ns-dashboard-page .desktop-side{display:flex!important}
  body.ns-dashboard-page .mobile-top{display:none!important}
}
@media(max-width:480px){
  body.ns-dashboard-page .main-shell{padding:7px!important;gap:7px!important}
  body.ns-dashboard-page .ns-dashboard-actions{grid-template-columns:1fr!important}
}

/* Dashboard cards and analytics ---------------------------------------- */
@media(max-width:900px){
  .ns-last-month-cards{grid-template-columns:1fr!important;gap:10px!important}
  .ns-metric-card{min-height:92px!important;padding:14px!important;border-radius:17px!important}
  .ns-metric-icon{width:46px!important;height:46px!important;border-radius:14px!important}
  .ns-standard-chart-grid{grid-template-columns:1fr!important}
  .ns-chart-summary-row{grid-template-columns:1fr 1fr!important;gap:8px!important}
  .ns-analytics-heading{flex-direction:column!important;align-items:stretch!important;gap:10px!important}
  .ns-analytics-controls{width:100%;display:flex!important;flex-wrap:wrap!important;gap:8px!important}
  .ns-standard-svg{min-width:560px!important}
}
@media(max-width:430px){
  .ns-chart-summary-row{grid-template-columns:1fr!important}
}

/* Partner Management: Agency / Agent / Branch Admin --------------------- */
#peopleView{scrollbar-gutter:stable both-edges}
@media(max-width:900px){
  #peopleView{padding:0 2px 88px!important;overflow-y:auto!important;overflow-x:hidden!important}
  #peopleView .ns-management-toolbar{
    position:sticky!important;top:0!important;z-index:25!important;display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;
    margin:0!important;padding:8px 4px 10px!important;background:#eef6fb!important;
  }
  #peopleView .ns-management-search-only{grid-column:1/-1!important;width:100%!important;min-height:48px!important;margin:0!important}
  #peopleView .ns-management-search-only .ns-people-search{min-height:48px!important;font-size:14px!important;padding:11px 13px 11px 42px!important}
  #peopleView .ns-management-toolbar .ns-people-search-btn,
  #peopleView .ns-management-toolbar .ns-people-clear-btn{width:100%!important;height:46px!important;min-height:46px!important;padding:0 12px!important;border-radius:12px!important}

  #peopleGrid.ns-people-grid{display:grid!important;grid-template-columns:1fr!important;gap:12px!important;width:100%!important;height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important;padding:2px 2px 14px!important}
  #peopleGrid .ns-agency-card.ns-agency-directory-card{
    width:100%!important;min-width:0!important;min-height:0!important;height:auto!important;margin:0!important;padding:16px 14px 15px 18px!important;gap:12px!important;overflow:hidden!important;border-radius:18px!important;
  }
  #peopleGrid .ns-directory-head{display:flex!important;flex-wrap:wrap!important;align-items:flex-start!important;gap:9px 10px!important;min-height:0!important}
  #peopleGrid .ns-agency-identity{width:100%!important;display:grid!important;grid-template-columns:48px minmax(0,1fr)!important;gap:10px!important;align-items:start!important}
  #peopleGrid .ns-agency-avatar{width:48px!important;height:48px!important;min-width:48px!important;border-radius:14px!important}
  #peopleGrid .ns-agency-title h3{font-size:18px!important;line-height:1.25!important;margin:2px 0 3px!important;overflow-wrap:anywhere!important}
  #peopleGrid .ns-agency-title p{font-size:12px!important;line-height:1.4!important;overflow-wrap:anywhere!important}
  #peopleGrid .ns-agency-code{margin:0 0 0 58px!important;padding:7px 11px!important;font-size:11px!important;max-width:calc(100% - 58px)!important;overflow-wrap:anywhere!important}
  #peopleGrid .ns-agency-directory-meta{grid-template-columns:1fr 1fr!important;gap:8px!important;margin:0!important;padding:9px!important;border-radius:12px!important}
  #peopleGrid .ns-agency-directory-meta span{padding:8px!important;font-size:11px!important;border-radius:10px!important}
  #peopleGrid .ns-agency-stats{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;margin:0!important}
  #peopleGrid .ns-agency-stat{min-height:62px!important;padding:9px!important;border-radius:11px!important}
  #peopleGrid .ns-agency-stat span{font-size:10px!important}
  #peopleGrid .ns-agency-stat b{font-size:14px!important}
  #peopleGrid .ns-agency-open-btn{min-height:46px!important;padding:10px 12px!important;font-size:13px!important;border-radius:12px!important;margin-top:0!important}
  .ns-people-pagination{
    position:sticky!important;bottom:0!important;z-index:24!important;width:100%!important;margin-top:4px!important;padding:9px 6px!important;
    justify-content:center!important;text-align:center!important;background:rgba(238,246,251,.97)!important;border-top:1px solid #d7e5ed!important;backdrop-filter:blur(8px);
  }
  .ns-people-pagination>span{width:100%!important;font-size:11px!important}
  .ns-people-pagination>div{justify-content:center!important;gap:5px!important}
  .ns-people-pagination button{min-width:36px!important;height:36px!important;padding:0 9px!important;border-radius:9px!important;font-size:12px!important}
}
@media(max-width:390px){
  #peopleGrid .ns-agency-directory-meta{grid-template-columns:1fr!important}
  #peopleGrid .ns-agency-code{margin-left:0!important;max-width:100%!important}
}

/* Partner account / billing view --------------------------------------- */
@media(max-width:900px){
  .ns-person-orders-header{padding:14px!important;border-radius:18px!important}
  .ns-person-orders-heading{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:12px!important}
  .ns-person-summary-grid,.ns-person-summary-grid-v54{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;width:100%!important}
  .ns-person-order-actions{display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;width:100%!important}
  .ns-person-order-actions>*{width:100%!important;min-height:44px!important;white-space:normal!important}
  .ns-person-orders-table-wrap{overflow:auto!important;max-height:none!important}
}
@media(max-width:480px){
  .ns-person-summary-grid,.ns-person-summary-grid-v54{grid-template-columns:1fr 1fr!important}
  .ns-person-order-actions{grid-template-columns:1fr!important}
}

/* Orders / bills / permission tables ----------------------------------- */
@media(max-width:900px){
  .orders-searchbar{grid-template-columns:1fr 1fr!important;gap:8px!important}
  .orders-searchbar input,.orders-searchbar select,.orders-searchbar button{width:100%!important;min-width:0!important}
  .orders-pagination{position:sticky;bottom:0;z-index:10;gap:5px!important;padding:8px!important}
  #billsView table,#branchBillsView table,.ns-user-table{min-width:900px!important}
  .ns-permission-shell,.ns-permission-main{width:100%!important;max-width:100%!important;padding:12px!important}
  .ns-create-card{width:100%!important;max-width:100%!important}
}
@media(max-width:520px){
  .orders-searchbar{grid-template-columns:1fr!important}
}

/* Invoice / bill detail ------------------------------------------------- */
@media(max-width:720px){
  .invoice-sheet{width:100%!important;max-width:100%!important;margin:0!important;padding:12px!important;border-radius:0!important}
  .invoice-sheet .section{padding:12px!important}
  .invoice-sheet .breakdown-table,.invoice-sheet .payment-table{min-width:760px}
  .invoice-sheet .order-breakdown,.invoice-sheet .bank-section{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
}

/* Dialogs / overlays ---------------------------------------------------- */
@media(max-width:640px){
  .ns-dialog,.ns-feedback-modal,.ns-modal,.modal-content{width:calc(100vw - 22px)!important;max-width:calc(100vw - 22px)!important;max-height:calc(100dvh - 28px)!important;overflow:auto!important;border-radius:18px!important;padding:16px!important}
  .ns-feedback-overlay,.modal-overlay{padding:11px!important}
}

/* Floating WhatsApp / AI / feedback controls: keep content readable. */
@media(max-width:640px){
  .ns-wa-float{right:10px!important;bottom:112px!important;width:50px!important;height:50px!important}
  .ns-ai-assistant{right:10px!important;bottom:10px!important}
  .ns-ai-fab{width:50px!important;height:50px!important;font-size:16px!important;border-width:3px!important}
  .ns-ai-panel{right:0!important;bottom:60px!important;width:calc(100vw - 20px)!important;max-width:390px!important;height:min(70dvh,560px)!important;max-height:70dvh!important}
  .ns-feedback-float{right:10px!important;bottom:170px!important;padding:9px 11px!important;font-size:12px!important}
  body{padding-bottom:max(0px,env(safe-area-inset-bottom))}
}

/* Small landscape phones: save vertical space. */
@media(max-height:520px) and (max-width:900px){
  body.ns-dashboard-page .mobile-top.md\:hidden{min-height:48px;padding:8px 10px!important}
  body.ns-dashboard-page .ns-dashboard-frame{height:calc(100dvh - 48px)!important}
  body.ns-dashboard-page .main-shell{height:100%!important}
  #peopleView .ns-management-toolbar{position:static!important}
  .ns-ai-panel{height:78dvh!important;max-height:78dvh!important}
}
