/* app.css — layered on top of styles.css for the authenticated app. */

/* ---------- Home ---------- */
.home-welcome { text-align: center; padding: 8px 0 24px; }
.welcome-heading {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 600; letter-spacing: -.005em;
  margin: 0;
}

.quick-tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin: 0 auto 40px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px 12px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--ink); font: inherit; cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}
.tile:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.tile-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  font-family: var(--font-serif);
}
.tile-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.home-grid {
  display: grid; grid-template-columns: 1fr 340px; gap: 28px;
  margin-bottom: 40px;
}

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.section-head h3 {
  font-family: var(--font-serif);
  font-size: 20px; font-weight: 600; margin: 0;
}
.see-all { font-size: 13px; font-weight: 600; color: var(--accent-deep); }

/* --- Updates --- */
.update-list { display: grid; gap: 10px; }
.update-card {
  display: grid; grid-template-columns: 40px 1fr; gap: 14px;
  padding: 14px 16px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.update-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; margin-top: 2px;
}
.update-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 4px;
}
.update-kind {
  text-transform: uppercase; letter-spacing: .1em;
  font-size: 11px; font-weight: 700; color: var(--accent-deep);
}
.update-when { font-size: 12px; color: var(--muted); }
.update-content {
  margin: 0; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.update-attribution { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.empty-state.small {
  padding: 24px 20px; text-align: center;
  background: var(--bg-tint); border-radius: var(--radius);
}

/* --- Care team --- */
.care-team {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px; height: fit-content;
}
.care-list { display: grid; gap: 10px; margin-bottom: 14px; }
.care-card {
  display: grid; grid-template-columns: 44px 1fr; gap: 12px;
  align-items: center;
  padding: 10px; border-radius: var(--radius-sm);
  background: var(--bg-tint);
}
.care-card.you { background: var(--accent-soft); }
.care-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 18px; font-weight: 700;
}
.care-card.placeholder .care-avatar {
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line);
}
.care-name { margin: 0; font-weight: 600; font-size: 14px; }
.care-role { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.care-note {
  font-size: 12px; color: var(--muted); margin: 12px 0 0;
  padding-top: 12px; border-top: 1px solid var(--line);
}

/* --- Morning routine widget --- */
.morning-panel .home-med-app {
  /* fill the column instead of the landing-page 380px max-width */
  max-width: none;
  margin: 0;
}

@media (max-width: 880px) {
  .home-grid { grid-template-columns: 1fr; }
  .care-team { order: 2; }
}
@media (max-width: 640px) {
  .quick-tiles { grid-template-columns: repeat(3, 1fr); }
}


.site-nav .tab {
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.site-nav .tab.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}
.who {
  font-size: 12px;
  color: var(--muted);
  text-transform: lowercase;
}

.child-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 20px 0 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.banner-meta {
  display: flex; align-items: center; gap: 14px;
}

/* ---------- Child switcher ---------- */
.child-title { position: relative; }
.child-name-row {
  display: flex; align-items: center; gap: 10px;
}
.switch-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.switch-btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}
.child-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  min-width: 260px; max-width: 340px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
}
.child-menu button {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  padding: 10px 12px; border: 0; background: transparent;
  border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); cursor: pointer;
}
.child-menu button:hover { background: var(--bg-tint); }
.child-menu .selected { color: var(--accent-deep); font-weight: 600; }
.child-menu .selected::after { content: "✓"; color: var(--accent); }
.child-menu .divider { height: 1px; background: var(--line); margin: 6px 4px; }
.child-menu .add-btn { color: var(--accent-deep); font-weight: 600; }

.section-title {
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 600; margin: 0 0 16px;
}

