/* App page styles — extend theme.css design tokens */

/* ── APP LAYOUT ── */
.app-main {
  min-height: calc(100vh - 60px);
  background: var(--bg);
}

.app-header {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  border-bottom: 1px solid var(--border);
  padding: 48px 24px 40px;
}

.app-header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.app-header-text { flex: 1; }

.app-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--fg);
  line-height: 1.1;
  margin-bottom: 10px;
}

.app-subtitle {
  font-size: 16px;
  color: var(--fg-muted);
  line-height: 1.6;
}

.app-header-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

/* ── CONTENT ── */
.app-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── FORM ── */
.budget-form {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-label-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.2px;
}

.form-label-hint {
  font-size: 13px;
  color: var(--fg-muted);
}

/* Budget input */
.budget-input-wrap {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  transition: border-color 0.2s;
  max-width: 260px;
}

.budget-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.budget-dollar {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-muted);
  margin-right: 4px;
  line-height: 1;
}

.budget-field {
  flex: 1;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--fg);
  border: none;
  outline: none;
  background: transparent;
  padding: 18px 0;
  letter-spacing: -1px;
  width: 100%;
  min-width: 0;
}

.budget-field::placeholder { color: #ccc; }

.budget-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.preset-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Store grid */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.store-card {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.store-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.store-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.store-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-card-icon { color: var(--fg-muted); flex-shrink: 0; }
.store-card.selected .store-card-icon { color: var(--accent); }

.store-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.store-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.store-check-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
}

.store-card.selected .store-check-mark { display: flex; }

/* Generate button */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--fg);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px 32px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.2px;
  width: 100%;
  max-width: 360px;
}

.generate-btn:hover:not(:disabled) {
  background: #2a2a4e;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(26, 26, 46, 0.25);
}

.generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-icon { flex-shrink: 0; }
.btn-loading { display: inline-flex; align-items: center; gap: 8px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* Error */
.error-msg {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  color: #dc2626;
  font-weight: 500;
  max-width: 360px;
}

/* ── RESULTS ── */
.results-section {
  margin-top: 56px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.result-summary {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.result-summary-left {}
.result-total-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.result-total {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -2px;
  line-height: 1;
}
.result-budget-info { margin-top: 8px; }
.budget-remaining { font-size: 14px; font-weight: 600; color: var(--accent-green); }
.budget-near { font-size: 14px; color: var(--fg-muted); }

.result-summary-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.result-savings-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 99px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #16a34a;
}

.result-items-count { font-size: 13px; color: var(--fg-muted); }

/* Category pills */
.category-breakdown { }
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px;
}

.cat-name { font-weight: 600; color: var(--fg); }
.cat-count { color: var(--fg-muted); }
.cat-spent { font-weight: 700; color: var(--accent); margin-left: 2px; }

/* Store sections */
.list-by-store {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.store-section {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.store-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.store-section-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}

.store-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.store-section-meta { display: flex; align-items: center; gap: 12px; }
.store-item-count { font-size: 12px; color: var(--fg-muted); }
.store-section-total { font-size: 14px; font-weight: 700; color: var(--fg); }

.store-items { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.list-item:last-child { border-bottom: none; }

.item-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 600; color: var(--fg); }
.item-unit { font-size: 12px; color: var(--fg-muted); }

.item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.item-price { font-size: 14px; font-weight: 700; color: var(--fg); }
.item-savings { font-size: 11px; font-weight: 600; color: var(--accent-green); }

/* Responsive */
@media (max-width: 600px) {
  .app-header { padding: 32px 20px 28px; }
  .app-header-inner { flex-direction: column; }
  .app-content { padding: 28px 20px 60px; }
  .store-grid { grid-template-columns: repeat(2, 1fr); }
  .budget-field { font-size: 28px; }
  .result-summary { flex-direction: column; }
  .result-summary-right { align-items: flex-start; }
  .list-item { padding: 12px 16px; }
}