/* =========================================================
   Root variables
   ========================================================= */
:root {
  --modal-w: 720px;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0,0,0,.18);
  --line: #dfe5eb;
  --text: #101828;
  --muted: #6c7a86;
  --bg: #f2f6fa;
  --white: #fff;
  --green: #2ea44f;
}

/* =========================================================
   Global / layout
   ========================================================= */
body.modal-open { overflow: hidden; }

body {
  background: #F2F6FA;
}

.list-wrap {
  max-width: 780px;
  margin: 140px auto 60px;
  padding: 0 16px;
  min-height: 65vh;
}

.hidden { display: none !important; }

/* Don’t flash empty states during initial/refresh loads */
body.list-loading #emptyList,
body.list-loading #emptyHistory { display: none !important; }


/* =========================================================
   Aisles & items
   ========================================================= */
.aisle { margin: 18px 0; }

.aisle h3,
.checked-list h3.checked-date {
  font-size: 14px;
  margin: 14px 0 0;
  padding: 10px;
  border-radius: 5px 5px 0 0;
  font-weight: 600;
  background: #dbe3e8e6;
  color: #03304169;
}

.item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: #fff;
  border-radius: 0;
  margin: 0;
  border-bottom: 1px solid #80808033;
}

.item:hover,
.item.checked:hover {
    background: #ffffff59;
}

.item .name {
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--text);
  font-size: 20px;
  width: fit-content;
}

.item .note { font-size: 12px; color: var(--muted); }
.meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

.item .icon-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  color: #506275;
  padding: 0;
  margin: 0;
}

/* Optional edit actions reveal (kept in case actions are present) */
.item .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.item:hover .actions,
.item:focus-within .actions { opacity: 1; pointer-events: auto; }

/* Clickable text region */
.item .click-target { flex: 1; cursor: pointer; }
/*.item .click-target:focus {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
  border-radius: 6px;
}*/

/* Checked items */
.item.checked { background: #ffffff; }
.item.checked .name {
  text-decoration: line-through;
  color: #97a2a7;
  font-style: italic;
}

/* Checkboxes in list */
.list-wrap input[type="checkbox"] {
  margin: 0;
  width: 20px;
  height: 20px;
  order: 2;
}

/* =========================================================
   History section
   ========================================================= */
.checked-list { margin-top: 24px; }
.checked-list.hidden { display: none; }

.checked-list h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 30px;
  margin-top: 50px;
}

.btn-clear { font-size: 12px; margin-left: 8px; }
.checked-list a#btnClear { margin: 0; }

.history-header {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-top: 50px;
}
.history-header .hdr-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.history-header .hdr-group button#historyToggle {
  padding: 0;
  margin: 0;
  background: white;
  height: 30px;
  width: 30px;
  border-radius: 50px;
  border: 1px solid #03304138;
  margin-right: 15px;
}
.history-header .hdr-group button#historyToggle i { color: #033041; }

.history-header .caret {
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .18s ease;
}
#checkedWrap.collapsed .caret { transform: rotate(-90deg); }
#checkedWrap.collapsed #checked { display: none; }

.checked-date { font-size: 14px; color: #67717c; margin: 14px 0 6px; }

.checked-list h2#list-history,
.checked-list h2#list-history:hover { cursor: pointer !important; }
#list-history:focus { outline: 2px solid #9ca3af; outline-offset: 2px; }

/* =========================================================
   Add bar (sticky)
   ========================================================= */
.addbar {
  display: flex;
  gap: 0;
  position: sticky;
  top: 80px;
  z-index: 81;
  background: var(--bg);
  padding: 17px 0 0;
  margin-bottom: 50px;
  /* stronger shadow for the sticky bar */
  box-shadow: 0 20px 25px 10px var(--bg);
}

input[type="text"]#addText {
  margin: 0;
  height: 55px;
  border-radius: 5px 0 0 5px;
}

.addbar a#btnAdd {
  margin: 0;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 35px;
  border-radius: 0 5px 5px 0;
}

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  font-size: 13px;
  z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.flash { animation: flash-bg 1.2s ease-out 1; }
