/* ================================================================
   FamilyApp — app.css
   Mobile-first, no framework, CSS custom properties for theming.
   ================================================================ */

/* ── Design tokens ── */
:root {
  --c-navy: #35627a;
  --c-terra: #b46258;
  --c-beige: #e5aea9;
  --c-purple: #a6a9d0;
  --c-sage: #8e9a98;
  --c-bg: #f5f3ef;
  --c-surface: #ffffff;
  --c-border: #e2ddd7;
  --c-text: #2c2c2c;
  --c-muted: #777268;
  --c-success: #4a9e6f;
  --c-danger: #c0392b;
  --c-warning: #e67e22;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-full: 999px;

  --sh-card: 0 2px 8px rgba(0, 0, 0, 0.08);
  --sh-top: 0 -1px 8px rgba(0, 0, 0, 0.06);

  --topbar-h: 56px;
  --bottomnav-h: 66px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  height: 100%;
  font-size: 16px;
}
body {
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
img,
svg {
  display: block;
}
button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
input,
textarea {
  font: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}

/* ── App container ── */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Screens ── */
.screen {
  display: none;
  flex: 1;
  overflow: hidden;
}
.screen.active {
  display: flex;
  flex-direction: column;
}
.screen.hidden {
  display: none !important;
}

/* ── Login ── */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  gap: 32px;
  background: var(--c-navy);
  min-height: 100%;
}
.login-logo {
  text-align: center;
  color: white;
}
.login-logo svg {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
}
.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.login-logo p {
  font-size: 1rem;
  opacity: 0.7;
  margin-top: 4px;
}

#form-login {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}
.field input {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
.field input:focus {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.18);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  cursor: pointer;
}
.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--c-terra);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--r-md);
  font-size: 1rem;
  font-weight: 600;
  transition:
    opacity 0.15s,
    transform 0.1s;
  touch-action: manipulation;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--c-terra);
  color: white;
}
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
}
.btn-danger {
  background: var(--c-danger);
  color: white;
}
.btn-ghost {
  background: transparent;
  color: var(--c-navy);
}
.btn-full {
  width: 100%;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Alerts ── */
.alert {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.alert-error {
  background: rgba(192, 57, 43, 0.15);
  color: #c0392b;
  border: 1px solid rgba(192, 57, 43, 0.3);
}
.alert-success {
  background: rgba(74, 158, 111, 0.15);
  color: #2e7d5a;
  border: 1px solid rgba(74, 158, 111, 0.3);
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-back {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-navy);
}
.topbar-back svg {
  width: 22px;
  height: 22px;
}
.topbar-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
}
.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--c-navy);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main content area ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
}

/* ── Bottom nav ── */
.bottom-nav {
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  color: var(--c-muted);
  font-size: 0.68rem;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-item svg {
  width: 22px;
  height: 22px;
}
.nav-item.active {
  color: var(--c-navy);
}
.nav-item.active svg {
  stroke: var(--c-navy);
}

/* ── Cards ── */
.card {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 0;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-text);
}
.card-body {
  padding: 12px 16px 16px;
}

/* ── Sections / page padding ── */
.page {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  margin-bottom: 8px;
}

/* ── Avatar circle ── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

/* ── Walk grid ── */
.walk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.walk-card {
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--sh-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: opacity 0.2s;
}
.walk-card.completed {
  opacity: 0.6;
}
.walk-card.completed .walk-round-label::after {
  content: " ✓";
  color: var(--c-success);
}
.walk-round-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
}
.walk-assigned {
  font-size: 0.95rem;
  font-weight: 600;
}
.walk-btn-complete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ── Grocery list ── */
.grocery-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
  transition: opacity 0.2s;
}
.grocery-item:last-child {
  border-bottom: none;
}
.grocery-item.checked {
  opacity: 0.5;
}
.grocery-item.checked .grocery-name {
  text-decoration: line-through;
}
.grocery-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--c-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.grocery-check.checked {
  background: var(--c-success);
  border-color: var(--c-success);
}
.grocery-check.checked::after {
  content: "✓";
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}
.grocery-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}
.grocery-meta {
  font-size: 0.8rem;
  color: var(--c-muted);
}
.grocery-delete {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* ── Chore list ── */
.chore-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
}
.chore-item:last-child {
  border-bottom: none;
}
.chore-info {
  flex: 1;
  min-width: 0;
}
.chore-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chore-meta {
  font-size: 0.8rem;
  color: var(--c-muted);
  margin-top: 2px;
}
.chore-done-btn {
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-navy);
  transition: background 0.15s;
  white-space: nowrap;
}
.chore-done-btn:active {
  background: var(--c-navy);
  color: white;
}

