/* =========================================================
   APP.CSS — SensiGrow base shell styles
   - Organized layout + hardened height chain
   - Fixes sidebar horizontal scroll (scroll-x)
   ========================================================= */


/* =========================================================
   1) ROOT / HEIGHT CHAIN
   Ensures 100% and 100vh layouts behave consistently in Dash.
   ========================================================= */

html, body {
  height: 100%;
  margin: 0;
}

/* Dash/React wrapper nodes differ by version; include all */
#react-entry-point,
#_dash-app-content,
#_dash-app-content > div {
  height: 100%;

  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27260%27%20height%3D%27140%27%20viewBox%3D%270%200%20260%20140%27%3E%3Ctext%20x%3D%2750%25%27%20y%3D%2750%25%27%20dominant-baseline%3D%27middle%27%20text-anchor%3D%27middle%27%20fill%3D%27%23177da5%27%20font-size%3D%2728%27%20fill-opacity%3D%270.16%27%20font-family%3D%27Segoe%20UI%2C%20Arial%2C%20sans-serif%27%20transform%3D%27rotate(-20%20130%2070)%27%3ESensiGrow%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 260px 140px;
  background-position: 0 0;
}

/* Prevent the browser window from scrolling (scrolling is internal) */
body {
  overflow: hidden;
}


/* =========================================================
   2) APP SHELL LAYOUT (Header + Sidebar + Main content)
   Matches base.py: #shell-view + .sg-shell-body + #page-content
   ========================================================= */

.sg-app-shell,
#shell-view,
#shell-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Sidebar + main content row fills remaining height under header */
.sg-shell-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;   /* critical for inner scroll areas */
  min-width: 0;    /* critical to prevent horizontal overflow */
}

/* Main content area to the right of the sidebar */
.sg-main-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;      /* CRITICAL: allow shrinking, prevents scroll-x issues */
  overflow: hidden;  /* content scroll happens inside #page-content */
  padding: 0.25rem;  /* matches your usage: p-1 in base.py */

  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27260%27%20height%3D%27140%27%20viewBox%3D%270%200%20260%20140%27%3E%3Ctext%20x%3D%2750%25%27%20y%3D%2750%25%27%20dominant-baseline%3D%27middle%27%20text-anchor%3D%27middle%27%20fill%3D%27%23177da5%27%20font-size%3D%2728%27%20fill-opacity%3D%270.16%27%20font-family%3D%27Segoe%20UI%2C%20Arial%2C%20sans-serif%27%20transform%3D%27rotate(-20%20130%2070)%27%3ESensiGrow%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 260px 140px;
  background-position: 0 0;
}

/* =========================================================
   PAGE CONTENT FRAME
   - #page-content itself is the "frame": no scrolling here
   - Wrappers inside fill height, but DO NOT force overflow:hidden
     (otherwise you kill inner scroll regions like plant_units_body)
   ========================================================= */

#page-content,
.sg-page-content {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;      /* ✅ only the frame hides overflow */
}

/* Dash sometimes inserts 1-2 wrapper divs.
   Make them flex-fill, but DO NOT set overflow here. */
/* #page-content > * {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  display: flex;
  flex-direction: column;
} */

/* Page-specific: irrigation page is a flex column frame */
/* #page-content .irrigation-recommendation-page {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  display: flex;
  flex-direction: column;
  overflow: hidden;
} */


/* Optional third wrapper (only if you actually see 3 levels in Elements) */
/* #page-content > * > * > * {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;

  display: flex;
  flex-direction: column;
} */




/* =========================================================
   3) HEADER / NAVBAR
   ========================================================= */

.sg-header-navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  padding-top: 0.05rem;
  padding-bottom: 0.05rem;
  border-bottom: 1px solid #bfc4cf;
}

.sg-header-navbar .sg-logo {
  max-height: 60px;
}

.sg-company-name {
  font-weight: bold;
  font-family: serif;
  font-size: 270%;
}

.sg-page-title {
  font-weight: 600;
  font-size: 1.3rem;
  text-transform: capitalize;
  font-style: italic;
  letter-spacing: 0.05em;
}

.sg-header-page-meta {
  display: flex;
  align-items: center;
  margin-left: 3rem;
  column-gap: 0.5rem;
}

/* Header actions */
.sg-global-actions-btn-group {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}

.sg-global-actions-row {
  display: flex;
  align-items: center;
  column-gap: 1rem;
  margin-left: 1rem;
}

.sg-plant-filter-dropdown {
  min-width: 220px;
  margin-bottom: 0;
}

/* Icon buttons */
.sg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
  min-width: 0;
  line-height: 1;
  font-size: 0;
  width: 24px;
  height: 24px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.sg-icon-btn:hover {
  transform: scale(1.06);
  filter: brightness(1.1);
  background-color: transparent !important;
  box-shadow: none;
}

