/* Variables globales */
:root {
  --primary-color: #9bb073;
  --secondary-color: #B83E2D;
  --hover-color: #4CAF50;
  --text-color: #202020;
  --font-family: Arial, sans-serif;
  --background-light: aliceblue;
}

/* Réinitialisation globale */
* {
  box-sizing: border-box;
}

/* Style the body */
body {
  font-family: var(--font-family);
  font-size: 20px;
  margin: 0;
}

pre {
  font-family: var(--font-family);
  margin: 0px;
  padding: 0px;
  outline: 0px;
  text-align: left;
  white-space: pre-wrap;
}

h1,
h2,
h3,
h4 {
  margin-top: 10px;
  margin-bottom: 5px;
  padding: 0;
  text-align: left;
}

h1 {
  font-size: 28px;
  text-align: center;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 20px;
}

h4 {
  font-size: 18px;
}

p {
  margin-bottom: 3px;
  padding: 0;
  font-size: 16px;
  text-align: left;
}

p.var_card {
  margin: 2px;
  padding: 0px;
  outline: 0px;
  text-align: left;
}

button,
.custom-button {
  background-color: var(--hover-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.4s;
}

button:hover,
.custom-button:hover {
  background-color: var(--primary-color);
}

table.var_card,
tr.var_card,
td.var_card {
  border-collapse: collapse;
  border: 1px solid var(--secondary-color);
  margin: 1px;
  font-size: 14px;
  text-align: left;
}

/**************** GRID ***********************************/

.grid_header {
  width: 100%;
  max-width: 100%;
  grid-area: header;
  padding: 7px;
  text-align: center;
  background: var(--primary-color);
  color: white;
  box-sizing: border-box;
  overflow: hidden;
}

.grid_navbar {
  width: 100%;
  max-width: 100%;
  grid-area: navbar;
  height: 50px;
  max-height: 50px;
  overflow: visible; /* dropdowns must paint over main content */
  background: rgb(69, 99, 17);
  color: white;
  padding: 0;
  position: relative;
  z-index: 1000; /* above main grid */
  box-sizing: border-box;
}

/* Main content shells fill the outer grid row; panes scroll on desktop side-by-side */
.grid_main_1c,
.grid_main_2c_11,
.grid_main_2c_12,
.grid_main_3c {
  grid-area: grid_main;
  display: grid;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  gap: 0;
  padding: 0;
  background-color: var(--background-light);
  box-sizing: border-box;
  overflow: hidden; /* desktop: children scroll independently */
  position: relative;
  z-index: 1; /* keep below navbar dropdowns */
}

.grid_main_1c {
  grid-template-areas: 'main';
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.grid_main_2c_11 {
  grid-template-areas: 'main2l main2r';
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.grid_main_2c_12 {
  grid-template-areas: 'main2l main2r';
  grid-template-columns: 1fr 2fr;
  grid-template-rows: minmax(0, 1fr);
}

.grid_main_3c {
  grid-template-areas: 'mainl mainc mainr';
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
}

.grid_main,
.grid_mainl,
.grid_mainc,
.grid_mainr,
.grid_main2l,
.grid_main2r {
  margin: 5px;
  padding: 5px;
  min-width: 0; /* allow flex/grid children to shrink within viewport */
  min-height: 0;
  overflow: auto; /* side-by-side: scroll inside pane */
  box-sizing: border-box;
  background-color: var(--background-light);
}

/* Form tables use full pane width; long selects stay inside */
.grid_mainl > table,
.grid_main2l > table,
.grid_main > table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.grid_mainl > table td,
.grid_main2l > table td,
.grid_main > table td {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

.grid_mainl > table td:first-child,
.grid_main2l > table td:first-child {
  width: 32%;
}

.grid_mainl > table td:last-child,
.grid_main2l > table td:last-child {
  width: 68%;
}

/* Wide data tables: scroll horizontally inside their container */
#harvest_list,
#harvest_stats,
#harvest_stats_last,
#harvest_rev_weekly12,
.ref-list,
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

#harvest_list table,
#harvest_stats table,
#harvest_stats_last table,
#harvest_rev_weekly12 table,
.ref-list table,
.table-scroll table {
  width: auto;
  min-width: 100%;
  max-width: none;
  table-layout: auto;
}

.grid_main {
  grid-area: main;
}

.grid_mainl {
  grid-area: mainl;
}

.grid_mainc {
  grid-area: mainc;
}

.grid_mainr {
  grid-area: mainr;
}

.grid_main2l {
  grid-area: main2l;
}

.grid_main2r {
  grid-area: main2r;
}

.grid_footer {
  grid-area: footer;
  background: var(--primary-color);
  color: white;
  text-align: left;
}

.grid_footer p {
  margin: 7px;
  padding: 5px;
  text-align: center;
}

.grid_outer {
  display: grid;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  grid-template-areas:
    'header'
    'navbar'
    'grid_main'
    'footer';
  grid-template-columns: minmax(0, 1fr);
  /* Fixed navbar row so a second menu line cannot steal main content */
  grid-template-rows: auto 50px minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  background-color: var(--background-light);
  /* Do not clip navbar dropdowns (overflow-x:hidden creates a clip edge) */
  overflow: visible;
}

.grid-container>div {
  font-size: 20px;
}

/*************** NAVBAR (single-line + priority overflow) *****/

.my_navbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  height: 50px;
  max-height: 50px;
  background-color: rgb(69, 99, 17);
  overflow: visible; /* critical: do not clip dropdown panels */
  box-sizing: border-box;
  position: relative;
  z-index: 1000;
}

.nav-primary {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  /* overflow:hidden would clip dropdowns — JS hides overflow items instead */
  overflow: visible;
}

.nav-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  box-sizing: border-box;
}

.nav-item-overflow {
  display: none !important;
}

.my_navbar > .nav-primary > a.nav-item,
.my_navbar a.nav-item {
  color: #f2f2f2;
  text-align: center;
  padding: 0 14px;
  height: 50px;
  line-height: 50px;
  text-decoration: none;
  font-size: 16px;
}

.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.dropbtn {
  display: inline-flex;
  align-items: center;
  text-align: left;
  background-color: rgb(69, 99, 17);
  color: white;
  padding: 0 14px;
  height: 50px;
  font-size: 16px;
  border: none;
  border-radius: 0;
  font-family: inherit;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
}

.nav-more {
  flex: 0 0 auto;
  margin-left: auto;
  position: relative;
  z-index: 1001;
}

.nav-more[hidden] {
  display: none !important;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #f1f1f1;
  min-width: 200px;
  max-width: min(92vw, 320px);
  /* overflow must stay visible so nested Language flyouts are not clipped */
  overflow: visible;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  z-index: 1100;
}

.dropdown-content-right {
  left: auto;
  right: 0;
}

.dropdown-content a,
.dropdown-content .submenu-btn {
  float: none;
  color: #202020;
  padding: 10px 14px;
  text-decoration: none;
  display: block;
  text-align: left;
  line-height: 1.3;
  white-space: normal;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
}

/* Nested Language submenu */
.nav-submenu {
  position: relative;
  border-top: 1px solid #ddd;
}

.submenu-btn {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
}

.submenu-btn::after {
  content: '▸';
  margin-left: 0.5em;
  opacity: 0.7;
}

.submenu-content {
  display: none;
  position: absolute;
  /* Open to the left of Admin (right-aligned menu) so it stays on-screen */
  left: auto;
  right: 100%;
  top: 0;
  min-width: 140px;
  background: #f8f8f8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  z-index: 1200;
}

/* Left-aligned dropdowns (e.g. Data) still open submenu to the right */
.dropdown-content:not(.dropdown-content-right) .submenu-content {
  left: 100%;
  right: auto;
}

.submenu-content a.active-lang {
  font-weight: bold;
  background: #e8f0dc;
}

/* Hover (desktop) and .open (touch / click) */
.nav-dropdown:hover > .dropdown-content,
.nav-dropdown.open > .dropdown-content {
  display: block;
}

.nav-submenu:hover > .submenu-content,
.nav-submenu.open > .submenu-content {
  display: block;
}

.my_navbar a.nav-item:hover,
.nav-dropdown:hover > .dropbtn,
.nav-dropdown.open > .dropbtn {
  background-color: var(--secondary-color);
  color: white;
}

.dropdown-content a:hover,
.dropdown-content .submenu-btn:hover,
.submenu-content a:hover {
  background-color: #ddd;
  color: black;
}

.active {
  background-color: var(--secondary-color);
  color: white;
  margin: 0;
}

/* Legacy class aliases */
.dropdown,
.dropdown-right {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.my_navbar .icon {
  display: none;
}

/* Nested submenu stacks under parent on narrow screens (no off-screen flyout) */
@media screen and (max-width: 800px) {
  .submenu-content {
    position: static;
    box-shadow: none;
    border-left: 3px solid #9bb073;
    background: #f0f0f0;
  }

  .submenu-btn::after {
    content: '▾';
  }
}


/********************** RESPONSIVE LAYOUT *******************/

/*
 * Mobile: page grows with content (browser scrolls the document).
 * Multi-column layouts stack full-height: column1 above column2 above column3.
 * Form controls fit the viewport width; wide data tables scroll horizontally.
 */
@media screen and (max-width: 800px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* page itself does not shift sideways */
    overflow-y: auto;
  }

  .grid_outer {
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 50px auto auto;
    overflow: visible;
  }

  .grid_main_1c,
  .grid_main_2c_11,
  .grid_main_2c_12,
  .grid_main_3c {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
  }

  .grid_main,
  .grid_mainl,
  .grid_mainc,
  .grid_mainr,
  .grid_main2l,
  .grid_main2r {
    position: relative;
    display: block;
    /* margin lives inside width so fields are not cropped on the right */
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px;
    flex: 0 0 auto;
    height: auto;
    max-height: none;
    overflow-x: auto; /* wide tables scroll here if needed */
    overflow-y: visible;
    box-sizing: border-box;
  }

  /* Form tables + controls fill the pane without overflowing */
  .grid_mainl > table,
  .grid_main2l > table,
  .grid_main > form table,
  #add_harvest_form {
    width: 100% !important;
    max-width: 100%;
    table-layout: fixed;
  }

  .grid_mainl input,
  .grid_mainl select,
  .grid_mainl textarea,
  .grid_main2l input,
  .grid_main2l select,
  .grid_main2l textarea,
  .grid_main input,
  .grid_main select,
  .grid_main textarea,
  #add_harvest_form input,
  #add_harvest_form select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  .grid_navbar,
  .my_navbar {
    height: 50px;
    max-height: 50px;
  }

  .my_navbar > .nav-primary > a.nav-item,
  .my_navbar a.nav-item,
  .dropbtn {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 15px;
  }
}


/********************  INPUT  *****************************/

input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Match production croppit.css input styling (field forms rely on this). */
input[type=number],
input[type=text],
input[type=date],
input[type=email],
input[type=password],
input[type=tel],
input[type=search],
textarea,
select,
input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 1px;
  margin: 1px 0; /* no horizontal margin — avoids width:100% + margin overflow */
  display: inline-block;
  border: 1px solid #aa1100;
  border-radius: 2px;
  box-sizing: border-box;
  font-size: 16px;
}

