/* =========================================================
   IRRIGATION RECOMMENDATION PAGE — LAYOUT CONTRACT
   ---------------------------------------------------------
   Goals:
   1) The page must fill the available content area (parent),
      NOT force the browser window to scroll.
   2) The header stays at the top at natural height.
   3) Only the plant-units body scrolls vertically.
   4) Never create horizontal overflow (prevents sidebar X-scroll).
   5) Last element is fully visible (extra bottom padding).
   ---------------------------------------------------------
   Required parent behavior (in app.css):
   - #page-content / .sg-page-content should be display:flex (column)
     and overflow:hidden (no scroll there).
   ========================================================= */


/* ---------------------------------------------------------
   0) Minimal horizontal overflow guard (optional)
   NOTE: This prevents global X-scrollbars if something leaks.
   If you don't want any global effect, you can remove this block.
   --------------------------------------------------------- */
html, body {
  overflow-x: hidden !important;
}


/* ---------------------------------------------------------
   1) Page wrapper (fills available parent height)
   IMPORTANT: flex: 1 1 auto makes this element actually
   take the remaining height inside #page-content (flex column).
   Without it, inner scroll regions may not get a real height.
   --------------------------------------------------------- */
.irrigation-recommendation-page {
  flex: 1 1 auto;           /* ✅ CRITICAL: fill parent flex height */
  height: 100%;             /* ok to keep */
  width: 100%;

  display: flex;
  flex-direction: column;

  overflow: hidden;         /* no scrollbars on the page wrapper */
  min-height: 0;            /* allow children to scroll */
  min-width: 0;             /* prevent horizontal overflow */
}


/* ---------------------------------------------------------
   2) Header area (natural height, full width, no X overflow)
   --------------------------------------------------------- */
.irrigation-recommendation-header {
  flex: 0 0 auto;
  width: 100%;

  min-height: 0;
  min-width: 0;
  
  overflow-x: hidden;       /* ensure header never causes X scroll */
}


/* ---------------------------------------------------------
   3) Scrollable body (ONLY scrolling region)
   - Takes remaining height under header
   - Scrolls vertically
   - Never scrolls horizontally
   --------------------------------------------------------- */
.irrigation-recommendation-plant-units-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  height: 69vh;

  display: block;                 /* ✅ important */
  overflow-y: auto !important;
  overflow-x: hidden !important;

  padding-top: 6px;
  padding-bottom: 24px;
  scroll-padding-bottom: 24px;
  overscroll-behavior: contain;
}


/* ---------------------------------------------------------
   4) Flex/overflow safety: allow any children to shrink
   (Prevents Plotly / long text from forcing extra width)
   --------------------------------------------------------- */
.irrigation-recommendation-page *,
.irrigation-recommendation-header *,
.irrigation-recommendation-plant-units-body * {
  min-width: 0;
  box-sizing: border-box;
}


/* ---------------------------------------------------------
   5) Plotly clamps (Plotly can sometimes overflow containers)
   --------------------------------------------------------- */
.irrigation-recommendation-page .js-plotly-plot,
.irrigation-recommendation-page .plot-container {
  max-width: 100%;
  overflow: hidden;
}


.irrigation-recommendation-plant-unit-card-header {
    /* padding: 8px 12px; */
    background-color: #689cbe;
    border-bottom: 1px solid #c4c8cc;
    font-size: 1.1rem;
    font-weight: 600;
    gap: 5px;
}

.irrigation-recommendation-day-card-header{
    /* padding: 8px 12px; */
    background-color: #a4bbdb;
    border-bottom: 1px solid #c4c8cc;
    font-size: 1.1rem;
    font-weight: 600;
    gap: 5px;
}






/* =========================================================
   6) PROFESSIONAL SUMMARY / OPERATIONS HEADER
   ========================================================= */