/* ---------- Timeline ---------- */
.timeline { display: grid; gap: 12px; }
.timeline-item {
  display: grid; grid-template-columns: 180px 1fr; gap: 20px;
  padding: 18px 22px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.timeline-item.medication { background: var(--bg-tint); }
.ti-when {
  color: var(--muted); font-size: 13px; padding-top: 2px;
  border-right: 1px solid var(--line); padding-right: 20px;
}
.ti-kind {
  text-transform: uppercase; letter-spacing: .12em;
  font-size: 11px; font-weight: 700; color: var(--accent-deep);
  margin-bottom: 6px;
}
.ti-content { color: var(--ink); white-space: pre-wrap; }
.ti-view { position: relative; padding-right: 160px; }
.ti-head { margin-bottom: 6px; }
.ti-actions {
  position: absolute;
  top: 50%; right: 0;
  transform: translateY(-50%);
  display: flex; gap: 8px; flex-shrink: 0;
}
.ti-actions .btn { padding: 5px 11px; font-size: 11px; }
.ti-link {
  background: transparent; border: 0; padding: 0;
  color: var(--accent-deep); font: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.ti-link:hover { color: var(--accent); text-decoration: underline; }
.ti-link-danger { color: #b91c1c; }
.ti-link-danger:hover { color: #7f1d1d; }
.ti-attribution {
  margin: 6px 0 0; font-size: 12px; color: var(--muted); font-style: italic;
}
.ti-edit label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--ink); margin: 10px 0 4px;
}
.ti-edit input, .ti-edit select, .ti-edit textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--ink);
  background: #fff; outline: 0;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.ti-edit input:focus, .ti-edit select:focus, .ti-edit textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ti-edit-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.empty { color: var(--muted); font-style: italic; }
.empty-state {
  text-align: center; padding: 48px 24px;
  background: var(--bg-tint); border-radius: var(--radius);
  display: grid; gap: 14px; justify-items: center;
}
.empty-state p { margin: 0; color: var(--ink-soft); }

/* ---------- Medications tab ---------- */
.med-card { position: relative; }
.med-card h3 { margin: 0 0 6px; font-size: 17px; }
.med-card p  { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }
.med-card .btn { padding: 6px 12px; font-size: 12px; }
.med-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.med-edit label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--ink); margin: 10px 0 4px;
}
.med-edit input {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--ink);
  background: #fff; outline: 0;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.med-edit input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.med-edit .med-actions { margin-top: 14px; }

@media (max-width: 720px) {
  .child-banner { flex-direction: column; align-items: flex-start; }
  .timeline-item { grid-template-columns: 1fr; gap: 8px; }
  /* On narrow screens don't reserve space on the right — buttons stack under the content */
  .ti-view { padding-right: 0; }
  .ti-actions { position: static; transform: none; margin-top: 8px; }
  .ti-when { border-right: 0; padding-right: 0;
             border-bottom: 1px solid var(--line); padding-bottom: 6px; }
}

/* ---------- Guided tutorial overlay ---------- */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 1000;
  pointer-events: none;
}
.tutorial-spotlight {
  position: absolute;
  border-radius: 12px;
  box-shadow:
    0 0 0 4px var(--accent),
    0 0 0 9999px rgba(15, 29, 22, 0.55);
  pointer-events: none;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease, opacity .2s ease;
}
.tutorial-tooltip {
  position: absolute;
  width: 320px; max-width: calc(100vw - 32px);
  background: #ffffff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 20px;
  pointer-events: auto;
  transition: top .25s ease, left .25s ease;
}
.tutorial-title {
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.tutorial-body {
  margin: 0 0 18px; color: var(--ink-soft);
  font-size: 14px; line-height: 1.55;
}
.tutorial-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.tutorial-skip {
  background: transparent; border: 0; padding: 0;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.tutorial-skip:hover { color: var(--ink); text-decoration: underline; }
.tutorial-progress {
  font-size: 12px; color: var(--muted); margin-right: 10px;
}

/* ---------- Onboarding: tracker groups (step 6) ---------- */
.tracker-group {
  margin: 20px 0 8px;
  padding: 16px 18px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}
.tracker-cat {
  font-size: 15px; font-weight: 700; margin: 0 0 10px;
  color: var(--accent-deep);
}
.tracker-items {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
@media (max-width: 640px) { .tracker-items { grid-template-columns: 1fr; } }
.tracker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; cursor: pointer;
  font-size: 14px; color: var(--ink);
}
.tracker-item input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
  flex-shrink: 0;
}
.tracker-item-text {
  flex: 1;
  line-height: 1.35;
}
.tracker-item .tracker-custom-tag {
  font-size: 11px; font-weight: 600;
  background: #eef2f7; color: var(--accent-deep);
  padding: 1px 6px; border-radius: 4px;
  margin-left: 6px;
}
.add-own {
  margin-top: 6px; padding: 4px 10px !important;
}

/* Info "?" icon + hover popover on tracker rows */
.tracker-info {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}
.tracker-info-btn {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12px; font-weight: 700;
  line-height: 18px; text-align: center; padding: 0;
  cursor: help;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.tracker-info-btn:hover,
.tracker-info-btn:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  outline: none;
}
.tracker-info-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 240px;
  max-width: 300px;
  padding: 12px 14px;
  background: #0f2a4a;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(15, 42, 74, 0.25);
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease, visibility .12s;
  pointer-events: none;
}
.tracker-info-pop::before {
  /* Little navy triangle pointing up at the "?" icon. */
  content: "";
  position: absolute;
  top: -6px;
  right: 8px;
  border: 6px solid transparent;
  border-bottom-color: #0f2a4a;
}
.tracker-info:hover .tracker-info-pop,
.tracker-info:focus-within .tracker-info-pop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.tracker-info-def {
  display: block;
  color: #fff;
  margin-bottom: 6px;
}
.tracker-info-ex {
  display: block;
  color: #cddaf0;
  font-size: 12px;
}
.tracker-info-ex strong {
  color: #fff;
  font-weight: 600;
  margin-right: 4px;
}
@media (max-width: 640px) {
  .tracker-info-pop {
    right: auto; left: 0;
    min-width: 220px;
  }
  .tracker-info-pop::before {
    right: auto; left: 8px;
  }
}