td > input[type=number],
td > input[type=text],
td > input[type=date],
td > input[type=email],
td > input[type=password],
td > input[type=tel],
td > input[type=search],
td > select,
td > textarea,
td > input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 1px 0;
  display: inline-block;
  box-sizing: border-box;
}

/* Range sliders (num_rows etc.) — keep usable slider chrome, not a bordered text box */
input[type=range],
td > input[type=range] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 28px;
  margin: 4px 0;
  padding: 0;
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
  box-sizing: border-box;
  vertical-align: middle;
  -webkit-appearance: auto;
  appearance: auto;
}

/* Date fields must keep calendar picker (type=date); do not restyle as plain text */
input[type=date],
td > input[type=date] {
  min-height: 1.8em;
  -webkit-appearance: auto;
  appearance: auto;
}

/* Checkboxes / radios must not stretch full width */
input[type=checkbox],
input[type=radio] {
  width: auto;
  max-width: none;
  display: inline-block;
  margin: 0 4px 0 0;
}

input[type=submit],
.button {
  width: auto;
  margin: 0px 0px 0px 0px;
  display: inline-block;
  background-color: var(--background-light);
  border: 1px solid #aa1100;
  border-radius: 5px;
  box-sizing: border-box;
  font-size: 18px;
  color: var(--text-color);
  cursor: pointer;
}

