/* Insights tab — CSS for Stewart's dashboard daily briefing + chat + notes.
   Loaded via <link rel="stylesheet" href="insights.css"> from Fitness_Dashboard.html.
   All variables (--card, --accent, --text, etc.) inherit from the main stylesheet. */

.insights-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .insights-row { grid-template-columns: 1fr; } }

/* Top row: equal-height two-column hero (Today's One Thing + Observations & Insights) */
.insights-toprow { align-items: stretch; }
.insights-equal { display: flex; flex-direction: column; }
.insights-equal .card-title { flex: 0 0 auto; }

/* Full-width briefing card (replaces the old two-column toprow) */
.insights-briefing-card .insights-onething-action,
.insights-briefing-card .insights-onething-why,
.insights-briefing-card .insights-observations { max-width: none; }

/* 2-column inner grid for the four sub-sections (ketosis / glucose / nutrition / movement) */
.insights-subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 800px) { .insights-subgrid { grid-template-columns: 1fr; } }
.insights-subgrid .insights-subsection { margin-top: 0; }  /* override the default 14px gap */

/* On the Insights panel, let the hero subtitle stretch to full width
   so the "reflect on yesterday" intro reads as one wide paragraph */
section[data-panel="insights"] .hero-left { max-width: none; width: 100%; }
section[data-panel="insights"] .hero-sub  { max-width: none; }

.insights-onething-card .insights-onething-action {
  font-size: 18px; font-weight: 700; color: var(--text);
  background: var(--bg-elevated); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 8px; margin-top: 8px;
}
.insights-onething-card .insights-onething-why {
  font-size: 13px; color: var(--text-muted); margin-top: 10px; line-height: 1.55;
}

