/**
 * shopping-app.css — Standalone Shopping List App.
 *
 * Purple/indigo gradient, clean checkboxes, category grouping.
 */

/* ── Container ───────────────────────────────────────────────────── */

.sapp {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 44px) + 12px) 16px
           calc(env(safe-area-inset-bottom, 0px) + 80px);
  background: linear-gradient(170deg,
    var(--sapp-bg1, #1a0a2e) 0%,
    var(--sapp-bg2, #261545) 45%,
    var(--sapp-bg3, #100820) 100%);
  color: #f0f0f0;
  position: relative;
}

.sapp::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 25% 8%, rgba(139, 92, 246, 0.10), transparent),
    radial-gradient(ellipse 50% 40% at 75% 55%, rgba(99, 60, 180, 0.06), transparent);
  pointer-events: none;
}

/* ── Back Button ─────────────────────────────────────────────────── */

.sapp-back {
  position: fixed;
  top: calc(env(safe-area-inset-top, 44px) + 10px);
  left: 14px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.sapp-back:active { background: rgba(0, 0, 0, 0.55); }

/* ── Hero ────────────────────────────────────────────────────────── */

.sapp-hero {
  text-align: center;
  padding: 28px 0 20px;
  position: relative;
}

.sapp-hero-count {
  font-size: 4.5rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
}

.sapp-hero-label {
  font-size: 1rem;
  opacity: 0.6;
  margin-top: 6px;
}

.sapp-hero-sub {
  font-size: 0.8rem;
  opacity: 0.4;
  margin-top: 4px;
}

/* ── Quick add bar ───────────────────────────────────────────────── */

.sapp-quickadd {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
}

.sapp-quickadd-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 16px;
  color: #f0f0f0;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.sapp-quickadd-input:focus { border-color: rgba(139, 92, 246, 0.5); }
.sapp-quickadd-input::placeholder { color: rgba(255, 255, 255, 0.3); }

.sapp-quickadd-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #8b5cf6;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.sapp-quickadd-btn:active { opacity: 0.7; }

/* ── Suggestions ─────────────────────────────────────────────────── */

.sapp-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sapp-suggestions::-webkit-scrollbar { display: none; }

.sapp-sug-chip {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.sapp-sug-chip:active { background: rgba(139, 92, 246, 0.3); }

/* ── Section (category group) ────────────────────────────────────── */

.sapp-section {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  margin-bottom: 12px;
  overflow: hidden;
  position: relative;
}

.sapp-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.5;
  font-weight: 600;
}

.sapp-section-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 0.7rem;
}

/* ── Item row ────────────────────────────────────────────────────── */

.sapp-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sapp-item:active { background: rgba(255, 255, 255, 0.04); }

.sapp-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.sapp-item.done .sapp-check {
  background: #8b5cf6;
  border-color: #8b5cf6;
}

.sapp-item-info { flex: 1; min-width: 0; }

.sapp-item-name {
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sapp-item.done .sapp-item-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.sapp-item-meta {
  font-size: 0.75rem;
  opacity: 0.4;
  margin-top: 1px;
}

.sapp-item-price {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.7;
  white-space: nowrap;
}

.sapp-item-del {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: none;
  color: #f87171;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.sapp-item-del:active { opacity: 1; }

/* ── Done section ────────────────────────────────────────────────── */

.sapp-done-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
  margin-top: 8px;
}

.sapp-done-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.4;
}

.sapp-clear-btn {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #fca5a5;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sapp-clear-btn:active { background: rgba(248, 113, 113, 0.25); }

/* ── Add form (expanded) ─────────────────────────────────────────── */

.sapp-addform {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  position: relative;
  animation: sapp-slide 0.25s ease;
}

.sapp-addform.open { display: flex; }

@keyframes sapp-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sapp-addform .sapp-form-row {
  display: flex;
  gap: 8px;
}

.sapp-addform .sapp-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  color: #f0f0f0;
  font-size: 0.88rem;
  outline: none;
  -webkit-appearance: none;
}

.sapp-addform .sapp-input:focus { border-color: rgba(139, 92, 246, 0.5); }
.sapp-addform .sapp-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.sapp-addform .sapp-input option { background: #261545; color: #f0f0f0; }

.sapp-expand-btn {
  background: none;
  border: none;
  color: #c4b5fd;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
  text-align: center;
  opacity: 0.7;
  -webkit-tap-highlight-color: transparent;
}

.sapp-expand-btn:active { opacity: 1; }

/* ── Family badge ────────────────────────────────────────────────── */

.sapp-family-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ── Toast ───────────────────────────────────────────────────────── */

.sapp-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #8b5cf6;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 26px;
  z-index: 200;
  animation: sapp-toast-in 0.3s ease, sapp-toast-out 0.3s ease 2s forwards;
  pointer-events: none;
}

@keyframes sapp-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes sapp-toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Empty ───────────────────────────────────────────────────────── */

.sapp-empty {
  text-align: center;
  padding: 32px 16px;
  opacity: 0.5;
}

.sapp-empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.sapp-empty-text { font-size: 0.9rem; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (min-width: 500px) {
  .sapp { padding-left: 24px; padding-right: 24px; }
  .sapp-hero-count { font-size: 5rem; }
}

/* Quick-add icon button (ghost variant of sapp-quickadd-btn) */
.sapp-quickadd-btn--ghost {
  background: transparent;
  font-size: 1.1rem;
}

/* Add form note + save button */
.sapp-add-notes {
  resize: vertical;
}
.sapp-add-save {
  width: 100%;
  background: #8b5cf6;
}

/* Recurring-icon inside item name */
.sapp-item-recurring-icon {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* Item meta italic / hint */
.sapp-item-meta--note {
  font-style: italic;
  opacity: 0.7;
}

/* Compare-prices hint button (sapp-item-del variant) */
.sapp-item-del--hint {
  opacity: 0.65;
  font-size: 0.78rem;
}

/* Actual-price label */
.sapp-item-price--actual {
  color: var(--color-teal, #33A199);
  font-weight: 600;
}

/* Recurring toggle button — opacity-driven by data-recurring attr */
.sapp-item-del--recur {
  font-size: 0.85rem;
  opacity: 0.35;
}
.sapp-item-del--recur[data-recurring="1"] {
  opacity: 1;
}

/* Show-all-done expand button */
.sapp-show-all {
  width: 100%;
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: transparent;
  color: var(--hint);
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 6px;
}

/* Category budget section */
.sapp-section--budget {
  margin-top: 8px;
}
.sapp-section-head--small {
  font-size: 0.82rem;
}
.sapp-budget-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sapp-budget-row__totals {
  color: var(--hint);
}
.sapp-budget-row__estimate {
  opacity: 0.7;
}

/* ── Toggle-confirm price input row (S8) ─────────────────────────── */
.sapp-price-input {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  margin-top: 4px;
  width: 100%;
}
.sapp-price-input__field {
  flex: 1;
  font-size: 0.8rem;
  padding: 6px 8px;
}

/* ── Barcode scanner overlay ─────────────────────────────────────── */
.sapp-scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
}
.sapp-scan-video {
  max-width: min(90vw, 400px);
  max-height: 55vh;
  border-radius: 12px;
  background: #000;
}
.sapp-scan-status {
  color: #F5F0E1;
  font-size: 0.88rem;
  text-align: center;
}
.sapp-scan-close {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 8px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ── Manual EAN input modal ──────────────────────────────────────── */
.sapp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sapp-modal-overlay--bottom {
  background: rgba(0, 0, 0, 0.85);
  align-items: flex-end;
  padding: 0;
}
.sapp-modal-card {
  background: #1a222e;
  border-radius: 16px;
  padding: 24px;
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sapp-modal-card--meal {
  border-radius: 20px 20px 0 0;
  width: min(100vw, 600px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}
.sapp-modal-title {
  color: #F5F0E1;
  font-weight: 700;
  font-size: 1rem;
}
.sapp-modal-subtitle {
  color: #aaa;
  font-size: 0.8rem;
}
.sapp-ean-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #334;
  background: #0d1a16;
  color: #F5F0E1;
  font-size: 1rem;
}
.sapp-ean-lookup {
  background: #33A199;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}
.sapp-ean-cancel {
  background: transparent;
  color: #888;
  border: 1px solid #334;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

/* ── Meal plan modal ─────────────────────────────────────────────── */
.sapp-meal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.sapp-meal-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.sapp-meal-scroll {
  overflow-x: auto;
}
.sapp-meal-table {
  border-collapse: collapse;
  width: 100%;
}
.sapp-meal-table th {
  padding: 4px 6px;
  font-size: 0.7rem;
  text-align: left;
  color: #aaa;
}
.sapp-meal-table th.sapp-meal-table__corner {
  width: 36px;
}
.sapp-meal-table td.sapp-meal-table__day {
  padding: 4px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #D9C49A;
  white-space: nowrap;
}
.sapp-meal-table td.sapp-meal-table__cell {
  padding: 2px 3px;
}
.sapp-meal-input {
  width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.07);
  border: none;
  border-radius: 5px;
  padding: 4px 5px;
  color: #F5F0E1;
  font-size: 0.72rem;
  box-sizing: border-box;
}
.sapp-meal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.sapp-meal-action {
  flex: 1;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  font-weight: 600;
}
.sapp-meal-action--save {
  background: #33A199;
}
.sapp-meal-action--gen {
  background: #8b5cf6;
}

/* ── Light-mode overrides for the dark-styled modals ─────────────── */
[data-theme="light"] .sapp-modal-card,
[data-theme-mode="light"] .sapp-modal-card,
[data-theme-preference="light"] .sapp-modal-card {
  background: #ffffff;
  color: #1c1917;
}
[data-theme="light"] .sapp-modal-title,
[data-theme-mode="light"] .sapp-modal-title,
[data-theme-preference="light"] .sapp-modal-title {
  color: #1c1917;
}
[data-theme="light"] .sapp-modal-subtitle,
[data-theme-mode="light"] .sapp-modal-subtitle,
[data-theme-preference="light"] .sapp-modal-subtitle {
  color: #57534e;
}
[data-theme="light"] .sapp-ean-input,
[data-theme-mode="light"] .sapp-ean-input,
[data-theme-preference="light"] .sapp-ean-input {
  background: #f5f5f4;
  color: #1c1917;
  border-color: #d6d3d1;
}
[data-theme="light"] .sapp-meal-table th,
[data-theme-mode="light"] .sapp-meal-table th,
[data-theme-preference="light"] .sapp-meal-table th,
[data-theme="light"] .sapp-meal-close,
[data-theme-mode="light"] .sapp-meal-close,
[data-theme-preference="light"] .sapp-meal-close {
  color: #57534e;
}
[data-theme="light"] .sapp-meal-table td.sapp-meal-table__day,
[data-theme-mode="light"] .sapp-meal-table td.sapp-meal-table__day,
[data-theme-preference="light"] .sapp-meal-table td.sapp-meal-table__day {
  color: #92621f;
}
[data-theme="light"] .sapp-meal-input,
[data-theme-mode="light"] .sapp-meal-input,
[data-theme-preference="light"] .sapp-meal-input {
  background: rgba(28, 25, 23, 0.06);
  color: #1c1917;
}
[data-theme="light"] .sapp-scan-status,
[data-theme-mode="light"] .sapp-scan-status,
[data-theme-preference="light"] .sapp-scan-status {
  color: #f5f5f4;
}
