:root {
  --bg-page: #fffdf8; --color-text: #4b3b2b;
  --bg-toolbar: #D0ACAC; --bg-panel: #f7e7ce;
  --color-border: #d4b98c;
  --button-highlight: #C88F4A;
  --button-highlight-hover: #B47D3F;
  --space-sm: 8px;    --space-md: 16px;   --space-lg: 24px;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Georgia', serif;
  background-color: var(--bg-page);
  color: var(--color-text);
  overflow-x: hidden;
}

#headerWrapper {
  position: sticky; /*fixed*/ /*HÄR*/
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  background: #eee;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  z-index: 1049;
  will-change: transform; /*TEST*/
}
.titleRow {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-toolbar);
  z-index: 1015;
}

.titleRow::before {
  content: "";
  display: block;
  height: 24px;
}

#logo {
  height: 100px;
  margin-bottom: 4px;
}

.title-input-container {
  flex: 1;
  width: 100%;
  padding: 0 0 0 var(--space-sm);
  box-sizing: border-box;        /* include that padding inside the 100% */
  max-width: none;               /* let it go full‑bleed if you want */
  margin: 0 0 0;   /* vertical spacing below the logo */
  text-align: center;
}

/* ── Modern, rounded input styling ── */
.title-input-container #titleInput {
  width: 100%;
  max-width: 700px;
  margin: 0px auto 0;
  text-align: left;    /* keep the text centered inside */
  padding: 12px 16px;
  font-size: 1.1rem;
  color: gray;
  font-style: normal; 
  background-color: #f0f0f0;
  border: none;              
  border-radius: 12px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
  transition: 
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    color 0.2s ease,
    font-style 0.2s ease;
  box-sizing: border-box;
}

.title-input-container #titleInput {
  width: 100%;
}

.title-input-container #titleInput:focus {
  outline: none;
  background-color: var(--bg-page);
  color: var(--color-text);        /* switch to black text */
  font-style: normal;     /* switch to normal font */
}

#titleInput::placeholder {
  color: gray;
  font-style: normal;
}

#toolbar {
  display: flex;
  position: relative;
  background: var(--bg-toolbar);
  min-height: 60px;
  justify-content: flex-start;
  align-items: center;
  padding: var(--space-sm);
  width: 100%;
  box-sizing: border-box;
  font-family: 'Georgia', serif;
  text-align: center;
  z-index: 1002;
}
.hamburger {
  display: flex;
  position: relative;
  background: var(--bg-panel);
  border: none;
  border-radius: 8px;
  padding: 8px;
  z-index: 1020;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  width: 60px;
  height: 40px;
  cursor: pointer;
  pointer-events: auto;
  margin: 0;
}
.hamburger span {
  display: block;
  width: 60%;
  height: 3px;
  background: var(--color-text);
  border-radius: 2px;
  margin: 0;
}
.hamburger .menu-text {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1;
}
.hamburger:hover {
  background: #eedeb7;
}
.toolbar-items {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-toolbar);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  box-sizing: border-box;
  z-index: 1049;
}

.toolbar-items.active {
  display: flex;
}

#toolbar button:not(.hamburger) {
  display: flex;
  align-items: center;
  text-align: left;        /* keep your left‑aligned text */
  padding-left: var(--space-md);
}

.btn-icon {
  font-size: 18px !important;

  /* make the box exactly the same size */
  width: 16px !important;
  height: 16px !important;

  /* inline-block so line-height is respected */
  display: inline-block !important;
  vertical-align: middle;

  /* center the ligature inside that box */
  line-height: 16px !important;
  text-align: center !important;
  margin-right: 12px;
  color: var(--color-text);
}

#toolbar select,
#toolbar button:not(.hamburger) {
  background-color: var(--bg-panel);
  border: 1px solid var(--color-border);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s ease;
  line-height: 1;
  height: 46px;
}

#toolbar #sumButtonMobile {
  justify-content: center !important;
  text-align: center !important;
  padding-left: 0 !important;
}

/* Hover for normal buttons */
#toolbar button:hover:not(.sum-btn):not(.hamburger),
#toolbar select:hover {
  background-color: #e6d3b3;
  border-color: #c2a77a;
}

#toolbar button.sum-btn {
  background-color: var(--button-highlight);
  color:#fff;
  font-weight:bold;
}

/* Hover/focus for enabled sum button */
#toolbar button.sum-btn:not([disabled]):hover,
#toolbar button.sum-btn:not([disabled]):focus-visible{
  background-color: var(--button-highlight-hover);
}

