/* ════════════════════════════════════════════════════════════
   MOBILE LAYER — loaded on every page after the main styles.
   Dashboard drawer, stacked tables, touch ergonomics, homepage
   helpers. Desktop (≥992px) is untouched.
   ════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════
   ०. आडवा scroll पूर्णपणे बंद — फोनवर पान कधीही बाजूला सरकू नये.
   कारण: AOS अ‍ॅनिमेशन (data-aos="fade-left") सुरू होण्यापूर्वी घटक
   translate(100px) वर बसतात; अ‍ॅनिमेशन ट्रिगर होईपर्यंत पान १००px
   रुंद होते व बोटाने बाजूला सरकते. body वर आधीच hidden होते, पण
   <html> वर नव्हते — म्हणून scroll तिथेच होत होता.
   `clip` वापरतो कारण `hidden` position:sticky तोडते.
   ════════════════════════════════════════════════════════════ */
html{ overflow-x:hidden; }          /* जुन्या ब्राउझरसाठी fallback */
@supports (overflow-x: clip){
  html{ overflow-x:clip; }          /* sticky headers शाबूत ठेवते */
}
body{ overflow-x:clip; max-width:100%; }
/* AOS घटक कधीही viewport बाहेर डोकावू नयेत */
[data-aos^="fade-left"], [data-aos^="fade-right"]{ will-change:transform; }

/* ── Back-to-top (all sizes, shows after scrolling) ── */
#mtTopBtn{
  position:fixed; right:16px; bottom:86px; z-index:1200;
  width:44px; height:44px; border-radius:50%; border:none; cursor:pointer;
  background:#0a1f5c; color:#fff; font-size:18px;
  box-shadow:0 6px 18px rgba(8,26,82,.45);
  opacity:0; visibility:hidden; transition:.25s;
}
#mtTopBtn.show{ opacity:1; visibility:visible; }

/* ── Desktop: mobile-only drawer controls off ──
   mobile.js body-appends #mtSbToggle + #mtSbBackdrop on dashboard pages.
   Without a base rule they render as in-flow default elements below the
   footer (white strip + stray hamburger). Hide on desktop; the mobile
   media-query below turns them back on. ── */
#mtSbToggle, #mtSbBackdrop{ display:none; }

