/* Checklist-specific styles — builds on styles.css design system tokens */

:root {
  --checklist-padding: 16px;
}

body.checklist-standalone {
  padding: var(--checklist-padding);
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.checklist-app {
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 24px;
}

.checklist-app.meal-prep-active {
  width: 100%;
  max-width: none;
}

/* Header: title + eyebrow + progress */
.checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.checklist-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.checklist-title {
  font-size: 28px;
  font-weight: 780;
  line-height: 1.05;
  margin: 0;
}

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

.progress-text {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.progress-ring {
  width: 34px;
  height: 34px;
}

/* Tab switcher */
.checklist-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.checklist-tab {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
  font-weight: 650;
}

.checklist-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.checklist-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Add item row */
.checklist-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.checklist-add-row input {
  flex: 1;
}

.checklist-add-row button {
  min-width: 60px;
  flex-shrink: 0;
}

/* Suggested chips section */
.checklist-suggested {
  margin: 16px 0;
}

.checklist-suggested-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.checklist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checklist-chip {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
  min-height: 32px;
}

.checklist-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.checklist-chip-plus {
  color: var(--accent);
  font-weight: 800;
}

.checklist-chip-why {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

/* Category headers */
.checklist-category {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
}

.checklist-category-name {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

.checklist-category-rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.checklist-category-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

/* List body container */
.checklist-list-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checklist-checked-toggle {
  width: 100%;
  margin: 14px 0 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.checklist-checked-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Individual checklist item */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: text;
  transition: background 120ms ease;
  min-height: 44px;
}

.checklist-item:hover {
  background: var(--surface-subtle);
}

.checklist-item.pending {
  background: var(--accent-soft);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
  opacity: 0.86;
}

.checklist-item.flash {
  animation: checklist-flash 1600ms ease;
}

@keyframes checklist-flash {
  0% {
    background: var(--accent-soft);
  }
  100% {
    background: transparent;
  }
}

.checklist-item-checkbox {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.checklist-item-checkbox:hover {
  border-color: var(--green);
}

.checklist-item.done .checklist-item-checkbox {
  background: var(--green);
  border-color: var(--green);
}

.checklist-item-checkbox svg {
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 120ms ease, transform 120ms ease;
}

.checklist-item.done .checklist-item-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.checklist-item-label {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  color: var(--ink);
}

.checklist-item.done .checklist-item-label {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 400;
}

.checklist-item.editing {
  background: var(--surface-subtle);
  cursor: default;
}

.checklist-edit-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.checklist-edit-input:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.checklist-edit-button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 750;
  flex: none;
}

.checklist-undo-button {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 120;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.checklist-undo-button[hidden] {
  display: none;
}

.checklist-undo-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

/* Actions section */
.checklist-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Empty state */
.checklist-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

/* Toast notification */
.checklist-toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--danger);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: checklist-slideIn 300ms ease-out;
  max-width: 300px;
  z-index: 100;
}

@keyframes checklist-slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.meal-prep-dialog {
  width: min(520px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: hidden;
}

.meal-prep-ingredient-list {
  display: grid;
  gap: 6px;
  max-height: min(52vh, 440px);
  overflow-y: auto;
  padding: 2px;
}

.meal-prep-ingredient {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.meal-prep-ingredient:hover {
  background: var(--surface-subtle);
}

.meal-prep-ingredient input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.meal-prep-ingredient-detail {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.meal-prep-ingredient-name {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meal-prep-ingredient.optional .meal-prep-ingredient-name,
.meal-prep-ingredient.already-needed .meal-prep-ingredient-name {
  color: #475867;
  font-weight: 600;
}

.meal-prep-ingredient-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.meal-prep-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.meal-prep-badge.optional {
  border-color: #d7b456;
  background: var(--amber-soft);
  color: #7a5b00;
}

.meal-prep-badge.already {
  border-color: #9fcdb9;
  background: var(--green-soft);
  color: var(--green);
}

.meal-plan-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 14px 0 18px;
}

.meal-plan-subtitle {
  max-width: none;
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meal-plan-new-recipe {
  flex: 0 0 auto;
  white-space: nowrap;
}

.meal-plan-table-wrap {
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.meal-plan-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.meal-plan-table th,
.meal-plan-table td {
  border-bottom: 1px solid var(--line-soft);
}

.meal-plan-table tr:last-child th,
.meal-plan-table tr:last-child td {
  border-bottom: 0;
}

.meal-plan-meal-heading,
.meal-plan-day-heading,
.meal-plan-row-heading {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  background: var(--surface-subtle);
}

.meal-plan-meal-heading,
.meal-plan-row-heading {
  width: 86px;
}

.meal-plan-table td {
  padding: 8px;
  vertical-align: top;
}

.meal-plan-cell {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.meal-plan-cell.empty {
  border-color: var(--line);
  border-style: dashed;
  color: var(--muted);
  font-weight: 650;
}

.meal-plan-cell.filled {
  border-color: #c8d2dd;
  background: #f8fafc;
}

.meal-plan-cell:hover {
  border-color: #9aaaba;
  background: #f4f7f9;
}

.meal-plan-picker,
.meal-recipe-editor {
  width: min(560px, 100%);
}

.meal-plan-picker-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.meal-plan-picker-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.meal-plan-recipe-list {
  display: grid;
  gap: 6px;
  max-height: min(36vh, 300px);
  overflow-y: auto;
}

.meal-plan-recipe-option {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.meal-plan-recipe-option:hover {
  background: var(--surface-subtle);
  border-color: #b8c3cf;
}

.meal-plan-custom-input,
.meal-recipe-title-input,
.meal-recipe-ingredients-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.meal-plan-custom-input,
.meal-recipe-title-input {
  min-height: 42px;
  padding: 9px 10px;
}

.meal-recipe-ingredients-input {
  min-height: 180px;
  margin-top: 10px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

/* Phone responsive */
@media (max-width: 600px) {
  :root {
    --checklist-padding: 12px;
  }

  .checklist-undo-button {
    bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .checklist-title {
    font-size: 24px;
  }

  .checklist-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
  }

  .checklist-progress {
    align-self: flex-start;
  }

  .checklist-add-row {
    gap: 6px;
  }

  .checklist-add-row button {
    min-width: 44px;
  }

  .checklist-chip,
  .checklist-tab {
    min-height: 36px;
    padding: 8px 12px;
  }

  .checklist-item {
    padding: 12px 8px;
  }

  .meal-prep-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .meal-prep-dialog {
    max-height: calc(100vh - 24px - env(safe-area-inset-bottom));
  }

  .meal-plan-intro {
    flex-direction: column;
  }

  .meal-plan-new-recipe {
    width: 100%;
  }

  .meal-plan-table {
    min-width: 0;
  }

  .meal-plan-table,
  .meal-plan-table thead,
  .meal-plan-table tbody,
  .meal-plan-table tr,
  .meal-plan-table th,
  .meal-plan-table td {
    display: block;
  }

  .meal-plan-table thead {
    display: none;
  }

  .meal-plan-row-heading {
    width: auto;
    border-top: 1px solid var(--line-soft);
  }

  .meal-plan-table td {
    padding: 7px 10px;
    border-bottom: 0;
  }
}
