/***********************/
/* FDA Nutrition Label */
/***********************/

.nutrition-label {
  margin: 2.5rem auto 0;
  max-width: 16rem;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.2;
  border: 1.5px solid #000;
  padding: 0.1875rem 0.3125rem;
  background: #fff;
  color: #000;
  text-align: left;
}

.nutrition-label h2 {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0;
  text-align: left;
}

.nutrition-label header {
  text-align: left;
  margin-bottom: 0;
}

.nutrition-label header::after {
  display: none;
}

.nutrition-label header p {
  font-family: inherit;
  font-style: normal;
  font-size: inherit;
  color: inherit;
}

.nutrition-label .servings {
  margin: 0;
  font-size: 0.75rem;
}

.nutrition-label .serving-size {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  padding-bottom: 0.125rem;
  border-bottom: 8px solid #000;
}

.nutrition-label .calories-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0;
  border-bottom: 4px solid #000;
}

.nutrition-label .calories-left {
  display: flex;
  flex-direction: column;
}

.nutrition-label .calories-row .amount-label {
  font-size: 0.5rem;
  font-weight: 700;
}

.nutrition-label .calories-row .label {
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
}

.nutrition-label .calories-row .value {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
}

.nutrition-label .dv-header {
  text-align: right;
  font-size: 0.6875rem;
  font-weight: 700;
  margin: 0;
  padding: 0.0625rem 0;
  border-bottom: 1px solid #000;
}

.nutrition-label .nutrient-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 0.0625rem 0;
  border-bottom: 1px solid #000;
}

.nutrition-label .nutrient-row:last-child {
  border-bottom: 7px solid #000;
}

.nutrition-label .nutrient-row.indent-1 {
  padding-left: 1.25em;
}

.nutrition-label .nutrient-row.indent-2 {
  padding-left: 2.5em;
}

.nutrition-label .nutrient-row .dv {
  white-space: nowrap;
}

.nutrition-label footer {
  font-family: inherit;
  color: inherit;
  margin-top: 0;
  padding-top: 0.1875rem;
  font-style: normal;
  font-weight: normal;
  text-align: left;
}

.nutrition-label footer p {
  font-size: 0.6875rem;
  font-weight: normal;
  margin: 0;
  line-height: 1.3;
}

.nutrition-footnote {
  font-size: 0.6875rem;
  font-style: italic;
  color: var(--text-soft);
  margin: 0.5rem 0 0;
  max-width: 16rem;
  margin-left: auto;
  margin-right: auto;
}
@media (prefers-color-scheme: dark) {
  .nutrition-label {
    border-color: var(--text);
    background: var(--ground);
    color: var(--text);
  }
  .nutrition-label .serving-size { border-bottom-color: var(--text); }
  .nutrition-label .calories-row { border-bottom-color: var(--text); }
  .nutrition-label .dv-header { border-bottom-color: var(--text); }
  .nutrition-label .nutrient-row { border-bottom-color: var(--text); }
  .nutrition-label .nutrient-row:last-child { border-bottom-color: var(--text); }
  .nf-thick-rule { border-top-color: var(--text); }
  .usda-results { border-color: var(--text); }
  .usda-result-item { border-bottom-color: var(--text); }
  .editor-density-candidates { border-color: var(--text); }
}
#nutrition-editor {
  width: min(100vw, 550px);
}
.recipe-unit-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
}
.recipe-unit-status { flex-shrink: 0; width: 1.2em; text-align: center; }
.recipe-unit-name { font-weight: 500; }
.recipe-unit-method { color: var(--text-soft); }

/* USDA search content (inside collapsible section) */
.usda-search-content {
  padding-top: 0.25rem;
}
.usda-search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.usda-search-row .input-base {
  flex: 1;
}
.usda-search-btn { white-space: nowrap; }
.usda-results {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--rule-faint);
  border-radius: 4px;
}
.usda-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.usda-result-item:last-child { border-bottom: none; }
.usda-result-item.loading .usda-result-info { opacity: 0.5; }
.usda-result-info {
  flex: 1;
  min-width: 0;
}
.usda-result-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usda-result-nutrients {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 0.15rem;
}
.usda-import-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--rule);
  padding: 0.25rem;
  flex-shrink: 0;
  border-radius: 3px;
  transition: color var(--duration-fast) ease;
}
@media (hover: hover) {
  .usda-import-btn:hover {
    color: var(--red);
  }
}
.usda-import-btn svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}
.usda-more-btn {
  display: block;
  width: 100%;
  padding: 0.4rem;
  text-align: center;
  background: none;
  border: none;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--red);
}
@media (hover: hover) {
  .usda-more-btn:hover {
    background: var(--hover-bg);
  }
}
.usda-no-results {
  padding: 0.75rem;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.85rem;
}
.usda-error {
  padding: 0.75rem;
  color: var(--danger-color);
  font-size: 0.85rem;
}
/* Nutrition Facts editor — FDA-inspired label styling */
.nf-editor {
  font-family: var(--font-body);
}

.nf-serving-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.nf-thick-rule {
  border-top: 4px solid var(--text);
  margin: 0.25rem 0;
}