.irrigation-recommendation-header {
  padding-top: 4px;
  padding-bottom: 4px;
  background: linear-gradient(180deg, #f7faf8 0%, #eef4f0 100%);
  border-bottom: 1px solid var(--agro-border, #d0ddd5);
}

.ir-header-row {
  margin-left: -3px !important;
  margin-right: -3px !important;
}

.ir-header-col {
  padding-left: 3px !important;
  padding-right: 3px !important;
}

.ir-summary-card {
  border: 1px solid #d7e1da !important;
  border-radius: 9px !important;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 43, 26, 0.07), 0 3px 10px rgba(15, 43, 26, 0.04);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.ir-summary-card:hover {
  border-color: #c3d3c8 !important;
  box-shadow: 0 3px 10px rgba(15, 43, 26, 0.10);
}

.ir-summary-card > .card-header {
  min-height: 31px;
  padding: 6px 9px;
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #f3f8f4 0%, #e9f2ec 100%);
  border-bottom: 1px solid #d7e1da;
  color: #234532;
}

.ir-header-title {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.79rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.ir-header-title-icon {
  flex: 0 0 auto;
  color: #2d7a46;
  font-size: 0.82rem;
  opacity: 0.9;
}

/* Keep chart canvases visually integrated with the cards. */
.ir-summary-card .card-body {
  background: #ffffff;
}

.ir-summary-card .js-plotly-plot,
.ir-summary-card .plot-container,
.ir-summary-card .svg-container {
  border-radius: 0 0 8px 8px;
}

/* Info card */
.ir-info-card-body {
  padding: 7px 8px !important;
  overflow: hidden;
}

.ir-info-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.71rem;
  color: #33483c;
}

.ir-info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 4px 5px;
  border: 1px solid #e1e9e4;
  border-radius: 6px;
  background: #f8fbf9;
}

.ir-info-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #60766a;
}

.ir-info-value {
  flex: 0 0 auto;
  font-weight: 700;
  color: #1f5c34;
}

.ir-info-section-title {
  margin-top: 2px;
  padding: 3px 2px 2px;
  color: #496458;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  border-bottom: 1px solid #e4ebe6;
}

.ir-info-pulse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 1px 2px;
  color: #546c60;
  line-height: 1.2;
}

.ir-info-pulse-row strong {
  flex: 0 0 auto;
  color: #243d30;
  font-weight: 700;
}

/* Operations card */
.ir-operations-body {
  padding: 7px 8px !important;
  overflow: visible;
}

.ir-operations-stack {
  height: 100%;
  justify-content: space-between;
}

.ir-control-group {
  padding: 5px 6px;
  border: 1px solid #e0e8e3;
  border-radius: 7px;
  background: #fafcfb;
}

