/* =========================================================
   APP.CSS — SensiGrow global styles
   =========================================================

   Sections:
   0)  Design tokens
   1)  Reset & height chain
   2)  App shell layout
   3)  Top header navbar
   4)  Sidebar
   5)  Page content navbar & shared card components
   6)  Login layout
   7)  Modals & toasts
   8)  Loading spinner
   9)  Generic buttons (sg-btns)
   10) In-body messages
   11) Global filters
   ========================================================= */


/* ---------------------------------------------------------
   0) DESIGN TOKENS
   --------------------------------------------------------- */
:root {
  /* SensiGrow brand */
  --sg-primary:        #177da5;
  --sg-primary-dark:   #115f7e;
  --sg-primary-light:  #e8f4f9;
  --sg-accent:         #2eb88a;
  --sg-border:         #c9d2e0;
  --sg-text:           #1f2a37;
  --sg-text-muted:     #64748b;
  --sg-surface:        #f4f6f9;
  --sg-radius:         6px;
  --sg-transition:     0.15s ease;
  --sg-shadow-sm:      0 1px 3px rgba(15,23,42,0.08);
  --sg-shadow-md:      0 4px 12px rgba(15,23,42,0.12);

  /* Agro green scale */
  --agro-green-900:    #0f2b1a;
  --agro-green-800:    #1a3d28;
  --agro-green-700:    #1f5c34;
  --agro-green-600:    #2d7a46;
  --agro-green-500:    #3a9e5c;
  --agro-green-400:    #52b96f;
  --agro-green-300:    #7dd29a;
  --agro-green-100:    #e6f4ec;
  --agro-green-50:     #f3faf6;

  /* Agro earth scale */
  --agro-earth-800:    #4a3728;
  --agro-earth-400:    #a07850;
  --agro-earth-100:    #f5ede4;

  /* Agro surfaces & borders */
  --agro-bg:           #f0f4f1;
  --agro-surface:      #ffffff;
  --agro-border:       #d0ddd5;
  --agro-border-soft:  #e3ece6;

  /* Agro text */
  --agro-text-primary:   #1a2e22;
  --agro-text-secondary: #4a6557;
  --agro-text-muted:     #7a9688;

  /* Agro semantic */
  --agro-accent:       #2d7a46;
  --agro-accent-hover: #1f5c34;
  --agro-red:          #c0392b;
  --agro-blue-light:   #d6eaf8;

  /* Agro shadows */
  --agro-shadow-sm:    0 1px 3px rgba(15,43,26,0.08);
  --agro-shadow-md:    0 4px 12px rgba(15,43,26,0.10);
  --agro-shadow-lg:    0 8px 24px rgba(15,43,26,0.14);

  /* Agro radii */
  --agro-radius-sm:    6px;
  --agro-radius-md:    10px;
  --agro-radius-lg:    14px;

  /* Agro fonts */
  --agro-font-display: 'DM Sans', 'Segoe UI', sans-serif;
  --agro-font-body:    'Inter', 'Segoe UI', sans-serif;
  --agro-font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Layout */
  --header-height:     56px;

  /* Watermark SVG (reused in multiple places) */
  --sg-watermark: 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.06%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");
}


/* ---------------------------------------------------------
   1) RESET & HEIGHT CHAIN
   --------------------------------------------------------- */
html, body {
  height: 100%;
  margin: 0;
}

body { overflow: hidden; }

/* Dash root elements fill full height with watermark */
#react-entry-point,
#_dash-app-content,
#_dash-app-content > div {
  height: 100%;
  background-image: var(--sg-watermark);
  background-repeat: repeat;
  background-size: 260px 140px;
}


/* ---------------------------------------------------------
   2) APP SHELL LAYOUT
   --------------------------------------------------------- */
.sg-app-shell,
#shell-view,
#shell-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sg-shell-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.sg-main-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0.25rem;
  background-image: var(--sg-watermark);
  background-repeat: repeat;
  background-size: 260px 140px;
}

#page-content,
.sg-page-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}


/* ---------------------------------------------------------
   3) TOP HEADER NAVBAR
   --------------------------------------------------------- */
.sg-header-navbar {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #bfc4cf;
  box-shadow: 0 2px 6px rgba(0,0,0,0.14);
}

.sg-header-navbar .sg-logo { max-height: 60px; }