.nf-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.125rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
}

.nf-row:last-child {
  border-bottom: none;
}

.nf-row.nf-calories {
  font-size: 1rem;
  font-weight: 900;
  padding: 0.2rem 0;
}

.nf-row.nf-calories .input-base {
  font-weight: 900;
  font-size: 1rem;
}

.nf-row.nf-indent {
  padding-left: 1.25em;
}

.nf-row.nf-indent .nf-name {
  font-weight: normal;
}

.nf-name {
  flex: 1;
  font-weight: 700;
  font-size: inherit;
}

/* Hide spin buttons on all number inputs in editor */
.editor-section input[type="number"]::-webkit-inner-spin-button,
.editor-section input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.editor-section input[type="number"] {
  -moz-appearance: textbox;
}

.nf-unit {
  font-size: 0.75rem;
  color: var(--text-soft);
  min-width: 1.25rem;
}

.editor-density-candidates {
  margin: -0.5rem 0 1rem;
  padding: 0;
  border: 1px solid var(--rule-faint);
  border-radius: 4px;
}
.editor-density-candidates[open] { padding: 0 0.75rem 0.75rem; }
.editor-density-candidates > summary {
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}
.editor-density-candidate-row {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.85rem;
  cursor: pointer;
}
@media (hover: hover) {
  .editor-density-candidate-row:hover {
    color: var(--red);
  }
}
.editor-density-candidate-row input[type="radio"] { margin-right: 0.4rem; }

.editor-form-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.editor-form-row > label {
  font-size: 0.9rem;
  min-width: 5rem;
  flex-shrink: 0;
}


.editor-field-unit {
  font-size: 0.85rem;
  color: var(--text-soft);
  min-width: 1.5rem;
}

.editor-portion-eq {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.editor-density-row {
  margin-bottom: 0.5rem;
}

/* Portion rows */
.editor-portion-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}


.editor-portion-unit {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.editor-btn-icon {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  border-radius: 3px;
}

@media (hover: hover) {
  .editor-btn-icon:hover {
    color: var(--danger-color);
    background: var(--danger-hover-bg);
  }
}

.editor-add-portion {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Alias chips */
.editor-alias-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
  min-height: 1.5rem;
}

.editor-alias-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  font-size: 0.85rem;
  line-height: 1.3;
}

.editor-alias-remove {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
}

@media (hover: hover) {
  .editor-alias-remove:hover {
    color: var(--danger-color);
  }
}

.editor-alias-add-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.editor-alias-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
}

.editor-add-alias {
  font-size: 0.85rem;
}

.aisle-form-select,
.aisle-new-input {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--rule-faint);
  border-radius: 3px;
  background: var(--input-bg);
  color: var(--text);
  min-width: 0;
  flex: 1;
}

.aisle-form-select:focus,
.aisle-new-input:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
  border-color: var(--red);
}

/* iOS zoom prevention: all form inputs in the editor need 1rem+ */
.editor-form input[type="number"],
.editor-form select,
.editor-form input[type="text"] {
  font-size: 1rem;
}

.editor-omit-row { margin-top: 0.4rem; }

/* Outer cards (Grocery Aisle, Aliases — always visible) */
.editor-card {
  border: 1px solid var(--rule-faint);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--ground);
}
.editor-field-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin-bottom: 0.25rem;
}

/* Empty-state hint text (inline, same height as chips so nothing shifts) */
.editor-empty-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
}

/* Divider between top fields and nutrition section */
.editor-divider {
  border: none;
  border-top: 1px solid var(--rule-faint);
  margin: 1rem 0;
}

/* Inner cards (nutrition subsections — halfway between ground and white) */
.editor-inner-card {
  background: color-mix(in srgb, var(--ground) 50%, white);
  border: 1px solid var(--rule-faint);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.editor-inner-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  margin: 0 0 0.5rem;
}

/* Subsections within an inner card (separated by top border) */
.editor-subsection { padding-top: 0.65rem; margin-top: 0.65rem; border-top: 1px solid var(--rule-faint); }
.editor-subsection:first-child { padding-top: 0; margin-top: 0; border-top: none; }
.editor-subsection-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.35rem;
}

/* Compact nutrition summary */
.nf-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  padding: 0.25rem 0;
}
.nf-summary strong { color: var(--text); font-weight: 600; }

/* Nutrient details disclosure — animated via grid rows */
.nf-disclosure { margin-top: 0.35rem; }
.nf-disclosure summary {
  font-size: 0.8rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.15rem 0;
}
@media (hover: hover) {
  .nf-disclosure summary:hover {
    color: var(--red);
  }
}
.nf-disclosure-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}
.nf-disclosure[open] .nf-disclosure-body {
  grid-template-rows: 1fr;
}
.nf-disclosure-body > * { overflow: hidden; }

/* Derived volume conversions */
/* Recipe Check: unresolved row */
.recipe-unit-unresolved {
  background: color-mix(in srgb, var(--red) 8%, transparent);
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
}

/* Collapsed summary metadata */
.editor-summary-meta {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-light);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
