/* Reusable components — shared across every screen */

/* Top app bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
}
.app-logo { display: block; border-radius: 8px; }
.app-name { font-weight: 700; letter-spacing: 0.01em; font-size: 1.05em; line-height: 1.2; }
.app-tagline { color: var(--muted); font-size: 0.8em; line-height: 1.2; }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.72em;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
}
.nav-btn .nav-icon svg { width: 22px; height: 22px; display: block; }
.nav-btn.active { color: var(--accent); }
.nav-btn:active { background: var(--accent-soft); }

/* Layout */
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--navbar-h) + 24px + env(safe-area-inset-bottom));
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.card-title {
  margin: 0 0 16px;
  font-size: 1em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.card-title-row .card-title { margin-bottom: 0; }

/* Small "AI-generated / placeholder" tag used on AI or placeholder content */
.ai-tag {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.ai-tag-row { margin-bottom: 10px; }

/* Persistent app-wide disclaimer footer */
.app-disclaimer {
  font-size: 0.75em;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
  padding: 16px 8px 8px;
}

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

label { font-size: 0.9em; color: var(--muted); font-weight: 500; }
.optional { font-weight: 400; opacity: 0.8; }

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"] {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* prevents iOS auto-zoom */
  width: 100%;
  min-height: 48px;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint { font-size: 0.85em; color: var(--muted); margin: 0; }

/* Segmented control */
.segmented {
  position: relative;
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: 100%;
}
.segmented-input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-label {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.segmented-input:checked + .segmented-label { background: var(--accent); color: var(--accent-text); }
.segmented-input:focus-visible + .segmented-label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chip row */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9em;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Buttons */
.btn-primary, .btn-secondary {
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  min-height: 50px;
}
.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
.btn-danger-armed { background: var(--error-soft); color: var(--error); }

/* Status messages */
.status {
  margin: 4px 0 16px;
  font-size: 0.92em;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
}
.status.error { background: var(--error-soft); color: var(--error); }

/* Icons (inline SVG, currentColor so they follow theme) */
.icon svg { width: 20px; height: 20px; display: block; }

/* Avatar */
.avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1em;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Generic stat/score card, reused by the home dashboard */
.score-card {
  border-radius: var(--radius-sm);
  padding: 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.score-label { font-size: 0.82em; color: var(--muted); font-weight: 600; }
.score-value { font-size: 1.4em; font-weight: 800; margin: 2px 0 8px; }
.score-bar { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; background: currentColor; }

.cat-luck         { color: var(--cat-luck); }
.cat-relationship { color: var(--cat-relationship); }
.cat-finance      { color: var(--cat-finance); }
.cat-health       { color: var(--cat-health); }
.cat-career       { color: var(--cat-career); }
.score-card.cat-luck         { background: var(--cat-luck-soft); border-color: transparent; }
.score-card.cat-relationship { background: var(--cat-relationship-soft); border-color: transparent; }
.score-card.cat-finance      { background: var(--cat-finance-soft); border-color: transparent; }
.score-card.cat-health       { background: var(--cat-health-soft); border-color: transparent; }
.score-card.cat-career       { background: var(--cat-career-soft); border-color: transparent; }
.score-card .score-value, .score-card .score-label { color: inherit; }

/* Locked / monetization card */
.locked-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.locked-card .lock-badge {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.locked-card h3 { margin: 0 0 2px; font-size: 1em; }
.locked-card .hint { margin: 0; }
.btn-unlock { width: auto; flex: 0 0 auto; padding: 10px 16px; min-height: 40px; }

/* Placeholder screens (forecast / remedies) */
.placeholder-card {
  text-align: center;
  padding: 40px 20px;
}
.placeholder-icon {
  display: inline-flex;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.placeholder-icon svg { width: 28px; height: 28px; }
.placeholder-card h2 { margin: 0 0 6px; }
.placeholder-card .hint { margin: 0 auto; max-width: 280px; }

/* PWA install / update dialogs (js/core/pwaDialog.js) — a centered card
   over a dimmed backdrop, built from a plain <div> appended to <body>
   rather than <dialog>, so it looks identical across browsers and themes. */
.pwa-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(13, 10, 26, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  animation: pwa-fade-in 0.18s ease-out;
}
@media (min-width: 480px) {
  .pwa-dialog-backdrop { align-items: center; }
}
.pwa-dialog {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px 20px;
  text-align: center;
  animation: pwa-slide-up 0.22s ease-out;
}
.pwa-dialog-icon {
  display: block;
  margin: 0 auto 14px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.pwa-dialog-title { margin: 0 0 8px; font-size: 1.15em; }
.pwa-version-badge {
  display: inline-block;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}
.pwa-dialog-body { margin: 0 0 20px; color: var(--muted); font-size: 0.92em; line-height: 1.5; }
.pwa-dialog-actions { display: flex; gap: 10px; }
.pwa-dialog-actions .btn-primary,
.pwa-dialog-actions .btn-secondary { width: auto; flex: 1; min-height: 46px; }

@keyframes pwa-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pwa-slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
