/* Smart Notes – shared styles, following DESIGN.md.
   Loaded by templates/layout.html, which every page extends. */

/* ---------- Design tokens: every colour and size lives here ---------- */
:root {
  --navy: #1e3a5f;
  --navy-dark: #152b47;
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e3e6eb;
  --summary-bg: #eef4fb;
  --text: #1f2933;
  --muted: #6b7280;
  --tag-bg: #eceff3;

  --overdue: #c0392b;
  --due-soon: #d68910;
  --done: #1e8449;

  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box; /* width includes padding and border: easier layouts */
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--navy);
}

h1 {
  margin: 0 0 1.25rem;
  font-size: 1.6rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

main.container {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

/* ---------- Top bar ---------- */
.topbar {
  color: #fff;
  background: var(--navy);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  min-height: 56px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 6px;
}

.search {
  margin-left: auto; /* pushes the search box to the right */
}

.search input {
  width: 220px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  border: none;
  border-radius: var(--radius);
}

/* Looks like the nav links, but it's a button because logging out is a POST */
.logout {
  padding: 0;
  font: inherit;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  background: none;
  border: none;
}

.logout:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* ---------- Login page ---------- */
.login-box {
  max-width: 360px;
  margin: 3rem auto 0;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  background: var(--navy);
  border: none;
  border-radius: var(--radius);
}

.button:hover {
  background: var(--navy-dark);
}

.button-danger {
  background: var(--overdue);
}

.button-danger:hover {
  background: #a93226;
}

/* ---------- Page header: title on the left, button on the right ---------- */
.page-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- Projects page: sidebar on the left, notes on the right ---------- */
.container-wide {
  max-width: 1100px;
}

.workspace {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}

.sidebar .label {
  display: block;
  margin: 0 0 0.6rem;
}

.project-list {
  padding: 0;
  margin: 0 0 1rem;
  list-style: none;
}

/* Each project is its own white box, stacked with a gap */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.project-list a {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.project-list a:hover {
  border-color: #c9d3e0;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.06);
}

.project-list a[aria-current="page"] {
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.project-list .count {
  font-size: 0.85rem;
  opacity: 0.7;
}

.new-project {
  display: flex;
  gap: 0.4rem;
}

.new-project input {
  flex: 1;
  min-width: 0; /* lets the box shrink inside the narrow sidebar */
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.button-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Add-note box at the top of a project */
/* Add-note box, below the cards */
.quick-add {
  padding: 0.9rem 1rem;
  margin-top: 1.5rem;
}

.quick-add select {
  max-width: 200px;
  padding: 0.45rem 0.6rem;
  margin-right: auto; /* pushes the Save button to the right */
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quick-add textarea {
  width: 100%;
  padding: 0;
  margin-bottom: 0.5rem;
  font: inherit;
  color: var(--text);
  resize: vertical;
  border: none;
  outline: none;
}

.quick-add .form-actions {
  justify-content: flex-end;
}

.empty-hint {
  margin: 0;
}

/* Project name on cards in All notes */
.note-project {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Note cards in a grid: as many 240px+ columns as fit ---------- */
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.note-card {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem 0.8rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.note-card:hover {
  border-color: #c9d3e0;
  box-shadow: 0 4px 14px rgba(30, 58, 95, 0.08);
}

/* The text and date: takes the spare space, so the footer sits at the bottom */
.note-link {
  flex-grow: 1;
  margin-bottom: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.note-text {
  /* Show at most 5 lines, ending with "…" */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  margin: 0 0 0.5rem;
  overflow: hidden;
  white-space: pre-line; /* keep the note's line breaks */
}

.note-card-footer {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  justify-content: space-between;
}

.button-complete {
  flex-shrink: 0;
  white-space: nowrap; /* keep "✓ Complete" on one line */
  padding: 0.2rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--done);
  cursor: pointer;
  background: none;
  border: 1px solid var(--done);
  border-radius: 999px;
}

.button-complete:hover {
  color: #fff;
  background: var(--done);
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  text-decoration: none;
}

/* ---------- Small grey text: dates and labels ---------- */
.muted,
.label {
  font-size: 0.85rem;
  color: var(--muted);
}

.label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Tags and chips ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag,
.chip {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 999px; /* very round = pill shape */
}

.tag {
  color: var(--text);
  background: var(--tag-bg);
}

.chip {
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip-overdue { color: var(--overdue); border-color: var(--overdue); }
.chip-due-soon { color: var(--due-soon); border-color: var(--due-soon); }
.chip-done { color: var(--done); border-color: var(--done); }

/* ---------- AI summary box ---------- */
.summary-box {
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  background: var(--summary-bg);
  border: 1px solid #d6e4f5;
  border-radius: var(--radius);
}

.summary-box p {
  margin: 0.35rem 0 0;
}

.summary-box .answer {
  white-space: pre-wrap; /* keep Claude's line breaks */
}

/* ---------- Note page ---------- */
.page-header .muted {
  display: block;
  margin-top: 0.25rem;
}

.section-heading {
  display: block;
  margin: 0 0 0.6rem;
}

.checklist {
  padding: 0 1.25rem;
  margin: 0 0 2rem;
  list-style: none;
}

.checklist li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

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

.checklist input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.tags + .section-heading,
.muted + .section-heading {
  margin-top: 2rem;
}

.note-body {
  padding: 1rem 1.25rem;
  margin: 0 0 2rem;
  font-family: inherit;
  font-size: 0.95rem;
  white-space: pre-wrap; /* keep line breaks, wrap long lines */
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.form label {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.form input,
.form textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.form input:focus,
.form textarea:focus {
  border-color: var(--navy);
  outline: 2px solid rgba(30, 58, 95, 0.15);
}

.form textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* Ask page: input and button side by side */
.ask-row {
  display: flex;
  gap: 0.5rem;
}

.ask-row input {
  margin-bottom: 0;
}

/* ---------- Spinner: a circle with one coloured side, turning ---------- */
.saving {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
}

.saving[hidden] {
  display: none; /* our display above would otherwise beat the hidden attribute */
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Messages ---------- */
.alert {
  padding: 0.75rem 1rem;
  margin: 0 0 1.5rem;
  color: var(--overdue);
  background: #fdf1ef;
  border: 1px solid #f2c4bd;
  border-radius: var(--radius);
}

/* "Note saved ✓": floats in the top-right corner (so nothing on the page moves),
   waits 3 seconds, then fades out over half a second */
.toast {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 10; /* above the page content */
  padding: 0.6rem 1rem;
  margin: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-weight: 600;
  color: var(--done);
  background: #edf7f0;
  border: 1px solid #bfe3cb;
  border-radius: var(--radius);
  animation: fade-out 0.5s ease 3s forwards;
}

.toast-error {
  color: var(--overdue);
  background: #fdf1ef;
  border-color: #f2c4bd;
}

@keyframes fade-out {
  to { opacity: 0; visibility: hidden; }
}

/* ---------- Ask page sources ---------- */
.source-list {
  padding: 0 1.25rem;
  margin: 0;
  list-style: none;
}

.source-list li {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.source-list a {
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.empty-state .empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Phone screens ---------- */
@media (max-width: 600px) {
  .search {
    width: 100%;
    margin-left: 0;
  }

  .search input {
    width: 100%;
  }

  .ask-row {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Projects become a row of chips instead of a tall list */
  .project-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .project-list a {
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
  }
}