/* ---------- Log form: marker chips ---------- */
.marker-tabs {
  display: flex; gap: 6px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 10px;
}
.marker-tab {
  background: transparent; border: 0; padding: 8px 12px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.marker-tab.active {
  color: var(--accent-deep); border-bottom-color: var(--accent);
}
.marker-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.marker-chips[hidden] { display: none; }
.marker-chip {
  border: 1px solid #d1d5db; background: #fff; color: var(--ink);
  border-radius: 999px; padding: 5px 12px;
  font-size: 13px; cursor: pointer; font-family: inherit;
  transition: background .1s ease, border-color .1s ease;
}
.marker-chip:hover { border-color: var(--accent); }
.marker-chip.selected {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ---------- Danger zone (Profile → Delete child) ---------- */
.danger-zone {
  margin-top: 40px;
  padding: 20px 22px;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  background: #fef2f2;
  max-width: 640px;
}
.danger-zone h3 {
  margin: 0 0 8px;
  font-size: 15px; font-weight: 700;
  color: #991b1b;
}
.danger-zone p {
  margin: 0 0 14px;
  font-size: 13px; color: #7f1d1d;
  line-height: 1.5;
}
.btn-danger {
  background: #dc2626; color: #fff; border: 1px solid #dc2626;
  padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
  font-family: inherit;
}
.btn-danger:hover  { background: #b91c1c; border-color: #b91c1c; }
.btn-danger:focus-visible { outline: 2px solid #7f1d1d; outline-offset: 2px; }

/* ---------- Log form: entry type picker ---------- */
.entry-type-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 6px 0 20px;
}
@media (max-width: 640px) { .entry-type-group { grid-template-columns: 1fr 1fr; } }
.entry-type-btn {
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color .12s ease, background .12s ease, transform .1s ease;
}
.entry-type-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.entry-type-btn.selected {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}

/* ---------- Log form: textarea + voice button ---------- */
.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-right: 96px; }
.mic-btn {
  position: absolute;
  top: 10px; right: 10px;
  padding: 6px 10px 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.mic-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.mic-btn .mic-icon { font-size: 14px; line-height: 1; }
.mic-btn.listening {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);    }
}

/* ---------- Log form: ABC-method tip (behavior only) ---------- */
.abc-tip {
  background: #edf1f7;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 8px 0 18px;
  color: #1f2b3d;
  font-size: 14px;
  line-height: 1.55;
  border-left: 3px solid var(--accent-2);
}
.abc-tip p { margin: 0; }
.abc-tip strong { color: #0f2a4a; font-weight: 700; }

/* ---------- Home sidebar: Incident Flag widget ---------- */
.incident-flag {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 22px 22px 20px; height: fit-content;
}
.incident-flag h3 {
  font-family: var(--font-serif);
  font-size: 20px; font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}
.incident-flag p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.incident-flag select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit; font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='%236b7a70' d='M5 8l5 5 5-5H5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 34px;
}
.incident-flag select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}
.incident-flag .btn-danger {
  width: 100%;
  padding: 12px 18px;
  border-radius: 10px;
  background: #d9b3b3;
  border-color: #d9b3b3;
  color: #fff;
  font-weight: 600;
}
.incident-flag .btn-danger:not(:disabled):hover {
  background: #c48a8a; border-color: #c48a8a;
}
.incident-flag .btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.incident-flag .form-note { margin-top: 12px; font-weight: 600; }