/* Planting form: intermediate action strips stay right-aligned like production */
.planting-form input[type=submit].planting_add,
.planting-form input[type=submit].planting_update,
.planting-form input[type=submit].planting_delete {
  width: auto;
  display: inline-block;
  margin-left: 4px;
}

.pot-hint {
  font-size: 14px;
  opacity: 0.85;
  margin: 0 0 10px 0;
}

/*
 * Zone map: DO NOT style nested <a>/<svg> inside the recursive map.
 * Production relies on default SVG/HTML layout; display:block on anchors
 * breaks nested child positioning (scale outer_x/outer_y).
 */

/* Field bed SVG only (production draw_planting.php inline styles) */
svg.bed {
  margin-top: 15px;
  margin-bottom: 15px;
  margin-left: 10px;
  margin-right: 10px;
  outline: 10px solid goldenrod;
  background: #663300;
  z-index: 0;
  overflow: auto;
}

#bed_date {
  width: 100%;
  max-width: 100%;
}

a.button {
  display: inline-block;
  width: auto;
  padding: 4px 10px;
  text-decoration: none;
  background-color: var(--background-light);
  border: 1px solid #aa1100;
  border-radius: 5px;
  color: var(--text-color);
  font-size: 16px;
}

a.button:hover {
  background-color: var(--hover-color);
  color: white;
}

