/* ==========================================================================
   Notes — Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design Tokens
   -------------------------------------------------------------------------- */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #121212;
  --text-light: #5a5a5a;
  --text-faint: #999999;
  --accent: #326891;
  --accent-light: #e8f0f8;
  --border: #dfdfdf;
  --border-light: #ebebeb;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --orange: #e65100;
  --orange-light: #fff3e0;
  --red: #c62828;
  --red-light: #ffebee;

  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", Menlo, Consolas, monospace;

  --measure: 72rem;
  --gutter: 1.5rem;
  --sidebar-w: 240px;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   App Layout — sidebar + content
   -------------------------------------------------------------------------- */

.appLayout {
  display: flex;
  height: 100vh;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.sidebarTitle {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebarLink {
  font-size: 0.75rem;
  color: var(--text-faint);
}

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

.sidebarNav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

/* Outline-style nav items */
.navItem {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition:
    background 0.1s,
    color 0.1s,
    border-color 0.1s;
}

.navItem:hover {
  background: var(--accent-light);
  color: var(--text);
  text-decoration: none;
}

.navItem.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-light);
}

.navChild {
  display: block;
  padding: 0.3rem 1rem 0.3rem 1.75rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-faint);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition:
    background 0.1s,
    color 0.1s;
}

.navChild:hover {
  background: var(--accent-light);
  color: var(--text-light);
  text-decoration: none;
}