/* 3. Disabled state — keep highlight, just fade */
#toolbar button.sum-btn[disabled]{
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

#toolbar label,
#toolbar input,
.toolbar-items button,
.toolbar-items select {
  width: 100%;
  font-size: 0.9rem;
  padding: 10px;
}

#toolbar select {
  min-width: 240px;
}

/* Floating Action Buttons - Core Styles */
.floating-buttons {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1020;
}

.floating-buttons button {
  background-color: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: 'Georgia', serif;
  color: var(--color-text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
}

/* Button States */
.floating-buttons button:not(:disabled) {
  opacity: 1;
  filter: none;
}

.floating-buttons button:disabled {
  opacity: 0.5;
  filter: grayscale(80%);
  background-color: rgba(208, 172, 172, 0.3);
  border-color: rgba(212, 184, 140, 0.4);
  pointer-events: none;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Icons */
.floating-buttons button .material-icons {
  font-size: 24px;
  color: var(--color-text);
  transition: color 0.3s ease;
}

.floating-buttons button:disabled .material-icons {
  color: rgba(75, 59, 43, 0.3);
}

/* Hover Effects */
.floating-buttons button:not(:disabled):hover {
  background-color: #e6d3b3;
  transform: translateY(-2px);
}

/* Material Icons Base (keep this) */
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#canvasContainer {
  position: relative;
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  z-index: 0;
}

#canvas {
  display: block;
  margin: 0;    /* no auto-centering or extra gaps */
  background-color: var(--bg-page);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 1);
  cursor: pointer;
  touch-action: auto;     /* allow swipes on empty space to scroll the wrapper */
}

#siteNotice {
  display: none;
  position: fixed;
  top: calc(56px + 16px);
  left: 8px; right: 8px;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 1050;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 96px);
  font-family: inherit;
  color: var(--color-text);
}

#siteNotice .close-site-notice {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  min-width: 48px;
  min-height: 48px;
}

#siteNotice h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}
#siteNotice p {
  margin: 0 0 12px;
  line-height: 1.4;
}
#siteNotice ol {
  margin: 0 0 0;
  padding-left: 20px;
}
#siteNotice ol li {
  margin-bottom: 6px;
  line-height: 1.4;
}

#summaryBox, #userFormBox {
  max-width: 400px;
  background: #fffef9;
  border: 1px solid var(--color-border);
  padding: 20px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

#summaryBox p, #userFormBox p {
  margin: 0 0 8px;
  font-weight: bold;
  color: var(--color-text);
}

#summaryBox select, #summaryBox button,
#userFormBox input, #userFormBox button, #userFormBox select {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  background-color: var(--bg-page);
  border-radius: 6px;
}

#summaryBox button,
#userFormBox button {
  background-color: var(--bg-panel);
  color: var(--color-text);
  padding: 8px 14px;
  margin-top: 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
}

#summaryBox button:hover,
#userFormBox button:hover {
  background-color: #e6d3b3;
}

#summaryBox button:last-of-type {
  background-color: #6c757d;
}

.quantity-control {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  padding: 10px;
  background-color: #f7f7f7;
  border-radius: 8px;
  border: 1px solid #ddd;
}

.quantity-control label {
  font-weight: bold;
  margin-bottom: 6px;
}

.quantity-control div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.quantity-control button {
  width: 30px;
  height: 30px;
  font-size: 18px;
  border: none;
  border-radius: 4px;
  background-color: #ddd;
  cursor: pointer;
}

.quantity-control span {
  min-width: 24px;
  text-align: center;
  font-family: monospace;
}

.quantity-control small {
  font-size: 12px;
  color: #666;
  margin-left: 4px;
}

#summaryBox small, #userFormBox small {
  display: block;
  margin-top: 10px;
  color: #555;
}

#summaryBox {
  padding: 20px 30px; /* Minska topp/botten-padding (tidigare t.ex. 20px 30px?) */
  max-height: 95vh;   /* Så rutan aldrig blir högre än 90% av skärmen */
  overflow-y: auto;   /* Visa scroll om innehållet är för långt */
}
.nav-bar {
  position: absolute;
  top: 20px;
  right: 30px;
  font-family: 'Segoe UI', sans-serif;
}

.nav-bar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 16px;
}

