/* Bob Fitness PWA — visual design by Pixi */
:root {
  --bg:       #0C1018;
  --surface:  #131926;
  --elevated: #1A2236;
  --border:   #243060;
  --accent:   #F5C518;
  --blue:     #2B4EA8;
  --text:     #F0F4FF;
  --muted:    #7B8BB5;
  --warn:     #E8821A;
  --danger:   #CC2200;
  --radius:   14px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Status dot */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}
.dot.online  { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.offline { background: var(--danger); }

/* ── Main content ── */
main {
  padding: 16px 16px calc(80px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
}

.view       { display: none; }
.view.active { display: block; }

.hidden { display: none !important; }

/* ── Buttons ── */
.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  padding: 13px 18px;
  background: var(--elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s, transform 0.1s;
  border: 1px solid var(--border);
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  color: #0C111E;
  border-color: transparent;
  font-weight: 800;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn:active  { transform: translateY(1px); opacity: 0.85; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Meal capture section ── */
.capture {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.capture label.btn {
  text-align: center;
  cursor: pointer;
  background: linear-gradient(135deg, #162C47 0%, #0F1E36 100%);
  border: 1.5px dashed #F5C51850;
  padding: 20px;
  font-size: 0.95rem;
  color: var(--text);
}

/* Form inputs */
select,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}

select:focus,
input[type="text"]:focus {
  border-color: var(--accent);
}

select option { background: var(--surface); }

/* ── Preview ── */
.preview {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.preview img {
  width: 100%;
  border-radius: var(--radius);
  max-height: 280px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ── Busy state ── */
.busy {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* ── Lists & Cards ── */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.card .thumb {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.card h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.card .muted {
  color: var(--muted);
  font-size: 0.75rem;
}

.card .kcal {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
  font-size: 0.9rem;
}

/* Macro row inside card */
.card .macros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card .macro-tag {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card .macro-tag b {
  color: var(--text);
  font-weight: 700;
}

/* ── Ingredient items ── */
.items {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.items li {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

/* Delete button */
.del {
  justify-self: end;
  align-self: start;
  color: var(--danger);
  background: none;
  border: 0;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.del:hover { opacity: 1; }

/* ── Analysis view ── */
/* Scope the grid to the active state, else the ID selector (specificity 100)
   overrides `.view { display:none }` and the analysis view never hides. */
#view-analysis.active {
  display: grid;
  gap: 10px;
}

#view-analysis input[type="text"] {
  margin: 0;
}

.analysis {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 4px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}

.analysis:empty { display: none; }

/* ── Workout sync button ── */
#syncWorkouts {
  margin-bottom: 14px;
  width: 100%;
}

/* ── Tab bar ── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}

.tab {
  flex: 1;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 10px 0 12px;
  display: grid;
  place-items: center;
  gap: 3px;
  cursor: pointer;
  transition: color 0.15s;
}

.tab-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.tab span {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tab.active        { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
  max-width: 90%;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ── Workout card extras ── */
.card .workout-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.card .badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--elevated);
  color: var(--muted);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

/* ── Splash screen ── */
.splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  transition: opacity 0.35s;
}

.splash.hidden { opacity: 0; pointer-events: none; }

.splash-icon img {
  border-radius: 20px;
  box-shadow: 0 0 40px #F5C51830;
}

.splash-name {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
}

.splash-tagline {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.splash-bar {
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 24px;
  overflow: hidden;
  position: relative;
}

.splash-bar::after {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--accent);
  animation: splashProgress 0.9s ease-out forwards;
}

@keyframes splashProgress {
  to { left: 0; }
}

/* ── App shell ── */
.app { height: 100%; }

/* ── Section label ── */
.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 18px 0 8px;
}

/* ── Score card ── */
.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}

.score-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

.score-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.score-num {
  font-size: 3.6rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}

.score-max {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.score-rating {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  min-height: 1.3em;
  margin-bottom: 20px;
}

/* vertical bar chart */
.score-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-items: end;
  height: 96px;
}

.score-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.score-bar-track {
  flex: 1;
  width: 28px;
  background: var(--elevated);
  border-radius: 4px 4px 2px 2px;
  position: relative;
  overflow: hidden;
}

.score-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--accent);
  border-radius: 4px 4px 2px 2px;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-bar-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Quick actions ── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.qa-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}

.qa-btn:active {
  background: var(--elevated);
  border-color: var(--accent);
}

.qa-icon { font-size: 1.4rem; }
.qa-label { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.qa-sub   { font-size: 0.7rem; color: var(--muted); }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg { opacity: 0.4; }

.empty-state p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── Bob header ── */
.bob-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.bob-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #C9A010 100%);
  color: #0C111E;
  font-weight: 900;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.bob-name {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.bob-tagline {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ── Bob ask block ── */
.bob-ask {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

/* ── Auth screen ── */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 24px;
}

.auth-inner {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 20px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-logo img { border-radius: 16px; box-shadow: 0 0 30px #F5C51825; }

.auth-logo-name {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
}

.auth-switch {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  text-align: center;
  transition: color 0.15s;
}

.auth-switch:hover { color: var(--accent); }

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-error {
  font-size: 0.82rem;
  color: var(--danger);
  padding: 10px 14px;
  background: #E05C5C12;
  border: 1px solid #E05C5C30;
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ── Topbar actions group ── */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Language toggle ── */
.lang-toggle {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.lang-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ── Multi-photo preview grid ── */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

/* app.js injects .thumb-item elements */
.thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  max-height: none;
  border: 0;
}

.thumb-item .thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00000080;
  color: #fff;
  border: 0;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

/* ── Settings block (Bob nézet alján) ── */
.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.settings-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-row input { flex: 1; }

.settings-hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Profile + measurement inputs (neo; polish = Pixi) ── */
select,
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}
input[type="number"]:focus,
input[type="date"]:focus { border-color: var(--accent); }

.profile-grid,
.measure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld-wide { grid-column: 1 / -1; }
.fld-lbl {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.profile-target {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.profile-target b { color: var(--accent); font-size: 1.05rem; }

/* Daily calorie summary (meals view) */
.cal-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
}
.cal-summary-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.cal-consumed { font-size: 1.35rem; font-weight: 800; color: var(--text); }
.cal-sep { color: var(--muted); }
.cal-target { font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.cal-unit { font-size: 0.8rem; color: var(--muted); }
.cal-bar-track {
  height: 8px;
  border-radius: 6px;
  background: var(--elevated);
  overflow: hidden;
  margin: 8px 0 6px;
}
.cal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.3s ease;
}
.cal-bar-fill.over { background: var(--danger); }
.cal-remaining { font-size: 0.75rem; }

/* ── Responsive: tablet and above ── */
@media (min-width: 480px) {
  main { padding: 20px 20px 0; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
