/* Matches the tana iOS app's palette (see Extensions/Color+Theme.swift, Color+Shopping.swift,
   Models/AppBackgroundTheme.swift): a warm peach accent, card-based rounded-corner layout on a
   soft cream/dark background, and the same wallet accent colors used throughout the app. */

:root {
  --accent: #d97d64; /* appAccent (default "peach" theme) */
  --accent-dark: #b8593f;
  --mint: #4cc97a; /* walletMint / secondaryAccent default */
  --mint-dark: #2f9c58;
  --gold: #f2b84b; /* walletGold */
  --gold-text: #b87a14; /* walletGoldText */
  --teal: #4fa8a6; /* walletTeal */
  --rose: #e06c8c; /* walletRose */
  --sky: #4fa0e0; /* walletSky */

  --bg: #f4efeb; /* shoppingTabBackground (light) */
  --card-bg: #ffffff;
  --text-primary: #2b2622;
  --text-secondary: #7a716a;
  --text-tertiary: #a89f97;
  --border: rgba(43, 38, 34, 0.08);
  --shadow: 0 2px 10px rgba(43, 38, 34, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2e2b27; /* shoppingTabBackground (dark) */
    --card-bg: #3a3632;
    --text-primary: #f4efeb;
    --text-secondary: #b8afa7;
    --text-tertiary: #8a8079;
    --border: rgba(244, 239, 235, 0.08);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  }
}

/* A theme toggle can override the OS preference by stamping either value here. */
:root[data-theme="dark"] {
  --bg: #2e2b27;
  --card-bg: #3a3632;
  --text-primary: #f4efeb;
  --text-secondary: #b8afa7;
  --text-tertiary: #8a8079;
  --border: rgba(244, 239, 235, 0.08);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

:root[data-theme="light"] {
  --bg: #f4efeb;
  --card-bg: #ffffff;
  --text-primary: #2b2622;
  --text-secondary: #7a716a;
  --text-tertiary: #a89f97;
  --border: rgba(43, 38, 34, 0.08);
  --shadow: 0 2px 10px rgba(43, 38, 34, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------------- state screens */

.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 70vh;
  padding: 24px;
  gap: 8px;
}

.state-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.state-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.state-text {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  max-width: 380px;
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------------------------------------------------------------- header */

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 20px;
}

.header-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.header-text h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.header-text p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ------------------------------------------------------------------------------------ sections */

.section {
  margin-bottom: 22px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 10px 4px;
}

.section-title .count {
  background: var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* --------------------------------------------------------------------------------- item card */

.item-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  gap: 12px;
  transition: opacity 0.2s ease;
}

.item-card.purchased {
  opacity: 0.72;
}

.item-photo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

.item-photo-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

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

.item-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-title-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.item-name {
  font-size: 16px;
  font-weight: 650;
  margin: 0;
}

/* The primary purchase-toggle action lives in the card's upper-right corner, next to the name,
   rather than full-width below the notes/link — a smaller footprint than the standalone `.btn`
   sizing so it reads as secondary to the item itself. */
.corner-action {
  flex-shrink: 0;
  font-size: 12.5px;
  padding: 6px 11px;
  white-space: nowrap;
}

.item-card.purchased .item-name {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.item-qty {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.item-notes {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 3px 0 0;
  line-height: 1.4;
}

.item-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--sky);
  text-decoration: none;
  margin-top: 6px;
}

.item-link:hover {
  text-decoration: underline;
}

.purchased-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--mint-dark);
}

.purchased-badge .badge-icon {
  font-size: 14px;
}

.purchased-meta {
  font-size: 12.5px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* -------------------------------------------------------------------------------------- buttons */

.btn {
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--mint);
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  opacity: 0.85;
}

.btn-text {
  background: none;
  color: var(--text-secondary);
  padding: 4px 6px;
  font-weight: 600;
  text-decoration: underline;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ------------------------------------------------------------------------------ purchase form */

.purchase-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-secondary);
}

.form-field input,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-primary);
}

.form-field input:focus,
.form-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.form-field textarea {
  resize: vertical;
  min-height: 56px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.form-actions .btn {
  flex: 1;
}

.form-error {
  font-size: 13px;
  color: var(--rose);
  margin: 0;
}

/* --------------------------------------------------------------------------------------- footer */

.footer-note {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12.5px;
  margin-top: 28px;
  padding: 0 20px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------------------------ scrollbar */

.app {
  overflow-x: hidden;
}

@media (max-width: 400px) {
  .app {
    padding: 18px 12px 56px;
  }
}