.nav-bar a {
  text-decoration: none;
  color: #fff;
  font-weight: bold;
  background-color: rgba(208, 172, 172, 0.8);
  padding: 8px 14px;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.nav-bar a:hover {
  background-color: rgba(208, 172, 172, 1);
}

/* 1. The semi-transparent backdrop covers the whole viewport */
#modalOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
}

/* 2. The checklist modal—responsive width + max-height */
#checklistContainer {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #f9f7f1;
  border: 1px solid #ddd;
  padding: 12px 12px 32px;  /* top/right 12px, bottom 32px */
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10001;

  width: 90%;
  max-width: 400px;
  max-height: 80vh;         /* never taller than 80% of viewport */
  overflow-x: hidden;
  overflow-y: auto;         /* scroll if very long */
  border-radius: 8px;
}

/* 3. Close button in top-right */
#checklistContainer .close-modal {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

#checklistContainer .remove-item,
#checklistContainer .controls button {
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* 4. Checklist items align neatly */
#checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
#checklistContainer h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}
#checklist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #e0dcd5;
}
#checklist li:last-child {
  border-bottom: none;
}

/* 5. Inside each li: label+checkbox on left, remove-button on right */
#checklist li label {
  display: flex;
  align-items: center;
  flex: 1;
}
#checklist li label input[type="checkbox"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
}
#checklist li .remove-item {
  background: #f3e0bd;
  border: 1px solid #dbccab;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

/* 6. Bottom controls: new-item + buttons */
#checklistContainer .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
#checklistContainer .controls input[type="text"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #dbccab;
  border-radius: 6px;
  box-sizing: border-box;
}
#checklistContainer .controls button {
  background: #f3e0bd;
  border: 1px solid #dbccab;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- Desktop --- (större än ipad) */
@media screen and (min-width: 1600px) {
  #toolbar {
    display: flex;
    align-items: center;
    justify-content: center;    /* or flex-start, as you prefer */
    flex-wrap: nowrap;
    gap: var(--space-sm);        /* space between title‐input and toolbar-items */
    padding: 4px var(--space-sm);/* top/bottom 4px, left/right var(--space-sm) */
    min-height: 100px;
  }

  /* 2) Title‑input sits to the left, no extra margins needed */
  .title-input-container {
    flex: 0 0 auto;             /* don’t grow/shrink */
    max-width: 400px;
  }

  /* 3) Toolbar‑items as a simple flex row with the same gap */
  .toolbar-items {
    display: flex !important;
    flex-direction: row;
    gap: var(--space-sm);        /* same gap between buttons */
    position: static;
    background: transparent;
    box-shadow: none;
    margin: 0;                   /* reset any old margins */
  }

  /* 4) Remove per‑button margins—gap on parent covers it */
  .toolbar-items > * {
    min-width: 0;
  }

  /* prevent wrapping and enable ellipsis */
  .toolbar-items > button,
  .toolbar-items > select {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 140px;
  }

  .toolbar-items > button .btn-icon {
    display: none !important;
  }

  .toolbar-items > button:not(.hamburger) {
    justify-content: center;
    text-align: center;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  #toolbar button#sumButtonMobile {
    padding: 0 !important;
    flex: 0 0 160px;           /* set explicit width */
  }

  .hamburger {
    display: none;
  }
  
  #siteNotice {
    top: calc(174px);
    padding: 24px;
    max-width: 500px;
    left: calc(50% - 250px);
    right: auto;
  }
  #siteNotice h2 {
    font-size: 1.6rem;
    margin-bottom: 12px;
  }
  #siteNotice p {
    margin-bottom: 16px;
  }
  #siteNotice ol li {
    margin-bottom: 8px;
    font-size: 1.1rem;
  }

  #checklistContainer {
    overflow-x: auto;
    padding: 16px;
  }
  #checklistContainer h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
  }
  #checklist li {
    padding: 8px 0;
  }
  #checklistContainer .remove-item,
  #checklistContainer .controls button {
    padding: 6px 12px;
    font-size: 1rem;
  }
}

@supports (-webkit-touch-callout: none) {
  /* Ensure sticky works on iOS */ /*HÄR*/
  #headerWrapper {
    position: -webkit-sticky;
    width: 100%;
    top: 0;
  }

  /*Hindra scroll-to-refresh i telefon*/
  html, body {
    height: 100%;
    overflow: hidden;             /* prevent body from scrolling */
  }
  #canvasContainer {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /*HIT*/
  
  /* Prevent double-fixed conflicts */
  body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  input, textarea, select {
    font-size: 16px !important;
    min-height: 44px !important;
  }
}