/* Combined "Observations & Insights" card — sub-sections with color-coded borders */
.insights-subsection {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: var(--bg-elevated); border-left: 3px solid var(--text-dim);
}
.insights-sub-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.insights-sub-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); font-weight: 700;
}
/* Color variants for sub-sections */
.insights-subsection.k-ketosis   { border-left-color: #f87171; }   /* red — out of ketosis tone */
.insights-subsection.k-glucose   { border-left-color: #6db1ff; }   /* blue */
.insights-subsection.k-nutrition { border-left-color: #fbbf24; }   /* amber */
.insights-subsection.k-movement  { border-left-color: #ff6b9d; }   /* coral pink */
/* Override pattern/meaning/action box accents inside each sub-section */
.insights-subsection.k-glucose   .insights-suggest-pattern { border-left-color: #6db1ff; }
.insights-subsection.k-glucose   .insights-suggest-action  { border-left-color: #6db1ff; background: rgba(109,177,255,0.10); }
.insights-subsection.k-nutrition .insights-suggest-pattern { border-left-color: #fbbf24; }
.insights-subsection.k-nutrition .insights-suggest-action  { border-left-color: #fbbf24; background: rgba(251,191,36,0.10); }
.insights-subsection.k-movement  .insights-suggest-pattern { border-left-color: #ff6b9d; }
.insights-subsection.k-movement  .insights-suggest-action  { border-left-color: #ff6b9d; background: rgba(255,107,157,0.10); }

.insights-ketosis-status {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700;
  margin: 8px 0 10px 0;
}
.insights-ketosis-status.k-out         { background: rgba(248,113,113,0.18); color: #f87171; }
.insights-ketosis-status.k-approaching { background: rgba(251,191,36,0.20); color: #fbbf24; }
.insights-ketosis-status.k-in          { background: rgba(52,211,153,0.20); color: #34d399; }
.insights-ketosis-blockers { margin: 0 0 8px 0; padding: 0; list-style: none; }
.insights-ketosis-blockers li {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.5;
  padding: 4px 0 4px 14px; position: relative;
}
.insights-ketosis-blockers li::before {
  content: '\00d7'; position: absolute; left: 0; color: #f87171; font-weight: 700;
}
.insights-ketosis-fix {
  font-size: 13px; color: var(--text);
  background: rgba(180,240,74,0.10); border-left: 3px solid var(--accent);
  padding: 8px 12px; border-radius: 8px; margin-top: 8px;
}

.insights-checkin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; margin-top: 8px; }
@media (max-width: 700px) { .insights-checkin-grid { grid-template-columns: 1fr; } }

/* New typed check-in sections — sliders 2-col, numbers/texts/bools 3-col */
.insights-checkin-section { display: grid; gap: 10px 14px; margin-top: 10px; }
.insights-checkin-section.sliders-grid { grid-template-columns: repeat(3, 1fr); }
.insights-checkin-section.numbers-grid { grid-template-columns: repeat(3, 1fr); }
.insights-checkin-section.texts-grid   { grid-template-columns: repeat(3, 1fr); }
.insights-checkin-section.bools-grid   { grid-template-columns: repeat(3, 1fr); gap: 10px 20px; }
@media (max-width: 700px) {
  .insights-checkin-section.sliders-grid,
  .insights-checkin-section.numbers-grid,
  .insights-checkin-section.texts-grid,
  .insights-checkin-section.bools-grid { grid-template-columns: 1fr; }
}
.insights-checkin-field { display: flex; flex-direction: column; gap: 4px; }
.insights-checkin-field label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim); font-weight: 700;
}
.insights-checkin-field input[type="text"],
.insights-checkin-field input[type="number"],
.insights-checkin-field input[type="range"] {
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-family: inherit; width: 100%;
}
.insights-checkin-field .range-row { display: flex; align-items: center; gap: 8px; }
.insights-checkin-field .range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.insights-checkin-field .range-row .range-value {
  font-size: 13px; color: var(--accent); font-weight: 700; min-width: 28px; text-align: right;
}
.insights-checkin-field .bool-row { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.insights-checkin-field .bool-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}
.insights-checkin-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap;
}

.insights-observations { margin: 8px 0 0 0; padding-left: 20px; }
.insights-observations li {
  font-size: 13px; color: var(--text); line-height: 1.55; margin-bottom: 8px;
}

/* Suggestion cards (glucose insight, nutrition suggestion, workout suggestion) */
.insights-suggest-pattern {
  font-size: 14px; font-weight: 700; color: var(--text);
  background: var(--bg-elevated); border-left: 3px solid var(--accent);
  padding: 8px 12px; border-radius: 8px; margin-top: 8px;
}
.insights-suggest-meaning {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.5;
  padding: 6px 12px 0 12px; margin-top: 6px;
}
.insights-suggest-action {
  font-size: 12.5px; color: var(--text); line-height: 1.5;
  background: rgba(180,240,74,0.08); border-left: 3px solid var(--accent);
  padding: 6px 12px; border-radius: 8px; margin-top: 8px; font-style: italic;
}

.insights-chat-log {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px; margin-top: 8px;
  max-height: 480px; overflow-y: auto;
}
.insights-chat-log:empty::before {
  content: 'Ask your first question below.'; color: var(--text-dim);
  font-size: 12.5px; font-style: italic;
}
.insights-chat-turn {
  font-size: 13.5px; line-height: 1.55; padding: 10px 12px; border-radius: 10px;
  white-space: pre-wrap; word-wrap: break-word;
}
.insights-chat-turn.user      { background: rgba(109,177,255,0.10); border-left: 3px solid #6db1ff; align-self: flex-end; max-width: 92%; }
.insights-chat-turn.assistant { background: var(--card); border-left: 3px solid var(--accent); align-self: flex-start; max-width: 92%; }
.insights-chat-turn .turn-role {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim); font-weight: 700; margin-bottom: 4px;
}
.insights-chat-form { display: flex; gap: 8px; margin-top: 10px; }
.insights-chat-input {
  flex: 1; background: var(--card); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; font-family: inherit;
}
.insights-chat-input:focus { outline: none; border-color: var(--accent); }
.insights-chat-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; font-size: 10.5px; color: var(--text-dim);
}
.insights-chat-newbtn {
  background: none; border: 1px solid var(--border-soft); color: var(--text-dim);
  font-size: 10.5px; padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.insights-chat-newbtn:hover { color: var(--accent); border-color: var(--accent); }

.insights-note-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.insights-note-form textarea {
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; font-family: inherit;
  min-height: 80px; resize: vertical;
}
.insights-note-form textarea:focus { outline: none; border-color: var(--accent); }
.insights-note-form button { align-self: flex-start; }
.insights-notes-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.insights-note-item {
  background: var(--bg-elevated); border-left: 3px solid var(--text-dim);
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px; color: var(--text); line-height: 1.5;
}
.insights-note-item .note-ts {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim); font-weight: 700; margin-bottom: 4px;
}

.insights-tools-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.insights-tools-row select {
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
}


/* ==== Insights tab "Today" snapshot: 6-tile grid (2026-05-29) ==== */
.insights-today-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; padding: 6px 4px;
  gap: 12px;
}
.insights-today-title {
  font-size: 11px; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
}
.insights-today-title #insights-today-time {
  color: var(--text); font-weight: 700; text-transform: none;
  letter-spacing: 0.5px; margin-left: 4px;
}

.insights-today-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}
@media (max-width: 1200px) { .insights-today-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .insights-today-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.it-tile {
  padding: 12px 14px;
  border-left: 3px solid var(--text-dim);
  transition: border-color 0.2s, background 0.2s;
}
.it-label {
  font-size: 10px; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
}
.it-value {
  font-size: 19px; color: var(--text); font-weight: 800;
  margin-top: 6px; line-height: 1.2; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
/* State color variants — applied by pillSet() in insights.js */
.it-tile.s-done    { border-left-color: #34d399; background: rgba(52,211,153,0.06); }
.it-tile.s-done    .it-value { color: #34d399; }
.it-tile.s-warn    { border-left-color: #fbbf24; background: rgba(251,191,36,0.07); }
.it-tile.s-warn    .it-value { color: #fbbf24; }
.it-tile.s-bad     { border-left-color: #f87171; background: rgba(248,113,113,0.08); }
.it-tile.s-bad     .it-value { color: #f87171; }
.it-tile.s-pending { border-left-color: var(--text-dim); }
.it-tile.s-pending .it-value { color: var(--text-muted); }

.insights-refresh-btn {
  background: var(--accent); color: #0a0f0d;
  border: 0; border-radius: 6px; padding: 5px 12px;
  font-family: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px; cursor: pointer;
}
.insights-refresh-btn:hover { filter: brightness(1.1); }


/* ==== Today's One Thing briefing card styling (2026-05-29) ====
   The JS uses .insights-briefing-card (not .insights-onething-card). The
   old rules at lines 28-35 under .insights-onething-card are unreachable
   leftovers; these rules give the actual rendered card visual hierarchy. */
.insights-briefing-card > .card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.insights-briefing-card .insights-onething-action {
  font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.4;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 8px;
  margin-top: 8px;
}
.insights-briefing-card .insights-onething-why {
  font-size: 13px; color: var(--text-muted); line-height: 1.55;
  margin-top: 10px;
  padding: 0 4px;
}
.insights-briefing-card .insights-quick-obs {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.insights-briefing-card .insights-quick-obs .iqo-line {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.55;
}
.insights-briefing-card .insights-toggle-detail {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.insights-briefing-card .insights-toggle-detail:hover {
  background: rgba(180,240,74,0.08);
  border-color: var(--accent);
}
.insights-briefing-card .ito-chevron {
  font-size: 13px; line-height: 1;
}
.insights-briefing-card .insights-detail-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-soft);
}
.insights-briefing-card .insights-detail-wrap > .card-title {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 1.5px;
}
.insights-briefing-card .insights-detail-wrap > .card-title:first-child {
  margin-top: 0;
}
.insights-briefing-card .insights-observations {
  margin: 6px 0 0 0; padding-left: 0; list-style: none;
}
.insights-briefing-card .insights-observations li {
  font-size: 13px; color: var(--text-muted); line-height: 1.55;
  padding: 4px 0 4px 16px; position: relative;
}
.insights-briefing-card .insights-observations li::before {
  content: '\2022'; position: absolute; left: 4px;
  color: var(--accent); font-weight: 700;
}


/* ==== Nutrition water tracker card (2026-05-29) ====
   The dial SVG was unconstrained, scaling to fill available width and
   dragging the whole .nutrition-targets-row to ~700px tall via
   align-items:stretch. Capping the dial and styling the row/buttons brings
   the card back to the same height as the other two in the row. */
.nutrition-water-card {
  padding: 14px 16px;
}
.nutrition-water-card .card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.nwc-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nwc-dial {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}
.nwc-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.nwc-status {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nwc-btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.iw-btn, .iw-btn-mini {
  background: var(--accent);
  color: #0a0f0d;
  border: 0;
  border-radius: 6px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.4px;
  transition: filter 0.15s;
}
.iw-btn:hover, .iw-btn-mini:hover { filter: brightness(1.1); }
.iw-btn:active, .iw-btn-mini:active { filter: brightness(0.92); }
.iw-btn:disabled, .iw-btn-mini:disabled {
  background: var(--bg-elevated); color: var(--text-dim);
  cursor: not-allowed; opacity: 0.6;
}
.nwc-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 2px;
}
