/* A családi Dashboard app stíluslapja (az éles app static/style.css-e alapján),
   a végén a demó kiegészítéseivel. Csak rendszerbetűkészlet, külső erőforrás nincs. */

:root {
  --border: #e1e4e8;
  --text: #1f2328;
  --text-muted: #656d76;
  --bg: #ffffff;
  --bg-muted: #f6f8fa;
  --accent: #3b82f6;
  --today-bg: #eff6ff;
  --today-border: #dc2626;
  --highlight-bg: #fde047;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-muted);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 8px;
}
.topbar-menu {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
}
.menu-btn {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}
.menu-btn:hover { background: var(--bg-muted); }
.menu-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.nav-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
}
.today-btn { font-weight: 600; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px calc(16px + env(safe-area-inset-right)) 28px calc(16px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 1rem; }
.card h3 { margin: 16px 0 8px; font-size: 0.9rem; color: var(--text-muted); }
.empty-state { color: var(--text-muted); margin: 0; }

/* Weather card — centered, since it's the focal block on the billboard layout */
.weather-content { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.weather-now { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap; }
.weather-icon-big { font-size: 2.6rem; line-height: 1; }
.weather-current { font-size: 2.4rem; font-weight: 700; }
.weather-now-label { color: var(--text-muted); font-size: 1rem; }
.weather-forecast { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; color: var(--text-muted); }

/* grid, not flex-wrap — must always stay side by side, never stack */
.weather-halfdays { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; gap: 16px; margin-top: 4px; }
.weather-halfday {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.weather-halfday-label { font-size: 0.85rem; color: var(--text-muted); }
.weather-icon-mid { font-size: 1.8rem; line-height: 1.4; }
.weather-halfday-temp { font-size: 1.3rem; font-weight: 600; }
.weather-halfday-precip { font-size: 0.8rem; color: var(--text-muted); }

/* 7-day forecast strip */
.weather-daily { margin-top: 16px; }
.daily-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.weather-daily-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
}
.weather-daily-cell.is-today { background: var(--today-bg); box-shadow: inset 0 0 0 2px var(--today-border); }
.weather-daily-label { font-size: 0.8rem; color: var(--text-muted); }
.weather-daily-date { font-size: 0.75rem; color: var(--text-muted); }
.weather-daily-temp { font-size: 0.85rem; }
.weather-daily-temp strong { font-size: 0.95rem; }
.weather-daily-precip { font-size: 0.72rem; color: var(--text-muted); }

/* Two-week notes layout */
.notes-header { margin-bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.notes-header h2 { margin: 0; }
.two-weeks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.week-section { }
.week-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

@media (max-width: 700px) {
  .daily-grid { grid-template-columns: repeat(4, 1fr); }
  .hourly-grid { grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); }
  .two-weeks-grid { grid-template-columns: 1fr; }
}

/* Week grid — single, pageable week (see topbar prev/today/next) */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.week-col.is-today { background: var(--today-bg); box-shadow: inset 0 0 0 2px var(--today-border); }
.week-col-header {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.day-note {
  flex: 1;
  min-height: 90px;
  border: none;
  resize: none;
  padding: 8px;
  font: inherit;
  /* 16px minimum — anything smaller triggers Safari's auto-zoom-on-focus
     on iOS, which matters here since editing mostly happens from phones. */
  font-size: 16px;
  background: transparent;
  color: var(--text);
}
.day-note:focus { outline: 2px solid var(--accent); outline-offset: -2px; }


/* Finance card */
.finance-balance { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.balance-input {
  min-height: 46px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  width: 200px;
  background: var(--highlight-bg);
  font-variant-numeric: tabular-nums;
}

.finance-contributions ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
/* Csak-olvasható sorok — a monthly_contributions kizárólag a cashflow
   szinkronból töltődik, nincs kézi szerkesztés (lásd finance.py). */
.contribution-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.contribution-person { flex: 1 1 160px; min-width: 0; font-size: 16px; }
.contribution-amount { width: 110px; font-size: 16px; font-variant-numeric: tabular-nums; }

/* Shopping list card */
.shopping-add { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.shopping-input {
  flex: 1;
  min-height: 46px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.shopping-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.shopping-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.shopping-row:last-child { border-bottom: none; }
.shopping-checkbox { width: 22px; height: 22px; flex: 0 0 auto; }
.shopping-text { flex: 1; min-width: 0; font-size: 16px; word-break: break-word; }
.shopping-row.is-checked .shopping-text { text-decoration: line-through; color: var(--text-muted); }
.shopping-delete {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 6px;
  min-width: 36px;
  min-height: 36px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* Save feedback toast + failed-save marker on a note cell */
.toast {
  position: fixed;
  z-index: 150;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 7px;
  background: #166534;
  color: white;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
  font-size: 0.88rem;
}
.toast.error { background: #b42318; }
.toast.hidden { display: none; }

.day-note.save-error { outline: 2px solid #b42318; outline-offset: -2px; }

/* Mobile — iPhone 13 mini (375px) and iPhone 16 (390-430px) optimization */
@media (max-width: 480px) {
  main {
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
    gap: 12px;
  }
  .card { padding: 14px; }
  .card h2 { font-size: 0.95rem; }

  .topbar {
    padding: 8px calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .topbar-menu { gap: 4px; }
  .menu-btn { font-size: 0.8rem; padding: 6px 8px; }
  .topbar-actions { justify-content: flex-end; }
  .nav-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .weather-current { font-size: 2rem; }
  .weather-icon-big { font-size: 2.2rem; }
  .daily-grid { display: none; }
  .weather-halfdays { grid-template-columns: 1fr; margin-top: 8px; }

  /* Two-week layout: stack vertically on mobile */
  .two-weeks-grid { grid-template-columns: 1fr; gap: 12px; }
  /* But within each week, show all 7 days on one screen as compact rows */
  .week-grid { grid-template-columns: 1fr; gap: 6px; }
  .week-col { flex-direction: row; align-items: stretch; }
  .week-col-header {
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 4px;
    font-size: 0.75rem;
  }
  .week-col-date { display: block; font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
  .day-note { min-height: 44px; padding: 8px; font-size: 15px; }

  .finance-balance { flex-direction: column; align-items: stretch; }
  .balance-input { width: 100%; }
  .finance-balance .nav-btn { width: 100%; }

  .contribution-amount { width: auto; flex: 1 1 90px; }

  .shopping-add { flex-direction: column; align-items: stretch; }
  .shopping-add .nav-btn { width: 100%; }
}

/* Vevőkártyák oldal (/cards) */
.hidden { display: none !important; }
.cards-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card-pick-btn {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.card-pick-btn:active { background: var(--today-bg); }
.card-pick-holder { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.cards-empty { color: var(--text-muted); margin: 0; }

.cards-manage summary { cursor: pointer; font-weight: 600; }
.card-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.card-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-muted); }
.card-form input, .card-form select {
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
.card-form-preview { grid-column: 1 / -1; max-width: 260px; }
.card-form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.cards-admin-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cards-admin-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.cards-admin-row:last-child { border-bottom: none; }
.cards-admin-text { flex: 1; min-width: 0; font-size: 16px; word-break: break-word; }
.cards-delete { color: #b42318; }

/* Full-screen card: always white, so scanners get maximum contrast. */
.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #ffffff;
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.card-overlay-inner { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.card-overlay-store { font-size: 1.6rem; font-weight: 700; }
.card-overlay-code { width: 100%; display: flex; justify-content: center; }
.card-overlay-code .code-qr { width: min(80vw, 360px); }
.card-overlay-code .code-bar { width: 100%; }
.code-qr svg, .code-bar svg { display: block; width: 100%; height: auto; }
.code-error { color: #b42318; padding: 12px; }
.card-overlay-holder { font-size: 1.1rem; font-weight: 600; }
.card-overlay-number { font-size: 1.2rem; letter-spacing: 0.05em; font-variant-numeric: tabular-nums; word-break: break-all; }
.card-overlay-close { min-width: 140px; min-height: 48px; font-size: 1rem; margin-top: 8px; }
body.card-open { overflow: hidden; }
/* Kis demójelzés a teljes képernyős kártyán (a felső sávot a kártya kitakarja).
   A sarokban marad, hogy a kódot ne takarja és a beolvasást ne zavarja. */
.card-overlay-demo {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  background: #b42318;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
}

/* ---------------------------------------------------------------------- */
/* Demó kiegészítések                                                     */
/* ---------------------------------------------------------------------- */

.demo-banner {
  background: #b42318;
  color: white;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
}

.demo-banner-link { margin-left: 10px; color: white; font-weight: 700; white-space: nowrap; }
.demo-banner-link:hover { text-decoration: none; }

.nav-btn.disabled { opacity: 0.35; cursor: default; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title-row h2 { margin: 0; }

.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.lang-switch a { padding: 6px 10px; color: var(--text-muted); text-decoration: none; font-size: 0.78rem; font-weight: 700; letter-spacing: .05em; }
.lang-switch a.active { background: var(--text); color: white; }



.dialog-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, 0.55); }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(480px, 100%); padding: 22px 24px; border-radius: 12px; background: white; box-shadow: 0 24px 64px rgba(0,0,0,0.25); }
.dialog .eyebrow { margin: 0 0 6px; color: #b42318; font-size: 0.72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.dialog p:not(.eyebrow) { color: var(--text-muted); line-height: 1.5; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.dialog-actions button { background: var(--accent); color: white; border: none; padding: 8px 18px; border-radius: 6px; cursor: pointer; font: inherit; }

.balance-input { width: 240px; }
@media (max-width: 480px) {
  .topbar-actions { justify-content: space-between; }
  .balance-input { width: 100%; }
}
