/* KarobarOS UI fixes (Jarvis) — loaded LAST so these win over older patch files.
   1) Plain popups become a centered, content-sized sheet instead of a
      full-screen takeover with content stuck at the top.
   2) Floating buttons form one clean stack — no overlaps.
   3) Header breathing room on small screens. */

/* ── 1) Popup sheet ─────────────────────────────── */
dialog#modal[open]{
  margin:auto;
  height:fit-content !important;
  max-height:92dvh !important;
  width:min(680px, calc(100vw - 20px)) !important;
  max-width:calc(100vw - 20px) !important;
  border-radius:18px;
  box-shadow:0 24px 80px rgba(0,0,0,.35);
}
@media (max-width:650px){
  dialog#modal[open]{
    width:calc(100vw - 16px) !important;
    max-width:calc(100vw - 16px) !important;
    max-height:94dvh !important;
  }
  /* Tall form sheets keep the app's full-height behaviour on mobile */
  dialog#modal.entry-sheet[open],
  dialog#modal.compact-edit-sheet[open]{
    height:var(--entry-viewport-height, 100dvh) !important;
    max-height:var(--entry-viewport-height, 100dvh) !important;
    width:100vw !important;
    max-width:100vw !important;
    border-radius:0;
  }
}

/* ── 2) Floating buttons — ONE chat button: the orange circle ──
   The circle (#faqChatButton) IS the Karobar AI button — it opens the
   AI assistant panel (assistant.js). The old #aiFab pill is gone.
   workspace-polish.css hides the circle off the home page; the
   :not() override below keeps it visible on every page (but never
   while the app is PIN-locked or a modal is open). */
@media (max-width:899px){
  /* Calculator already lives in the bottom nav — hide the shortcut */
  #calcShortcut{display:none !important}
  /* Circle sits where the AI pill used to be: above the bottom nav */
  #faqChatButton{bottom:calc(86px + env(safe-area-inset-bottom)); right:14px; z-index:40}
  body:not([data-page=home]):not(.workspace-locked):not(:has(#modal[open])) #faqChatButton{display:grid !important}
}
@media (min-width:900px){
  /* One vertical stack at right:20px, bottom → top, 14px gaps:
     Calculator pill ≈20–64 · Karobar AI chat circle 78–122.
     The [data-page=home] selector matches workspace-polish.css's
     home-page rule specificity; ui-fixes.css loads last, so these win. */
  body #calcShortcut, body[data-page=home] #calcShortcut{bottom:20px; right:20px; z-index:29}
  #faqChatButton{bottom:78px; right:20px; z-index:40}
  body:not([data-page=home]):not(.workspace-locked):not(:has(#modal[open])) #faqChatButton{display:grid !important}
}

/* ── 3) Header ──────────────────────────────────── */
#cloudButton{border-radius:20px; white-space:nowrap; flex:0 0 auto}
@media (max-width:650px){
  #cloudButton{min-width:44px; min-height:40px; padding:6px 10px}
}

/* ── 4) Small home polish ───────────────────────── */
@media (max-width:650px){
  .home-cash-card{margin:12px 0; padding:16px}
  .home-cash-card strong{font-size:24px}
}

/* ── 5) Bills: Counter Sale shortcut hamesha apni row mein ──
   pos.js ise heading ke baad lagata hai; yahan use in-flow,
   full-width row bana diya taake stats card ko kabhi na dhake. */
#posBillsShortcut{display:flex; align-items:center; justify-content:center; width:100%; min-height:46px; margin:0 0 12px; border-radius:12px; position:static}

/* ── 6) POS page par chat circle nahi ──
   Circle POS ki bottom total-bar ke dayein sire ko dhakta tha.
   Selector section 2 wale display:grid rule se zyada specific
   hai, is liye sirf POS page par jeetta hai. */
body[data-page="pos"]:not([data-page="home"]):not(.workspace-locked):not(:has(#modal[open])) #faqChatButton{display:none !important}
