/* Tab bar component — pure CSS tabs using radio inputs.
   Works without JavaScript (critical for iOS Safari local file:// viewing).
   Days are grouped inside a <details> dropdown to keep the bar compact. */

.tab-radio { display: none; }

.tab-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  gap: 0.4rem;
  overflow: visible;
}

.tab-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

/* All tab content hidden by default */
.tab-content { display: none; }

/* ── Active tab label highlighting ── */
#tab-r-summary:checked  ~ .tab-bar .tab-btn[for="tab-r-summary"],
#tab-r-shopping:checked ~ .tab-bar .tab-btn[for="tab-r-shopping"] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* Highlight the "Days" summary when any day radio is checked */
#tab-r-monday:checked    ~ .tab-bar .days-dropdown > summary,
#tab-r-tuesday:checked   ~ .tab-bar .days-dropdown > summary,
#tab-r-wednesday:checked ~ .tab-bar .days-dropdown > summary,
#tab-r-thursday:checked  ~ .tab-bar .days-dropdown > summary,
#tab-r-friday:checked    ~ .tab-bar .days-dropdown > summary,
#tab-r-saturday:checked  ~ .tab-bar .days-dropdown > summary,
#tab-r-sunday:checked    ~ .tab-bar .days-dropdown > summary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* Highlight the selected day label inside the dropdown */
#tab-r-monday:checked    ~ .tab-bar .day-label[for="tab-r-monday"],
#tab-r-tuesday:checked   ~ .tab-bar .day-label[for="tab-r-tuesday"],
#tab-r-wednesday:checked ~ .tab-bar .day-label[for="tab-r-wednesday"],
#tab-r-thursday:checked  ~ .tab-bar .day-label[for="tab-r-thursday"],
#tab-r-friday:checked    ~ .tab-bar .day-label[for="tab-r-friday"],
#tab-r-saturday:checked  ~ .tab-bar .day-label[for="tab-r-saturday"],
#tab-r-sunday:checked    ~ .tab-bar .day-label[for="tab-r-sunday"] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* ── Show the matching tab content section ── */
#tab-r-summary:checked   ~ .tab-c-summary,
#tab-r-shopping:checked  ~ .tab-c-shopping,
#tab-r-monday:checked    ~ .tab-c-monday,
#tab-r-tuesday:checked   ~ .tab-c-tuesday,
#tab-r-wednesday:checked ~ .tab-c-wednesday,
#tab-r-thursday:checked  ~ .tab-c-thursday,
#tab-r-friday:checked    ~ .tab-c-friday,
#tab-r-saturday:checked  ~ .tab-c-saturday,
#tab-r-sunday:checked    ~ .tab-c-sunday {
  display: block;
}

/* ── Days dropdown (native <details>/<summary>) ── */
.days-dropdown {
  position: relative;
  flex-shrink: 0;
}
.days-dropdown > summary {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.days-dropdown > summary::-webkit-details-marker { display: none; }
.days-dropdown > summary::marker { display: none; content: ""; }
.days-dropdown > summary:hover {
  background: var(--surface2);
  color: var(--text);
}
.days-dropdown > summary::after {
  content: " \25BE";
  font-size: 0.75em;
  margin-left: 0.3em;
}

.days-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  min-width: 140px;
}
.day-label {
  display: block;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.1s ease;
}
.day-label:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Recipes collapsible — uses native <details>/<summary> ── */
.recipes-details { margin-top: 1.5rem; }
.recipes-details > summary {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.recipes-details > summary::-webkit-details-marker { display: none; }
.recipes-details > summary::marker { display: none; content: ""; }
.recipes-details > summary:hover { background: var(--surface2); }
.recipes-details > .recipes-section { display: block; margin-top: 1rem; }