.sg-icon {
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.sg-icon:hover {
  transform: scale(1.06);
  filter: brightness(1.1);
}


/* =========================================================
   4) SIDEBAR (FIX SCROLL-X HERE)
   Sidebar in base.py:
   id="sidebar-container", className="sg-sidebar"
   ========================================================= */

/* Expanded sidebar */
.sg-sidebar,
#sidebar-container {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);

  width: 260px;
  min-width: 260px;
  max-width: 260px;
  flex: 0 0 260px;    /* lock width in flex row */
  flex-shrink: 0;     /* never shrink (prevents width change) */

  height: 100%;
  overflow-y: auto;
  overflow-x: hidden; /* ✅ key fix: never allow horizontal scroll */

  border-right: 1px solid #bfc4cf;
}

/* Collapsed sidebar */
.sg-sidebar.collapsed,
#sidebar-container.collapsed {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  flex: 0 0 64px;
  flex-shrink: 0;

  overflow-x: hidden; /* ✅ also in collapsed state */
}

/* Small hamburger button at the top of the sidebar */
.sg-sidebar-toggle {
  border: none;
  background: transparent;
  font-size: 1.2rem;
}

/* Sidebar nav wrapper should also never overflow horizontally */
.sg-sidebar-nav,
#sidebar-nav {
  overflow-x: hidden;
  min-width: 0;
}

/* Sidebar links: prevent long text pushing width */
.sg-sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  text-decoration: none;

  max-width: 100%;
  min-width: 0;
  overflow: hidden;  /* ✅ ensures children don’t create scroll-x */
}

/* If your link has icon + text spans, clamp the text */
.sg-sidebar-nav a span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide menu text when sidebar is collapsed, keep only icons */
.sg-sidebar.collapsed .sg-sidebar-nav a span:last-child {
  display: none;
}

/* Sidebar icon images when using custom assets */
.sg-sidebar-icon {
  width: 35px;
  height: 35px;
  object-fit: contain;
  flex: 0 0 auto;
}

.sg-sidebar-icon.collapsed {
  width: 75px;
  height: 75px;
  object-fit: contain;
  flex: 0 0 auto;
}

/* Extra safety: images/SVGs inside sidebar never exceed width */
.sg-sidebar img,
.sg-sidebar svg {
  max-width: 100%;
}


/* =========================================================
   5) LOGIN LAYOUT
   ========================================================= */

.sg-login-layout,
#login-view,
#login-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 65px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.sg-login-layout {
  background-image: url("/assets/backgrounds/login-bg.jpg");
}

.sg-login-layout .sg-logo {
  max-height: 70px;
}

.sg-logo-login {
  height: 3.5rem;
  width: auto;
}

.sg-login-header {
  background-color: #eaecdf;
}


/* =========================================================
   6) MODALS / TOASTS
   ========================================================= */

.sg-toast-container {
  z-index: 1080;
}

.sg-modal-title {
  font-weight: 600;
  font-size: 1.3rem;
  text-transform: capitalize;
  font-style: italic;
  letter-spacing: 0.05em;
}

.sg-modal-header {
  border-bottom: 1px solid #8fa2cc;
  padding: 0.75rem 1rem;
  background-color: #b9c9da;
}

.sg-modal-footer {
  border-top: 1px solid #8fa2cc;
  padding: 0.75rem 1rem;
  background-color: #e9ecee;
}

.sg-page-content-top-navbar {
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  color: #0e0d0d;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: #689cbe !important;
}


/* =========================================================
   7) LOADING SPINNER OVERLAY
   ========================================================= */

.loading-spinner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner .dash-spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 18px 22px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.loading-spinner .dash-spinner {
  width: 150px !important;
  height: 150px !important;
  border-width: 12px !important;
  border-style: solid !important;
  border-radius: 50% !important;

  border-color: rgba(23, 125, 165, 0.18) !important;
  border-top-color: #177da5 !important;

  animation-duration: 0.85s !important;
  box-shadow: 0 0 12px rgba(23, 125, 165, 0.25);
}

.loading-spinner .dash-spinner-container::after {
  content: "Loading…";
  margin-top: 12px;
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1f2a37;
  opacity: 0.95;
}

/* =========================================================
   8) GENERIC SG BUTTONS (used in multiple pages)
   ========================================================= */
.sg-btns{
  width: 3.0vh;
  height: 3.0vh;
  display: inline-flex;           /* inline-flex works better in toolbars */
  align-items: center;
  justify-content: center;

  padding: 0 !important;          /* ✅ Bootstrap adds padding */
  line-height: 1 !important;      /* ✅ kill baseline weirdness */

  font-size: 2.5vh;
  font-weight: bold;
  box-sizing: border-box;
}

.sg-btns .bi{
  display: block;                 /* ✅ removes baseline alignment issues */
  line-height: 1;                 /* ✅ keeps it centered */
}

.sg-btns.btn{
  min-height: 0 !important;
}