.sg-company-name {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--sg-text);
  letter-spacing: -0.01em;
}

.sg-company-tagline {
  display: block;
  margin-top: 3px;
  font-size: 0.70rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--sg-text-muted);
}

.sg-page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--sg-text);
}

.sg-header-page-meta {
  display: flex;
  align-items: center;
  margin-left: 3rem;
  column-gap: 0.5rem;
}

/* Icon buttons in the header */
.sg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 4px;
  font-size: 0;
  line-height: 1;
  min-width: 0;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: transform var(--sg-transition), filter var(--sg-transition);
}

.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 var(--sg-transition), filter var(--sg-transition);
}

.sg-icon:hover {
  transform: scale(1.06);
  filter: brightness(1.1);
}

/* User menu button */
#user-menu > .btn,
#user-menu .btn.dropdown-toggle {
  height: 38px;
  padding: 0 0.85rem;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--sg-text);
  background: #ffffff;
  border: 1px solid var(--sg-border);
  border-radius: 999px;
  transition: background var(--sg-transition), border-color var(--sg-transition), color var(--sg-transition);
}

#user-menu > .btn:hover,
#user-menu .btn.dropdown-toggle:hover {
  background: var(--sg-primary-light);
  border-color: var(--sg-primary);
  color: var(--sg-primary);
}

/* User avatar circle */
.sg-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-accent));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* User dropdown menu */
#user-menu .dropdown-menu {
  padding: 0.3rem;
  border: 1px solid var(--sg-border);
  border-radius: 10px;
  box-shadow: var(--sg-shadow-md);
}

#user-menu .dropdown-item {
  padding: 0.38rem 0.7rem;
  font-size: 0.87rem;
  border-radius: var(--sg-radius);
  transition: background var(--sg-transition);
}

#user-menu .dropdown-item:hover { background: var(--sg-primary-light); }

/* Global actions row */
.sg-global-actions-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.sg-global-actions-row {
  display: flex;
  align-items: center;
  margin-left: 1rem;
  column-gap: 1.5rem;
}


/* ---------------------------------------------------------
   4) SIDEBAR
   --------------------------------------------------------- */
.sg-sidebar,
#sidebar-container {
  flex: 0 0 260px;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #bfc4cf;
  box-shadow: 2px 0 6px rgba(15,23,42,0.06);
}

.sg-sidebar.collapsed,
#sidebar-container.collapsed {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  flex-shrink: 0;
  overflow-x: hidden;
}

/* Sidebar scrollbar */
#sidebar-container::-webkit-scrollbar       { width: 4px; }
#sidebar-container::-webkit-scrollbar-track { background: transparent; }
#sidebar-container::-webkit-scrollbar-thumb { background: var(--sg-border); border-radius: 4px; }
#sidebar-container::-webkit-scrollbar-thumb:hover { background: var(--sg-primary); }

/* Collapse toggle button */
.sg-sidebar-toggle {
  padding: 0.2rem 0.35rem;
  font-size: 1.2rem;
  color: var(--sg-text-muted);
  background: transparent;
  border: none;
  border-radius: var(--sg-radius);
  cursor: pointer;
  transition: background var(--sg-transition), color var(--sg-transition);
}

.sg-sidebar-toggle:hover {
  background: var(--sg-primary-light);
  color: var(--sg-primary);
}

/* Nav links */
.sg-sidebar-nav,
#sidebar-nav {
  overflow-x: hidden;
  min-width: 0;
}

.sg-sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
  border-radius: var(--sg-radius);
  position: relative;
  transition: background var(--sg-transition), color var(--sg-transition);
}

.sg-sidebar-nav a:hover {
  background: var(--sg-primary-light);
  color: var(--sg-primary);
}

.sg-sidebar-nav a.active,
.sg-sidebar-nav a[aria-current="page"] {
  background: var(--sg-primary-light);
  color: var(--sg-primary);
  font-weight: 600;
}

/* Active indicator bar */
.sg-sidebar-nav a.active::before,
.sg-sidebar-nav a[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sg-primary);
}

.sg-sidebar-nav a span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide labels when collapsed */
.sg-sidebar.collapsed .sg-sidebar-nav a span:last-child { display: none; }

/* Sidebar icons */
.sg-sidebar-icon {
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  object-fit: contain;
}

.sg-sidebar-icon.collapsed {
  width: 75px;
  height: 75px;
}