.ir-control-label {
  margin-bottom: 4px;
  color: #667b70;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.ir-square-action-btn {
  width: 32px !important;
  min-width: 32px !important;
  height: 31px !important;
  min-height: 31px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.ir-square-action-btn i {
  font-size: 0.85rem;
}

.ir-program-dropdown .Select-control,
.ir-program-dropdown .select__control,
.ir-compact-select.form-select {
  min-height: 31px;
  height: 31px;
  border-color: #ccd8d0;
  border-radius: 6px;
  background: #ffffff;
  font-size: 0.73rem;
}

.ir-program-dropdown .Select-placeholder,
.ir-program-dropdown .Select-value-label,
.ir-program-dropdown .select__single-value,
.ir-program-dropdown .select__placeholder {
  font-size: 0.73rem;
}

.ir-compact-select.form-select {
  padding-top: 0.18rem;
  padding-bottom: 0.18rem;
  padding-left: 0.45rem;
  padding-right: 1.55rem;
}

.ir-compact-select.form-select:focus,
.ir-program-dropdown .Select-control:focus-within,
.ir-program-dropdown .select__control--is-focused {
  border-color: #7eaa8e !important;
  box-shadow: 0 0 0 2px rgba(45, 122, 70, 0.10) !important;
}

.ir-compact-select.form-select:disabled {
  color: #8a9990;
  background-color: #f0f3f1;
  border-color: #dde4df;
}

.ir-follower-checkbox {
  display: flex;
  align-items: center;
  min-height: 31px;
  padding: 0 3px;
  margin: 0 !important;
  white-space: nowrap;
  font-size: 0.72rem;
  color: #40584b;
}

.ir-follower-checkbox .form-check-input {
  position: static;
  float: none;
  margin: 0 0.35rem 0 0 !important;
  flex: 0 0 auto;
}

.ir-days-group {
  padding-bottom: 3px;
}

.ir-days-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.ir-days-value {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 999px;
  text-align: center;
  color: #ffffff;
  background: #2d7a46;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0;
}

.ir-days-slider {
  padding: 0 4px;
}

.ir-days-slider .rc-slider {
  margin-top: 1px;
}

.ir-days-slider .rc-slider-track {
  background-color: #52a86c;
}

.ir-days-slider .rc-slider-handle {
  border-color: #2d7a46;
}

.ir-days-slider .rc-slider-dot-active {
  border-color: #52a86c;
}

.ir-days-slider .rc-slider-mark-text {
  color: #6b7f74;
  font-size: 0.61rem;
}


/* Info and Operations only: readable, compact, and safe at short heights.
   Existing chart widths and the header horizontal-scroll behavior are retained. */
.irrigation-recommendation-header .ir-info-col { min-width: 176px; }
.irrigation-recommendation-header .ir-operations-col { min-width: 416px; }
.irrigation-recommendation-header :is(.ir-info-card, .ir-operations-card) {
  min-height: 0;
  overflow: visible;
  border-radius: 10px !important;
}
.irrigation-recommendation-header :is(.ir-info-card, .ir-operations-card) > .card-header {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px 10px 0 0;
  background: #edf5ef;
}
.irrigation-recommendation-header :is(.ir-info-card, .ir-operations-card) .ir-header-title {
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
}
.irrigation-recommendation-header :is(.ir-info-card-body, .ir-operations-body) {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px !important;
  overflow: auto;
  scrollbar-width: thin;
  border-radius: 0 0 10px 10px;
}
.ir-info-card .ir-info-panel {
  height: auto;
  gap: 3px;
  font-size: 13px;
  line-height: 1.35;
}
.ir-info-card .ir-info-item {
  padding: 4px 6px;
  gap: 8px;
  border: 0;
  background: #f1f6f3;
}
.ir-info-card .ir-info-label {
  white-space: normal;
  overflow-wrap: anywhere;
  color: #465f50;
}
.ir-info-card .ir-info-value { font-variant-numeric: tabular-nums; }
.ir-info-card .ir-info-section-title {
  margin-top: 4px;
  padding: 4px 2px;
  font-size: 11px;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
}
.ir-info-card .ir-info-pulse-row {
  padding: 3px 2px;
  gap: 8px;
  line-height: 1.3;
  border-bottom: 1px solid #edf1ee;
}
.ir-info-card .ir-info-pulse-row strong {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.ir-operations-card .ir-operations-stack {
  height: auto;
  min-height: 100%;
  justify-content: flex-start;
  gap: 8px !important;
}
.ir-operations-card .ir-control-group {
  padding: 7px 8px;
  border-color: #e2e9e4;
  background: #fafcfb;
}
.ir-operations-card .ir-control-label,
.ir-operations-card .ir-select-label {
  display: block;
  margin-bottom: 5px;
  color: #405b4b;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}
.ir-operations-card .ir-select-label { font-size: 11px; }
.ir-operations-card .ir-plan-tools {
  display: grid;
  grid-template-columns: 34px 34px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  align-items: end !important;
}
.ir-operations-card .ir-plan-tools > .col,
.ir-operations-card .ir-plan-tools > .col-auto {
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
}
.ir-operations-card .ir-plan-tools > .col-auto:has(.ir-follower-checkbox) {
  grid-column: span 2;
}
.ir-operations-card .ir-square-action-btn {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
}
.ir-operations-card .ir-square-action-btn i { font-size: 15px; }
.ir-operations-card .ir-compact-select.form-select,
.ir-operations-card .ir-program-dropdown {
  font-size: 13px;
}
.ir-operations-card .ir-compact-select.form-select,
.ir-operations-card .ir-program-dropdown .Select-control,
.ir-operations-card .ir-program-dropdown .select__control {
  height: 34px;
  min-height: 34px;
  font-size: 13px;
}
.ir-operations-card .ir-program-dropdown :is(.Select-placeholder, .Select-value-label,
.select__single-value, .select__placeholder) { font-size: 13px; }
.ir-operations-card .ir-program-dropdown { min-width: 0; }
.ir-operations-card .ir-follower-checkbox {
  min-height: 28px;
  white-space: normal;
  font-size: 12px;
  line-height: 1.35;
  padding: 0;
}
.ir-operations-card .ir-follower-checkbox .form-check-input {
  margin: 0 !important;
  margin-inline-end: 6px !important;
}
.ir-operations-card .ir-days-group { margin-top: auto; padding-bottom: 14px; }
.ir-operations-card .ir-days-label { display: flex; margin-bottom: 8px; }
.ir-operations-card .ir-days-value { font-size: 12px; min-width: 24px; }
.ir-operations-card .ir-days-slider { padding: 0 10px; }
.ir-operations-card .ir-days-slider .rc-slider-mark-text { font-size: 11px; color: #405b4b; }
.ir-operations-card :is(button, select, input):focus-visible {
  outline: 2px solid #246b3c;
  outline-offset: 2px;
}
@media (max-width: 767px) {
  .irrigation-recommendation-header .ir-info-col { min-width: 176px; }
  .irrigation-recommendation-header .ir-operations-col { min-width: 360px; }
}


/* Header chart cards: match Info / Operations without affecting unit charts. */
.irrigation-recommendation-header .ir-chart-card {
  min-height: 0;
  border-radius: 10px !important;
  box-shadow: 0 1px 4px rgba(25, 65, 40, 0.07);
}
.irrigation-recommendation-header .ir-chart-card > .card-header {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  background: #edf5ef;
  border-bottom: 1px solid #d7e1da;
}
.irrigation-recommendation-header .ir-chart-card .ir-header-title {
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}
.irrigation-recommendation-header .ir-chart-card .ir-header-title-icon {
  font-size: 14px;
}
.irrigation-recommendation-header .ir-chart-card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0 0 10px 10px;
}
.irrigation-recommendation-header .ir-chart-card .modebar {
  border-radius: 6px;
}


/* Recommendation rows: scoped to the unit and daily cards. */
.ir-unit-card {
  height: max(30vh, 290px) !important;
  border: 1px solid #d7e1da;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(25,65,40,.06);
}
.ir-unit-card > .card-header { border-bottom: 1px solid #dce7df; }
.ir-unit-card .ir-unit-header {
  padding: 8px 10px;
  gap: 12px;
  background: #edf5ef;
  text-transform: none;
  min-height: 68px;
  flex-wrap: wrap;
}
.ir-unit-header .ir-unit-identity { flex: 1 1 560px; gap: 8px; flex-wrap: wrap; }
.ir-unit-header .ir-unit-identity > img { width: 24px; height: 24px; object-fit: contain; }
.ir-unit-description-wrap { flex: 1 1 240px; min-width: 0; }
.ir-unit-description { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
.ir-unit-name { font-size: 15px; line-height: 1.3; color: #203e2d; overflow-wrap: anywhere; }
.ir-unit-location { font-size: 11px; line-height: 1.3; color: #536c5e; overflow-wrap: anywhere; }
.ir-unit-metadata { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 5px; }
.ir-unit-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px;
  border-radius: 5px; background: #fff; border: 1px solid #dce7df;
  font-size: 11px; line-height: 1.3; color: #405b4b; }
.ir-stress-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #b6c6bc; flex: 0 0 auto; }
.ir-unit-header .ir-calculation-status { font-size: 11px; line-height: 1.3; font-style: normal !important; }
.ir-unit-header .ir-unit-plan-actions { gap: 8px; flex: 0 1 auto; flex-wrap: wrap; }
.ir-unit-plan-actions .form-check { margin: 0 !important; font-size: 12px; line-height: 1.35; }
.ir-unit-header .ir-unit-action { width: 32px; height: 32px; min-width: 32px; padding: 0;
  display: inline-flex; justify-content: center; align-items: center; border-radius: 6px; }
.ir-unit-card > .card-body { padding: 7px !important; }
.ir-unit-card .ir-day-card { border: 1px solid #e0e8e3; border-radius: 7px; overflow: hidden; box-shadow: none; }
.ir-day-card > .ir-day-date { flex: 0 0 auto; border: 0; background: #f3f7f4; }
.ir-day-date .sg-card-footer { background: transparent; padding: 3px 7px; gap: 4px; min-height: 28px; }
.ir-day-date .sg-card-footer > div:last-child { font-size: 12px !important; font-weight: 600; color: #2a4835 !important; }
.ir-day-card .ir-day-weather { background: #fff; border: 0; padding: 3px 5px; overflow-x: auto; }
.ir-day-card > .card-header:not(.ir-day-date) { border-bottom: 1px solid #edf1ee; background: #fff; }
.ir-unit-header :is(button, input):focus-visible { outline: 2px solid #246b3c; outline-offset: 2px; }
@media (max-width: 900px) {
  .ir-unit-card { height: max(38vh, 340px) !important; }
  .ir-unit-header .ir-unit-identity { flex-basis: 100%; }
  .ir-unit-header .ir-unit-plan-actions { margin-inline-start: auto; }
}


/* Daily chart polish; retain weather widget warnings and pulse colors. */
.ir-unit-card .ir-day-today { border-color: #70a981; }
.ir-day-today > .ir-day-date { box-shadow: inset 0 3px 0 #3d8b5c; }
.ir-day-card .ir-day-weather { scrollbar-width: thin; }
.ir-day-card > .card-body { margin: 3px !important; }
.ir-day-card .modebar { border-radius: 5px; background: rgba(255,255,255,.9); }
.ir-day-card .js-plotly-plot { border-radius: 0 0 6px 6px; }


/* Larger, readable unit-header typography, including Hebrew fallbacks. */
.ir-unit-card .ir-unit-header {
  font-family: "Segoe UI", Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  padding: 10px 12px;
}
.ir-unit-header .ir-unit-name {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: normal;
}
.ir-unit-header .ir-unit-location {
  font-size: 13px;
  line-height: 1.4;
  color: #466050;
}
.ir-unit-header .ir-unit-badge,
.ir-unit-header .ir-calculation-status {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.ir-unit-header .ir-unit-badge { padding: 3px 8px; }
.ir-unit-header .ir-unit-plan-actions .form-check {
  font-size: 14px;
  line-height: 1.4;
}