/* ── Collapsible sections (mobile accordions) ── */
.m-collapse-btn{ display:none; }
@media (max-width: 991.98px){
  .m-collapse-btn{
    display:flex; align-items:center; justify-content:space-between; width:100%;
    background:#fff; border:1.5px solid #dbe1f0; border-radius:12px;
    padding:13px 16px; font-weight:700; color:#0a1f5c; font-size:15px; cursor:pointer;
  }
  .m-collapse-btn .chev{ transition:.25s; color:#e8681a; }
  .m-collapse-btn.open .chev{ transform:rotate(180deg); }
  .m-collapse-body{ display:none; margin-top:14px; }
  .m-collapse-body.open{ display:block; }
}
@media (min-width: 992px){ .m-collapse-body{ display:block !important; } }

@media (max-width: 991.98px){

  /* ── Fix horizontal overflow: .row.g-5 gutters (−24px) exceed the
        mobile container padding (12px), widening the page past the
        viewport and clipping text at the right edge ── */
  .row.g-5{ --bs-gutter-x: 1.5rem; }

  /* ── Touch ergonomics ─────────────────────────────────── */
  input.form-control-custom, select.form-control-custom, textarea.form-control-custom,
  .fc, .form-control, .form-select { font-size:16px !important; }   /* stops iOS zoom-on-focus */
  .btn-primary-custom, .btn-navy { min-height:46px; }
  input[type="radio"], input[type="checkbox"]{ width:20px; height:20px; }

  /* ── DASHBOARD SIDEBAR → slide-in drawer ──────────────── */
  .dashboard-wrapper .sidebar{
    display:block !important;
    position:fixed; top:0; left:0; bottom:0; z-index:2050;
    width:82%; max-width:320px; min-height:100vh;
    transform:translateX(-100%); transition:transform .3s cubic-bezier(.4,0,.2,1);
    overflow-y:auto; box-shadow:8px 0 40px rgba(0,0,0,.55);
  }
  .dashboard-wrapper .sidebar.open{ transform:translateX(0); }
  #mtSbToggle{
    display:flex; align-items:center; justify-content:center;
    position:fixed; left:12px; bottom:16px; z-index:2040;
    width:52px; height:52px; border-radius:50%; border:none; cursor:pointer;
    background:linear-gradient(135deg,#e8681a,#c2520e); color:#fff; font-size:20px;
    box-shadow:0 8px 22px rgba(232,104,26,.55);
  }
  #mtSbBackdrop{
    display:block;
    position:fixed; inset:0; background:rgba(3,8,30,.55); z-index:2045;
    opacity:0; visibility:hidden; transition:opacity .3s;
  }
  #mtSbBackdrop.show{ opacity:1; visibility:visible; }
  body.mt-sb-locked{ overflow:hidden; }

  /* ── STACKED TABLES (.stack-mobile) — each row becomes a card ── */
  table.stack-mobile{ min-width:0 !important; }
  table.stack-mobile thead{ display:none; }
  table.stack-mobile, table.stack-mobile tbody{ display:block; width:100%; }
  table.stack-mobile tr{
    display:block; background:#fff; border:1.5px solid #dbe1f0; border-radius:12px;
    margin:0 0 12px; padding:10px 12px; box-shadow:0 2px 8px rgba(8,26,82,.06);
  }
  table.stack-mobile td{
    display:block; width:100% !important; min-width:0 !important;
    border:none !important; padding:7px 2px !important; text-align:left !important;
  }
  table.stack-mobile td[data-label]::before{
    content:attr(data-label);
    display:block; font-size:11.5px; font-weight:700; color:#64748b;
    text-transform:none; margin-bottom:3px;
  }
  table.stack-mobile td:empty{ display:none; }

  /* ── File inputs: preview thumbnails ── */
  .mt-file-preview{ display:flex; align-items:center; gap:8px; margin-top:6px; font-size:12px; color:#16a34a; }
  .mt-file-preview img{ width:44px; height:44px; object-fit:cover; border-radius:8px; border:1px solid #dbe1f0; }

  /* ── Homepage helpers ─────────────────────────────────── */
  /* quick actions under hero */
  .mt-quick{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; padding:14px 14px 4px; }
  .mt-quick a{
    display:flex; flex-direction:column; align-items:center; gap:6px;
    background:#fff; border:1.5px solid #dbe1f0; border-radius:14px;
    padding:14px 6px; text-decoration:none; color:#0a1f5c; font-weight:700; font-size:12.5px;
    box-shadow:0 2px 10px rgba(8,26,82,.07);
  }
  .mt-quick a i{ font-size:20px; color:#e8681a; }
  /* section chips */
  .sec-chips{ display:flex; gap:8px; overflow-x:auto; padding:10px 14px 12px; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .sec-chips::-webkit-scrollbar{ display:none; }
  .sec-chips a{
    flex-shrink:0; background:#eef2ff; color:#0a1f5c; border-radius:20px;
    padding:8px 15px; font-size:13px; font-weight:600; text-decoration:none; white-space:nowrap;
  }
  /* sticky register FAB */
  #mtRegFab{
    position:fixed; right:16px; bottom:16px; z-index:1200;
    display:inline-flex; align-items:center; gap:8px;
    background:linear-gradient(135deg,#e8681a,#c2520e); color:#fff;
    border-radius:30px; padding:13px 20px; font-weight:800; font-size:14.5px;
    text-decoration:none; box-shadow:0 10px 26px rgba(232,104,26,.55);
  }
  /* compact countdown: hide year/month/second boxes on phones */
  #cdbox_y, #cdbox_mo, #cdbox_s{ display:none !important; }
  /* hide extra news beyond first 3 until "more" tapped */
  .news-extra{ display:none; }
  body.show-all-news .news-extra{ display:block; }
}

@media (min-width: 992px){
  .mt-quick, .sec-chips, #mtRegFab, #newsMoreBtn{ display:none !important; }
}

/* very small phones: subsidy info cards one per row */
@media (max-width: 420px){
  .subsidy-row > .col-6{ width:100%; }
}

/* ════════════════════════════════════════════════════════════
   स्पर्श-अनुकूलता (touch ergonomics) — फोन व PWA
   Apple/Google शिफारस: प्रत्येक टॅप-लक्ष्य किमान ४४×४४ px.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px){

  /* तळटीपेतील व यादीतील दुवे — बोटाला नीट लागावेत */
  footer a, .footer-bottom a, footer li > a{
    display:inline-block; min-height:44px; line-height:44px; padding:0 2px;
  }
  footer li{ margin-bottom:0 !important; }

  /* बटणे, इनपुट, select — किमान उंची + iOS zoom टाळण्यासाठी १६px मजकूर */
  .btn, .btn-navy, .btn-primary-custom, button, input[type=submit], input[type=button]{
    min-height:44px;
  }
  input:not([type=checkbox]):not([type=radio]), select, textarea,
  .form-control, .form-control-custom, .fc, .fc2, .kpa-fc, .ga-fc{
    min-height:44px; font-size:16px;      /* <16px असल्यास iOS आपोआप zoom करते */
  }
  input[type=checkbox], input[type=radio]{ width:20px; height:20px; }

  /* पान-क्रमांक, चिप्स, लहान action-बटणे */
  .sbtn, .btn2, .kpa-btn, .btn-sm, .pagination a, .pagination span{
    min-height:40px; display:inline-flex; align-items:center; justify-content:center;
  }

  /* सारण्या — नेहमी स्वतःच्या चौकटीत आडवे सरकाव्यात, पान नाही */
  .table-responsive, .dashboard-content table{ -webkit-overflow-scrolling:touch; }
  .dashboard-content table{ min-width:0; }

  /* डॅशबोर्ड सारांश-कार्डे — फोनवर २ प्रति ओळ, बोटाला मोठी */
  .dsc{ padding:14px 8px !important; }
  .dsc .dsc-go{ opacity:1 !important; }   /* फोनवर hover नसतो — नेहमी दाखवा */

  /* मान्यवर कार्डे — पूर्ण रुंदी */
  .kp-grid{ grid-template-columns:1fr !important; }
  .kp-card{ max-width:100% !important; }

  /* लॉगआउट-पूर्व प्रलंबित कामे — बटणे पूर्ण रुंद */
  .lo-btn{ min-width:100% !important; }
  .lo-t{ flex-wrap:wrap; }
  .lo-go{ width:100%; text-align:right; }

  /* वर्ष-वेळापत्रक व इतर रुंद फॉर्म — रकाने खाली-खाली */
  .ymform .row > [class*="col-"]{ margin-bottom:6px; }
}

/* ── PWA (standalone) — नोच / होम-बार साठी सुरक्षित जागा ──
   ⚠️ -webkit-touch-callout:none body वर लावू नये — iOS/Android standalone
   विंडोत हे touch-scroll gesture ओळखण्यात अडथळा आणू शकते (ज्ञात दोष).
   फक्त safe-area padding — हे पूर्णपणे सुरक्षित, scroll-निरपेक्ष आहे. */
@media (display-mode: standalone){
  body{
    padding-top:env(safe-area-inset-top);
    padding-bottom:env(safe-area-inset-bottom);
  }
  #mtTopBtn{ bottom:calc(86px + env(safe-area-inset-bottom)); }
}

/* ── अतिशय लहान फोन (≤360px) ── */
@media (max-width: 360px){
  .dashboard-content{ padding-left:10px !important; padding-right:10px !important; }
  .st-cd-u{ min-width:40px; padding:5px 5px; }
  .st-cd-n{ font-size:15px; }
}