/* Form tables in center column (pot edit) use full pane width */
.grid_mainc > form table,
.grid_mainc form.planting-form table,
.planting-form table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.planting-form table td {
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

input[type=submit]:hover,
.button:hover {
  background-color: var(--hover-color);
}

/*************** Button box  *******************/

#select {
  display: flex;
  flex-wrap: wrap;
  justify-content: left;
  width: 100%;
  outline: 2px;
  /*background-color: red;*/
}

#select a {
  text-decoration: none;
  display: block;
  width: 100%;
}

p.options {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-left: 3px;
  padding-right: 3px;
  border-radius: 20px;
  border-color: grey;
  border-style: solid;
  border-width: 5px;
  background-color: var(--background-light);
  background-position: center center;
  opacity: 0.9;
  height: 100px;
  width: 100px;
  margin: 2px;
  font-family: var(--font-family);
  color: var(--text-color);
  font-size: 20px;
  font-weight: bold;
  text-align: center;
}

p.options:hover {
  background-color: silver !important;
  color: var(--secondary-color) !important;
}


/***************  Styled table **************/

.styled {
  width: auto;
  border-collapse: collapse;
  font-family: var(--font-family);
  font-size: 16px;
}

.styled th {
  background-color: var(--primary-color);
  text-align: left;
  font-weight: bold;
  padding: 2px 10px 2px 2px;
}

.styled td {
  width: auto;
  text-align: left;
  padding: 2px 10px 2px 2px;
}

.styled tr:nth-child(even) {
  background-color: #f9f9f9;
}

.styled tr {
  background-color: #EBEBEB;
}

.styled tr:hover {
  background-color: #b5c29c !important;
}


/***************  Flip**************/


.flip-box {
  background-color: transparent;
  width: 100%;
  height: 200px;
  border: 1px solid #f1f1f1;
  perspective: 1000px;
  position: relative;
}

.flip-box-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}

.flip-box:hover .flip-box-inner,
.flip-box.flipped .flip-box-inner,
.flip-box:focus .flip-box-inner {
  transform: rotateY(180deg);
}

/* Touch devices: rely on .flipped (hover is flaky); still allow hover on desktop */
@media (hover: none) {
  .flip-box:hover .flip-box-inner {
    transform: none;
  }
  .flip-box.flipped .flip-box-inner {
    transform: rotateY(180deg);
  }
}

.flip-box-front {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  overflow: hidden;
}

.flip-box-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.flip-box-front {
  background-color: var(--background-light);
  color: black;
  border: 2px solid #aa1100;
  border-radius: 10px;

}

.flip-box-back {
  background-color: var(--background-light);
  color: var(--text-color);
  transform: rotateY(180deg);
  overflow: scroll;
  padding: 15px 15px;
  border: 2px solid #aa1100;
  border-radius: 10px;
}