.sg-sidebar img,
.sg-sidebar svg {
  max-width: 100%;
}


/* ---------------------------------------------------------
   5) PAGE CONTENT NAVBAR & SHARED CARD COMPONENTS
   --------------------------------------------------------- */

/* Per-page top toolbar (used inside each page) */
.sg-page-content-top-navbar {
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: bold;
  color: #0e0d0d;
  background-color: #e8f2f7 !important;
  box-shadow: var(--sg-shadow-sm);
}

/* Shared card header — used across all pages */
.sg-card-header {
  padding:         0.4rem 0.75rem;
  background:      #d3e6cbfb;
  border-bottom:   1px solid #aec7b5;
  font-family:     var(--agro-font-display);
  font-size:       0.88rem;
  font-weight:     600;
  letter-spacing:  0.02em;
  text-transform:  uppercase;
  color:           #27500A;
}

/* Shared card footer — used across all pages */
.sg-card-footer {
  padding:       0.4rem 0.75rem;
  background:    #d7dfd3fb;
  border-top:    1px solid #aec7b5;
  font-family:   var(--agro-font-display);
  font-size:     0.85rem;
  font-weight:   500;
  color:         #27500A;
}


/* ---------------------------------------------------------
   6) LOGIN LAYOUT
   --------------------------------------------------------- */
.sg-login-layout,
#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 0;
  background: none;
}

/* Left branding panel */
.sg-login-left-panel {
  flex: 1 1 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
  background-image: url("/assets/backgrounds/login-bg.jpg");
  background-size: cover;
  background-position: center;
}

.sg-login-left-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  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%23ffffff%27%20font-size%3D%2728%27%20fill-opacity%3D%270.04%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;
}

.sg-login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.sg-login-brand-logo {
  height: 90px;
  width: auto;
  opacity: 0.95;
}

.sg-login-brand-name {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 3.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #ffffff;
  margin: 0 0 0.25rem 0;
}

.sg-login-brand-tagline {
  font-size: 1.0rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin: 0 0 2rem 0;
}

.sg-login-brand-divider {
  border-color: rgba(255,255,255,0.2);
  margin: 0 0 1.5rem 0;
}

.sg-login-brand-desc {
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.6;
  color: rgba(255,255,255,0.72);
  margin: 0;
}

/* Right form panel */
.sg-login-right-panel {
  flex: 0 0 450px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0.75rem;
  margin-left: 15px;
  margin-right: 15px;
  background: #f8fafc;
}

.sg-login-form {
  width: 100%;
  max-width: 100%;
}

.sg-login-title {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--sg-text);
  margin: 0 0 0.25rem 0;
}

.sg-login-subtitle {
  font-size: 1.05rem;
  color: var(--sg-text-muted);
  margin: 0;
}

.sg-login-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--sg-text);
  margin-bottom: 0.5rem;
}