@keyframes flash-bg { 0% { background:#fff8d6; } 100% { background:#fff; } }

/* =========================================================
   Modal (edit/settings/bulk)
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(17 24 39 / 76%);
  display: none;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.open { display: flex; }

.modal {
  width: min(100%, var(--modal-w));
  max-width: 475px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 80px);
  overflow: auto;
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
#editBackdrop header,
#settingsBackdrop header,
#bulkBackdrop header,
#mobileActionsBackdrop header { padding: 0 25px; }

.modal h3 { margin: 0; font-size: 20px; }
#editBackdrop header h3,
#settingsBackdrop header h3,
#bulkBackdrop header h3,
#mobileActionsBackdrop header h3 { color: #334155; font-size: 25px; }

.modal .xbtn {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  color: #334155;
}
#editBackdrop header button#modalClose,
#settingsBackdrop button#settingsClose,
#bulkBackdrop button#bulkClose,
#mobileActionsBackdrop  button#mobileActionsClose {
  margin: 0;
  padding: 15px;
  font-size: 40px;
}

.modal .content { padding: 20px 22px; }
.modal .content .row { margin-bottom: 14px; }
.modal .content label { user-select: none; }
.modal .content .desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

#settingsBackdrop .content .row,
#bulkBackdrop .content .row { padding: 5px !important; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid .span2 { grid-column: 1 / -1; }

#editBackdrop .modal .grid { gap: 10px; }

.field label {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 6px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.field input,
.field select {
  width: 100%;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
#editBackdrop .modal .field input,
#editBackdrop .modal .field select {
  border: 1px solid #3341559e;
  border-radius: 5px;
}

.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}
.icon-trash {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: #475569;
}
.actions-row { display: flex; gap: 10px; }
.btn-green {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}
.btn-green:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary {
  background: #eef2f6;
  color: #111827;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}

/* Specific modal max widths */
#editBackdrop .modal,
#settingsBackdrop .modal,
#bulkBackdrop .modal { max-width: 450px !important; }

/* =========================================================
   Action buttons (floating share/print)
   ========================================================= */
.action-btns {
  position: fixed;
  top: 200px;
  right: 100px;
}
.action-btns div {
  background: #033041;
  width: 50px;
  height: 50px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
}
.action-btns div i { color: white; font-size: 20px; }
.action-btns div:hover { cursor: pointer; }

@media (max-width: 1100px) {
  .action-btns {display: none;}
  .toolbar .mobile-only { display: block !important; }
}


/* =========================================================
   Title Tools
   ========================================================= */

  /* Layout switch */
  .title-tools {
    display:flex; justify-content:space-between; align-items:center; margin-bottom:15px;
  }
  .mobile-actions-btn { display:none; border:none; background:#f3f4f6; padding:8px 10px; border-radius:10px; }
  .mobile-actions-btn i { font-size:18px; color:#111827; }

  @media (max-width: 1100px) {
    .toolbar { display:none !important; }
    .mobile-actions-btn { display:inline-flex; align-items:center; }
  }

  /* Mobile actions modal bits (piggybacks on your .modal styles) */
  .ma-view.hidden { display:none; }
  .ma-row {
    width:100%; text-align:left; display:flex; align-items:center; gap:10px;
    padding:10px 12px; border:1px solid #e5e7eb; border-radius:10px; background:#fff; margin:8px 0;
  }
  .ma-row .chev { margin-left:auto; opacity:.6; }
  .ma-row.danger { border-color:#fee2e2; background:#fff; color:#b91c1c; }
  .ma-row i { width:18px; text-align:center; }
  .ma-subhead { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
  .ma-back {
    background:#f3f4f6; border:1px solid #e5e7eb; border-radius:8px; padding:6px 10px;
  }

  .modal-backdrop .content button {
    color: #033041;
  }
  .modal-backdrop .content button:hover,
  .modal-backdrop .content button:focus {
      color: white;
  }
  .ma-row.danger:hover,
  .ma-row.danger:focus {
      border-color: #b91c1c;
      background: #033041;
      color: white;
  }
  button#btnMobileActions {
      margin: 0;
      padding: 12px 25px
  }
  button#btnMobileActions:hover,
  button#btnMobileActions:focus {
      background: white;
  }
  .ma-subhead {
    margin: 15px 0 20px;
  }
  .ma-subhead button {
      margin: 0;
  }
  .ma-subhead h4 {
      margin: 0;
      color: #033041;
      font-weight: 500;
  }



/* =========================================================
   Toolbar & dropdowns
   ========================================================= */

  .toolbar { display: flex; gap: 10px; align-items: center; }

  .toolbar .button.tiny,
  .checked-list .button.tiny {
    padding: 8px 12px;
    font-size: 16px;
    margin: 0;
    background: white;
    border: 2px solid #03304129;
    color: #033041;
    border-radius: 8px;
  }

  a.button.tiny.primary { color: #ed5840; }

  .toolbar .mobile-only { display: none; }


  @media (max-width: 768px) {
    /*.toolbar .mobile-only { display: block; }*/
    .hide-on-mobile { display: none; }

    /*.title-tools {
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 25px;
    }*/
  }

  /* Generic dropdown */
  .dd { position: relative; }
  .dd-toggle { position: relative; }

  .dd-menu {
    position: absolute;
    right: 0;
    top: 110%;
    min-width: 220px;
    padding: 6px;
    background: #fff;
    border: 1px solid #e5ebf2;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    display: none;
    z-index: 2000;
  }
  .dd.open .dd-menu { display: block; }

  .dd-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: #fff;
    border: 0;
    cursor: pointer;
    color: #111827;
    border-radius: 8px;
    margin: 0;
    white-space: nowrap;
    margin-right: 15px;
  }
  .dd-menu button:hover { background: #f4f7fa; }
  .dd-menu i { width: 16px; text-align: center; }
  #bulkClear i { color: #ca3f0c; }
  #bulkAdd i  { color: #77b433; }

/* =========================================================
   Empty states
   ========================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 22px;
  margin: 16px 0;
  background: #ffffff;
  border: 1px dashed #acafb6;
  border-radius: 12px;
  color: #6b7280;
  min-height: 300px;
  justify-content: center;
}
.empty-state .icon { width: 48px; height: 48px; opacity: .7; margin-bottom: 6px; }
.empty-state h4 { margin: 0; font-size: 16px; color: #374151; }
.empty-state p  { margin: 0; font-size: 13px; }

/* =========================================================
   Bulk modal specifics
   ========================================================= */
#bulkBackdrop .row { width: 100% !important; padding: 0 0 25px 0; font-size: 16px !important; }
#bulkBackdrop .row .desc { font-size: 14px !important; line-height: 26px; color: black; }

/* =========================================================
   Print: only the current list (#groups)
   ========================================================= */
@media print {
  body * { visibility: hidden !important; }
  #groups, #groups * { visibility: visible !important; }

  #groups {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
  }

  #groups:before {
    content: "My Shopping List";
    display: block;
    width: 100%;
    border-bottom: 1px solid black;
    font-weight: bold;
    font-size: 25px;
  }
  #groups:after {
    border-top: 1px solid black;
    display: block;
    width: 100%;
    padding-top: 20px;
    margin-top: 20px;
    content: "https://recipecloudapp.com | Recipe Cloud App";
    font-weight: bold;
    font-size: 20px;
  }

  .aisle { break-inside: avoid; page-break-inside: avoid; }
  a[href]::after { content: ""; }
}



/* =========================================================
   New Checkboxes (large hit area, right-aligned)
   ========================================================= */

.item { position: relative; }

/* Hide the real checkbox but keep it accessible */
.item .cb {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none; /* clicks go to the label */
}

/* Large clickable label on the right (forgiving hit area) */
.item .cb-ui {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;              /* generous tap target */
  height: 44px;
  cursor: pointer;
  z-index: 3;               /* above .click-target */
}

/* Visual box inside the big label */
.item .cb-ui::before {
  content: "";
  position: absolute;
  right: 9px;               /* centers the box within 44px area */
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 2px solid #5c768d;      /* outline */
  border-radius: 7px;
  background: #fff;
  box-sizing: border-box;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

/* The checkmark (hidden by default) */
.item .cb-ui::after {
  content: "";
  position: absolute;
  right: 16px;              /* aligns inside the 22px box */
  top: 50%;
  width: 6px;
  height: 12px;
  border: solid #033041;
  border-width: 0 2px 2px 0;
  transform: translateY(-60%) rotate(45deg) scale(.95);
  opacity: 0;
  transition: opacity .12s ease-in;
}

/* Keep text clear of the control */
.item .click-target {
  position: relative;
  padding-right: 68px;      /* room for 44px hit area + spacing */
  user-select: none;
  z-index: 1;
  cursor: default;          /* no longer clickable */
}
.item .name { cursor: pointer; }  /* only title opens modal */

/* Focus ring for keyboard users (on the hidden input) */
.item .cb:focus-visible + .cb-ui::before {
  box-shadow: 0 0 0 3px rgba(3,48,65,.25);
  border-color: #033041;
}

/* ===== Checked states =====
   We support BOTH:
   1) <input> checked (normal unchecked list)
   2) .item.checked class (history rows rendered as checked)
*/

/* Outline + fill when checked */
.item .cb:checked + .cb-ui::before,
.item.checked .cb-ui::before {
  border-color: #033041;
  background: #eef4f7;
}

/* Show the checkmark */
.item .cb:checked + .cb-ui::after,
.item.checked .cb-ui::after {
  opacity: 1;
}

/* Hover polish: outline + preview checkmark */
.item .cb-ui:hover::before {
  border-color: #375a73;
}
.item .cb-ui:hover::after {
  opacity: .5;              /* faint checkmark preview */
}
.item .cb:checked + .cb-ui:hover::after,
.item.checked .cb-ui:hover::after {
  opacity: 1;               /* full opacity if actually checked */
}




/* =========================================================
   Mobile Styles
   ========================================================= */

   @media (max-width: 768px) {
    .item .name {
      font-size: 16px
      }
      .item .click-target {
          position: relative;
          padding-right: 30px;
          user-select: none;
          z-index: 1;
          cursor: default;
      }
      .addbar a#btnAdd {
          margin: 0;
          height: 45px;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 0 20px;
          border-radius: 0 5px 5px 0;
      }
      input[type="text"]#addText {
          margin: 0;
          height: 45px;
          border-radius: 5px 0 0 5px;
      }
   }