/* ── Agenda / events ── */
.event-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border);
}
.event-item:last-child {
  border-bottom: none;
}
.event-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  margin-top: 5px;
  flex-shrink: 0;
}
.event-body {
  flex: 1;
  min-width: 0;
}
.event-title {
  font-size: 0.95rem;
  font-weight: 600;
}
.event-time {
  font-size: 0.8rem;
  color: var(--c-muted);
  margin-top: 2px;
}
.event-location {
  font-size: 0.8rem;
  color: var(--c-muted);
}

/* ── Dashboard summary cards ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dash-tile {
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--sh-card);
  cursor: pointer;
  transition: transform 0.1s;
}
.dash-tile:active {
  transform: scale(0.97);
}
.dash-tile-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.dash-tile-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dash-tile-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--c-navy);
  margin-top: 4px;
}
.dash-tile-sub {
  font-size: 0.8rem;
  color: var(--c-muted);
  margin-top: 2px;
}

/* ── Calendar strip ── */
.cal-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.cal-strip::-webkit-scrollbar {
  display: none;
}
.cal-day {
  min-width: 46px;
  padding: 8px 6px;
  border-radius: var(--r-md);
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.cal-day.today {
  background: var(--c-navy);
  color: white;
}
.cal-day.selected {
  background: var(--c-navy);
  color: white;
}
.cal-day.today.selected {
  background: var(--c-navy);
  color: white;
}
.cal-day.has-events::after {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--c-terra);
  margin: 4px auto 0;
}
.cal-day.today.has-events::after {
  background: white;
}
.cal-day-name {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.7;
  text-transform: uppercase;
}
.cal-day-num {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ── Add item form ── */
.add-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
.add-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--c-border);
  background: var(--c-bg);
  outline: none;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}
.add-input:focus {
  border-color: var(--c-navy);
}
.add-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--r-full);
  background: var(--c-navy);
  color: white;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Date nav ── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.date-nav-label {
  font-size: 1rem;
  font-weight: 700;
}
.date-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--c-muted);
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 0.95rem;
}

/* ── Loading spinner ── */
.loader {
  display: flex;
  justify-content: center;
  padding: 48px;
}
.loader::after {
  content: "";
  width: 32px;
  height: 32px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-navy);
  border-radius: var(--r-full);
  animation: spin 0.8s linear infinite;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--r-full);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  animation: toast-in 0.25s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.toast.hidden {
  display: none;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

/* ── Utility ── */
.hidden {
  display: none !important;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.text-muted {
  color: var(--c-muted);
  font-size: 0.85rem;
}
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--c-bg);
  color: var(--c-muted);
}

/* ── Modal / bottom sheet ── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  background: var(--c-surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 85vh;
  overflow-y: auto;
}
.sheet-title {
  font-size: 1.1rem;
  font-weight: 700;
}
.sheet-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 1.4rem;
  color: var(--c-muted);
}

/* ── Sheet: override login-style field colors ── */
.sheet .field label {
  color: var(--c-muted);
}
.sheet .field input,
.sheet .field select,
.sheet .add-input {
  background: var(--c-bg);
  color: var(--c-text);
  border: 1.5px solid var(--c-border);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  outline: none;
  width: 100%;
  flex: none;
}
.sheet .field input::placeholder,
.sheet .add-input::placeholder {
  color: var(--c-muted);
  opacity: 1;
}
.sheet .field input:focus,
.sheet .add-input:focus {
  border-color: var(--c-navy);
}
.sheet .checkbox-row {
  color: var(--c-text);
}

/* ── Responsive (tablet+) ── */
@media (min-width: 600px) {
  #screen-app {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
  }
  #app {
    background: var(--c-bg);
    justify-content: center;
  }
}

/* -- Offline banner (inline, below topbar) -- */
.offline-banner {
  background: var(--c-warning);
  color: white;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}

/* -- Install / push prompt banner (floating bottom) -- */
.install-banner {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 10px);
  left: 12px;
  right: 12px;
  background: var(--c-navy);
  color: white;
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  z-index: 90;
  font-size: 0.9rem;
  font-weight: 500;
  animation: toast-in 0.25s ease;
}
.install-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* -- SW update banner (inline, below topbar) -- */
.update-banner {
  background: var(--c-terra);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