.sg-login-input {
  font-size: 1rem !important;
  padding: 0.75rem 1rem !important;
  background: #ffffff !important;
  border: 1px solid #dde2ea !important;
  border-radius: 8px !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

.sg-login-input:focus {
  border-color: var(--sg-primary) !important;
  box-shadow: 0 0 0 3px rgba(23,125,165,0.14) !important;
  outline: none !important;
}

.sg-login-show-pw {
  font-size: 0.95rem;
  color: var(--sg-text-muted);
}

.sg-login-forgot {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--sg-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.sg-login-forgot:hover {
  color: var(--sg-primary-dark);
  text-decoration: underline;
}

.sg-login-btn {
  height: 52px !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  border-radius: 8px !important;
  background: var(--sg-primary) !important;
  border-color: var(--sg-primary) !important;
  transition: background 0.15s ease, box-shadow 0.15s ease !important;
}

.sg-login-btn:hover {
  background: var(--sg-primary-dark) !important;
  box-shadow: 0 4px 14px rgba(23,125,165,0.35) !important;
}

/* Login misc */
.sg-login-layout .sg-logo  { max-height: 70px; }
.sg-logo-login             { height: 3.5rem; width: auto; }
.sg-login-header           { background-color: #eaecdf; }

/* Responsive — stack panels on mobile */
@media (max-width: 768px) {
  .sg-login-layout,
  #login-view {
    flex-direction: column;
  }

  .sg-login-left-panel {
    flex: 0 0 220px;
    padding: 2rem;
  }

  .sg-login-right-panel {
    flex: 1;
    padding: 2rem 0.75rem;
  }

  .sg-login-brand-name { font-size: 2rem; }
}


/* ---------------------------------------------------------
   7) MODALS & TOASTS
   --------------------------------------------------------- */
.sg-toast-container { z-index: 1080; }

.sg-modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.sg-modal-header {
  padding: 0.75rem 1rem;
  background-color: #b9c9da;
  border-bottom: 1px solid #8fa2cc;
}

.sg-modal-footer {
  padding: 0.75rem 1rem;
  background-color: #e9ecee;
  border-top: 1px solid #8fa2cc;
}


/* ---------------------------------------------------------
   8) LOADING SPINNER
   --------------------------------------------------------- */
.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: 22px 30px;
  border-radius: 14px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 16px 40px rgba(0,0,0,0.14);
}

.loading-spinner .dash-spinner-container::after {
  content: "Loading…";
  margin-top: 10px;
  font: 500 13px/1.2 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.03em;
  color: var(--sg-text-muted);
}

.loading-spinner .dash-spinner {
  width: 80px !important;
  height: 80px !important;
  border-width: 6px !important;
  border-style: solid !important;
  border-radius: 50% !important;
  border-color: rgba(23,125,165,0.15) !important;
  border-top-color: var(--sg-primary) !important;
  animation-duration: 0.7s !important;
  box-shadow: none !important;
}


/* ---------------------------------------------------------
   9) GENERIC BUTTONS (sg-btns)
   --------------------------------------------------------- */
.sg-btns {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.0vh;
  height: 3.0vh;
  font-size: 2.5vh;
  font-weight: bold;
  padding: 0 !important;
  line-height: 1 !important;
  box-sizing: border-box;
}

.sg-btns .bi   { display: block; line-height: 1; }
.sg-btns.btn   { min-height: 0 !important; }


/* ---------------------------------------------------------
   10) IN-BODY MESSAGES
   --------------------------------------------------------- */
.sg-in-body-message {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  font-size: 200%;
  font-weight: bold;
  color: var(--sg-text);
  box-sizing: border-box;
}


/* ---------------------------------------------------------
   11) GLOBAL FILTERS
   --------------------------------------------------------- */
.sg-global-filter-group {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  column-gap: 0.5rem;
  min-width: 0;
}

.sg-global-filter-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sg-text);
  white-space: nowrap;
  user-select: none;
}

.sg-global-filter-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 0.75rem 0 4px;
  background: #ffffff;
  border: 1px solid var(--sg-border);
  border-radius: 999px;
  box-shadow: var(--sg-shadow-sm);
  box-sizing: border-box;
  transition: border-color var(--sg-transition), box-shadow var(--sg-transition);
}

.sg-global-filter-control:hover,
.sg-global-filter-control:focus-within {
  border-color: var(--sg-primary);
  box-shadow: 0 0 0 3px rgba(23,125,165,0.12);
}

.sg-global-filter-control .sg-icon { width: 28px; height: 28px; }

/* Ghost trigger button inside the pill */
.sg-global-filter-trigger,
.sg-global-filter-trigger:focus,
.sg-global-filter-trigger:active {
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.sg-global-filter-value {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--sg-text);
}

/* Plant unit filter dropdown inside the pill */
.sg-plant-filter-dropdown { min-width: 220px; margin-bottom: 0; }

.sg-global-filter-control .sg-plant-filter-dropdown { min-width: 240px; margin: 0; }

.sg-global-filter-control .sg-plant-filter-dropdown,
.sg-global-filter-control .sg-plant-filter-dropdown .Select,
.sg-global-filter-control .sg-plant-filter-dropdown .Select-control {
  height: 34px;
  min-height: 34px;
  line-height: 34px;
}

.sg-global-filter-control .sg-plant-filter-dropdown .Select-control,
.sg-global-filter-control .sg-plant-filter-dropdown .dash-dropdown .Select-control {
  background: transparent;
  border: none;
  box-shadow: none;
  min-height: 30px;
}

.sg-global-filter-control .sg-plant-filter-dropdown .Select-placeholder,
.sg-global-filter-control .sg-plant-filter-dropdown .Select-value {
  line-height: 34px;
  padding-top: 0;
  padding-bottom: 0;
}