/* ==========================================================================
   agna-responsive.css  —  GoCloud RIS mobile/tablet responsive hardening
   COSMETIC CSS ONLY. Layers AFTER main bundle + theme-*.css + agna-bg.js styles.
   All rules are scoped to small viewports (<=768px / <=480px) so desktop is
   untouched. Fully reversible: delete this file + its <link> in index.html.
   Owner: responsive pass 2026-11-16. Do not add logic/colours/branding here.
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. GLOBAL ANTI-OVERFLOW GUARD (phones + small tablets)
   Stops the document body from scrolling sideways. Wide children get their
   own inner scroll via the rules below, so nothing is lost — it just can't
   push the whole page wider than the screen.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }
  /* antd flex layout: let content shrink instead of forcing body wider */
  .ant-layout,
  .ant-layout-content,
  .ant-layout-has-sider {
    min-width: 0;
  }
  .ant-layout-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* -------------------------------------------------------------------------
   2. TABLES — give wide tables a horizontal scroll container.
   The bundle sets .ant-table-wrapper{max-width:100%} but no overflow, so a
   table with many columns overflows the page. Scroll it instead.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ant-table-wrapper,
  .ant-table-content,
  .ant-table-body,
  .ant-table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  /* keep cell text from exploding row height; headers stay on one line */
  .ant-table-thead > tr > th {
    white-space: nowrap;
  }
}

/* -------------------------------------------------------------------------
   3. FIXED MIN-WIDTH UTILITY CLASSES
   The bundle ships .minw450 .. .minw950 and .min-w-[740px] with
   min-width:<n>px!important. On phones these force horizontal overflow
   (e.g. a 740px modal body on a 390px screen). Release the floor on small
   screens; inner tables still scroll via rule #2.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .minw450, .minw500, .minw550, .minw600, .minw650, .minw700,
  .minw750, .minw800, .minw850, .minw900, .minw950,
  .min-w-\[740px\], .min-w-\[700px\], .min-w-\[600px\], .min-w-\[500px\] {
    min-width: 0 !important;
  }
}

/* -------------------------------------------------------------------------
   4. MODALS — full-ish width on phones so they never exceed the viewport.
   antd already caps max-width:calc(100vw - 16px); reinforce + tighten
   margins so the dialog uses the screen on small devices.
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .ant-modal {
    max-width: 100vw !important;
    margin: 8px auto !important;
    top: 8px !important;
    padding-bottom: 8px !important;
  }
  .ant-modal-content {
    border-radius: 10px;
  }
  .ant-modal-body {
    max-height: 72vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* -------------------------------------------------------------------------
   5. DRAWERS — never wider than the screen; leave an edge to dismiss.
   antd sets the drawer width via inline style (often 378px). Cap it so it
   can't exceed the viewport on narrow phones.
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .ant-drawer-content-wrapper {
    max-width: 100vw !important;
  }
  .ant-drawer-left .ant-drawer-content-wrapper,
  .ant-drawer-right .ant-drawer-content-wrapper {
    max-width: 92vw !important;
  }
  .ant-drawer-top .ant-drawer-content-wrapper,
  .ant-drawer-bottom .ant-drawer-content-wrapper {
    max-height: 85vh;
  }
}

/* -------------------------------------------------------------------------
   6. GRIDS — stack unguarded multi-column tailwind grids on small screens.
   Only affects elements whose base class is a bare .grid-cols-N (no
   responsive prefix); responsive grids already collapse on their own.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .grid-cols-4, .grid-cols-5, .grid-cols-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 480px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4,
  .grid-cols-5, .grid-cols-6 {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* -------------------------------------------------------------------------
   7. antd Row/Col — let columns wrap and shrink (antd Row wraps by default,
   this just guarantees no column forces overflow).
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .ant-row {
    row-gap: 8px;
  }
  .ant-col {
    min-width: 0;
  }
}

/* -------------------------------------------------------------------------
   8. TAP TARGETS — comfortable touch sizes on phones/tablets.
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .ant-btn {
    min-height: 40px;
  }
  .ant-menu-item,
  .ant-menu-submenu-title {
    min-height: 44px;
    line-height: 44px;
  }
  .ant-pagination-item,
  .ant-pagination-prev,
  .ant-pagination-next {
    min-width: 36px;
    min-height: 36px;
    line-height: 34px;
  }
  /* tabs / pagination scroll instead of overflowing */
  .ant-pagination {
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* -------------------------------------------------------------------------
   9. LOGIN PAGE — the login card already fits; this is a belt-and-braces
   guard so inputs/button stay full width and comfortably tappable on the
   smallest phones, and nothing overflows the auth container.
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .ant-input,
  .ant-input-affix-wrapper,
  .ant-input-password {
    min-height: 40px;
  }
  /* guard any form card that uses a fixed pixel width from exceeding screen */
  form, .ant-form {
    max-width: 100%;
  }
}

/* -------------------------------------------------------------------------
   10. THEME SWITCHER (🎨) — keep its pop-up menu inside the viewport on
   phones so it never causes sideways scroll. (Position of the FAB itself is
   left as-is: bottom-right, 44px, already a good tap target.)
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  #agna-theme-switch .agna-theme-menu {
    max-width: 78vw;
  }
}

/* Remove the floating AI-icon tool (owner request 16 Nov 2026) — global */
:is(button,a,div,span):has(> img[src="aiicon.png"]){display:none!important}
:has(> img[src="aiicon.png"]){display:none!important}
img[src="aiicon.png"]{display:none!important}