.navChild.active {
  color: var(--accent);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Content area
   -------------------------------------------------------------------------- */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contentHeader {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.contentMain {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter);
  max-width: var(--measure);
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

.section {
  margin-bottom: 2rem;
}

.sectionHeader {
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.sectionDeck {
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--text-light);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Subsections
   -------------------------------------------------------------------------- */

.subsection {
  margin-bottom: 2rem;
}

.subsectionTitle {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--accent);
}

/* --------------------------------------------------------------------------
   Stat Cards
   -------------------------------------------------------------------------- */

.statsRow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.statCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 4px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.statCard:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.statValue {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
}

.statLabel {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-color: var(--border-light);
}

.cardTitle {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.cardMeta {
  font-size: 0.85rem;
  color: var(--text-light);
}

.cardBody {
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.cardExpandable {
  cursor: pointer;
}

.cardDetail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.cardDetail > * {
  overflow: hidden;
}

.cardExpandable.open .cardDetail {
  grid-template-rows: 1fr;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.cardToggle {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.5rem;
}

.cardToggle::before {
  content: "\25B8  ";
}

.cardExpandable.open .cardToggle::before {
  content: "\25BE  ";
}

.cardGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Net Worth
   -------------------------------------------------------------------------- */

.netWorth {
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.netWorthValue {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 700;
}

.netWorthValue.positive {
  color: var(--green);
}
.netWorthValue.negative {
  color: var(--red);
}

.netWorthLabel {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Bar Charts
   -------------------------------------------------------------------------- */

.barRow {
  display: flex;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 0.75rem;
}

.barLabel {
  flex: 0 0 120px;
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barTrack {
  flex: 1;
  height: 20px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.barFill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.6s ease;
}

.barFill.high {
  background: var(--orange);
}
.barFill.full {
  background: var(--red);
}

.barAmount {
  flex: 0 0 100px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Filters & Search
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filterPill {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.filterPill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filterPill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.searchInput {
  width: 100%;
  max-width: 360px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 1rem;
}

.searchInput:focus {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Tags
   -------------------------------------------------------------------------- */

.tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 3px;
  background: var(--accent-light);
  color: var(--accent);
  vertical-align: middle;
}

.tagGreen {
  background: var(--green-light);
  color: var(--green);
}

.tagOrange {
  background: var(--orange-light);
  color: var(--orange);
}

.tagRed {
  background: var(--red-light);
  color: var(--red);
}

.tagBlue {
  background: #e3f2fd;
  color: #1565c0;
}

.tagGray {
  background: #f5f5f5;
  color: #757575;
}

.groupTag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  border-radius: 100px;
  margin: 0.15rem 0.15rem;
  background: #f0e6f6;
  color: #6a1b9a;
}

.groupTag.subject {
  background: #e3f2fd;
  color: #1565c0;
}

.groupTag.quality {
  background: #fff8e1;
  color: #f57f17;
}

.groupTag.list {
  background: var(--green-light);
  color: var(--green);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.paginationInfo {
  font-size: 0.85rem;
  color: var(--text-light);
}

.filterPill:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.sortSelect {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-light);
  outline: none;
  cursor: pointer;
  margin-bottom: 1rem;
}

.sortSelect:focus {
  border-color: var(--accent);
}

.toggleBtn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 0.75rem;
}

.toggleBtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.dataTable th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--text);
}

.dataTable td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.dataTable tr:hover td {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   Item Lists
   -------------------------------------------------------------------------- */

.itemList {
  list-style: none;
}

.itemList li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95rem;
}

.itemList li:last-child {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Todos
   -------------------------------------------------------------------------- */

.todoItem {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.todoItem:last-child {
  border-bottom: none;
}

.todoCheck {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 3px;
}

.todoItem.completed .todoCheck {
  background: var(--green);
  border-color: var(--green);
}

.todoItem.completed .todoText {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Meal Plan
   -------------------------------------------------------------------------- */

.mealPlanGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.mealDay {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
}

.mealDayName {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-light);
}

.mealDay .itemList li {
  font-size: 0.9rem;
  padding: 0.2rem 0;
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Recipes
   -------------------------------------------------------------------------- */

.recipeIngredients {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.recipeIngredients li {
  padding: 0.15rem 0;
}

.recipeSteps {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.recipeSteps li {
  padding: 0.25rem 0;
}

/* --------------------------------------------------------------------------
   Ask Box
   -------------------------------------------------------------------------- */

.askBox {
  padding: 0.6rem var(--gutter);
}

.askRow {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  position: relative;
}

.askInput {
  flex: 1;
  padding: 0.55rem 0.75rem 0.55rem 2rem;
  font-size: 0.9rem;
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.askInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.askIcon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-faint);
  pointer-events: none;
}

.askKbd {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-faint);
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  line-height: 1.4;
  white-space: nowrap;
  user-select: none;
}

.askButton {
  padding: 0.55rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--sans);
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.askButton:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.askButton:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* spinner */
.askSpinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: askSpin 0.6s linear infinite;
}

.askButton:disabled .askSpinner {
  display: inline-block;
}

@keyframes askSpin {
  to {
    transform: rotate(360deg);
  }
}

.askOutput {
  display: none;
}

.askOutput.hasResponse,
.askOutput.hasError {
  display: block;
  margin-top: 0.6rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  animation: askFadeIn 0.3s ease;
}

.askOutput.hasResponse {
  border-left: 3px solid var(--green);
}

.askOutput.hasError {
  color: var(--red);
  background: var(--red-light);
  border-color: var(--red);
  border-left: 3px solid var(--red);
}

@keyframes askFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.askDebugRow {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.askDebugToggle {
  display: none;
  cursor: pointer;
  font-family: var(--mono, monospace);
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 0.2rem 0.45rem;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  user-select: none;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.askDebugToggle.visible {
  display: inline-block;
}

.askDebugToggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.askDebug {
  display: none;
  width: 100%;
  margin-top: 0.5rem;
  padding: 1rem;
  font-family: var(--mono, monospace);
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 400px;
}

.askDebug.open {
  display: block;
}

/* Ask history dropdown */
.askHistoryList {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
}

.askHistoryItem {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--sans);
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
}

.askHistoryItem:last-child {
  border-bottom: none;
}

.askHistoryItem:hover,
.askHistoryItem.highlighted {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   Global Search
   -------------------------------------------------------------------------- */

.searchOverlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: overlayFadeIn 0.15s ease;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.searchPalette {
  width: 90%;
  max-width: 560px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.15),
    0 0 0 1px var(--border);
  overflow: hidden;
  animation: paletteSlideIn 0.2s ease;
}

@keyframes paletteSlideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.searchPaletteInput {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-family: var(--sans);
  border: none;
  border-bottom: 1px solid var(--border-light);
  outline: none;
  background: transparent;
}

.searchResults {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.searchResultItem {
  display: block;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
  border-bottom: 1px solid var(--border-light);
}

.searchResultItem:last-child {
  border-bottom: none;
}

.searchResultItem:hover,
.searchResultItem.highlighted {
  background: var(--accent-light);
  text-decoration: none;
}

.searchResultSection {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-right: 0.5rem;
}

.searchResultTitle {
  font-weight: 500;
}

.searchResultMeta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.15rem;
}

.searchEmpty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.searchHint {
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border-light);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Loading & Error
   -------------------------------------------------------------------------- */

.loading {
  text-align: center;
  padding: 4rem 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-light);
  font-size: 1.1rem;
}
