/* Mother Nature's Landscapes — Job Planner.
   Mobile-first: base styles target phones on site (big touch targets, high
   contrast in sunlight); desktop refinements live in the min-width queries.
   Brand: deep green #3d5221, warm cream #e9e7db, Poppins, minimalist + airy. */

/* ---------- Fonts (self-hosted, works with patchy site reception) ---------- */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/poppins-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/poppins-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/poppins-700.woff2') format('woff2');
}

:root {
  --brand: #3d5221;        /* deep forest green */
  --brand-deep: #2e3f18;
  --cream: #e9e7db;        /* warm cream page background */
  --card: #fbfaf5;         /* warm white cards */
  --border: #d8d4c4;
  --ink: #141414;
  --ink-soft: #5d6152;
  --leaf: #79a63f;         /* bright leaf accent */
  --leaf-soft: #e4ecd3;
  --sage: #96a487;
  --danger: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(46, 63, 24, 0.10), 0 1px 2px rgba(46, 63, 24, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Headings: Poppins bold, roughly double the body. Subheadings (h2) follow the
   brand rule: uppercase, body size, letterspaced. */
h1 { font-size: 1.7rem; font-weight: 700; color: var(--brand); margin: 0 0 0.5rem; line-height: 1.25; }
h2 { font-size: 0.95rem; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.8rem; }
a { color: inherit; }

/* ---------- Top navigation ---------- */
.topnav {
  background: var(--brand);
  color: #fff;
  padding: 0.7rem 1rem 0.75rem;
}
.topnav-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.brand { text-decoration: none; color: #fff; display: flex; align-items: center; gap: 0.6rem; }
/* The logo is green + black, so it sits on a small cream panel (same treatment
   as the brand's proposal covers) to stay readable on the dark green bar. */
.brand-logo {
  height: 34px;
  width: auto;
  background: var(--cream);
  padding: 5px 10px;
  border-radius: 10px;
  box-sizing: content-box;
  display: block;
}
.brand-sub { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.22em; color: #c9d3b1; }
.nav-right { display: flex; align-items: center; gap: 0.6rem; }
.nav-user { color: #dfe5d2; text-decoration: none; font-size: 0.85rem; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.logout-form button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
  white-space: nowrap;
}
/* Small phones: the logo chip is the brand — drop the text next to it. */
@media (max-width: 460px) {
  .brand-sub { display: none; }
}
.logout-form button:hover { background: rgba(255, 255, 255, 0.12); }

.nav-links { display: flex; gap: 0.45rem; margin-top: 0.7rem; }
.nav-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  color: #eef0e6;
  font-weight: 600;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 10px;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* ---------- Page container ---------- */
.page { max-width: 960px; margin: 0 auto; padding: 1.1rem 1rem 4.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 480px; }
.notice { background: var(--leaf-soft); border: 1px solid var(--sage); color: var(--brand); padding: 0.7rem 0.9rem; border-radius: 10px; }
.hint { color: var(--ink-soft); font-size: 0.85rem; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.8rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.85rem; margin: 0.85rem 0 0.3rem; color: var(--brand); }
input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem; /* 16px+ stops iOS zooming the page on focus */
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--leaf); outline-offset: 1px; border-color: var(--leaf); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0.25rem 1rem; }
.form-actions { margin-top: 0.9rem; }
.form-error { background: #fbeeed; border: 1px solid #e5b5b1; color: var(--danger); padding: 0.7rem 0.9rem; border-radius: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--brand);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--leaf-soft); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-danger { color: var(--danger); border-color: #e0c0bd; }
.btn-danger:hover { background: #fbeeed; }

/* ---------- Login (styled like the brand's proposal cover) ---------- */
.login-body {
  margin: 0;
  font-family: 'Poppins', -apple-system, sans-serif;
  background: var(--brand);
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.login {
  background: var(--cream);
  border-radius: 16px;
  padding: 2rem 1.6rem;
  width: 100%;
  max-width: 400px;
}
.login-logo { display: block; width: min(250px, 78%); height: auto; margin: 0 auto 1.5rem; }
.login-title { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--brand); }
.login-sub { color: var(--ink-soft); margin: 0.1rem 0 0.75rem; font-size: 0.9rem; }
.login button { margin-top: 1.4rem; }
.login-note { color: var(--ink-soft); font-size: 0.82rem; margin-top: 1.1rem; text-align: center; }

/* ---------- Badges + pills ---------- */
.badge { display: inline-block; padding: 0.16rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: capitalize; }
.badge-admin { background: var(--brand); color: #fff; }
.badge-crew { background: var(--leaf-soft); color: var(--brand); }
.badge-status { background: #eceadf; color: var(--ink-soft); }

.status-not_started, .status-pending { background: #eceadf; color: var(--ink-soft); }
.status-in_progress { background: #f2ecd4; color: #6b5b1e; }
.status-completed { background: var(--leaf-soft); color: var(--brand); }

.pill { display: inline-block; padding: 0.08rem 0.5rem; border-radius: 999px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; vertical-align: middle; }
.pill-today { background: var(--leaf); color: #fff; }
.pill-overdue { background: #f6dedc; color: var(--danger); }
.pill-carried { background: #f2ecd4; color: #6b5b1e; }
/* Planned multi-day work reads as calm/on-track — deliberately NOT the amber
   "carried" warning, so on-plan and behind-schedule look different at a glance. */
.pill-span { background: var(--leaf-soft); color: var(--brand); }
.days-input { max-width: 4.5rem; flex: 0 0 auto; text-align: center; }
.pill-blocked { background: #f6dedc; color: var(--danger); }
.done-by { font-size: 0.75rem; color: #4c6b23; font-weight: 600; white-space: nowrap; }

/* ---------- Tables (stacked cards on mobile by default) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table, .table tbody, .table tr, .table td { display: block; width: 100%; }
.table tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.75rem; padding: 0.6rem 0.7rem; background: #fff; }
.table td { border: none; padding: 0.3rem 0.15rem; }
.table td::before {
  content: attr(data-label);
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
}
.row-inactive { color: var(--ink-soft); background: #f4f2e9; }

/* ---------- Disclosure chips (Manage / notes / blocked) ---------- */
details summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: #eceadf;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.82rem;
  user-select: none;
}
details[open] summary { background: var(--leaf-soft); }
.action-panel { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; }
.inline-form { display: flex; gap: 0.45rem; align-items: center; margin: 0; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; flex: 1 1 auto; min-width: 130px; }
.inline-label { font-size: 0.8rem; color: var(--ink-soft); margin: 0; font-weight: 400; }
details.card summary { background: none; padding: 0; min-height: 0; border-radius: 0; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; }
details.card hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Job list ---------- */
.job-list { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }
.job-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
}
.job-card:hover { box-shadow: 0 4px 14px rgba(46, 63, 24, 0.16); }
.job-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.job-card h2 { margin: 0; font-size: 1.02rem; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; }
.job-client { font-weight: 600; margin: 0.3rem 0 0; color: var(--brand); }
.job-address { color: var(--ink-soft); margin: 0.15rem 0 0; font-size: 0.88rem; }
.job-meta { color: var(--ink-soft); font-size: 0.83rem; margin: 0.5rem 0 0; }
.job-progress-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.6rem 0 0.1rem; }
.job-percent { font-size: 0.8rem; color: var(--brand); font-weight: 600; white-space: nowrap; }

/* ---------- Finished jobs (the archive) ---------- */
.finished-jobs { margin-top: 1.75rem; }
.finished-jobs > summary {
  background: none;
  padding: 0.4rem 0;
  border-radius: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.finished-list { margin-top: 0.9rem; }
.job-card-finished { border-left-color: var(--sage); opacity: 0.82; }
.job-card-finished:hover { opacity: 1; }
.job-finish-form { margin-left: auto; }

/* ---------- Progress bars ---------- */
.progress { background: #dcd9c9; border-radius: 999px; height: 9px; overflow: hidden; width: 100%; }
.progress-fill { height: 100%; background: var(--leaf); border-radius: 999px; transition: width 0.25s ease; }
.progress-fill.is-complete { background: var(--brand); }
.job-progress-block { display: flex; align-items: center; gap: 0.7rem; margin: 0.6rem 0 1rem; }
.job-percent-big { font-weight: 600; white-space: nowrap; color: var(--brand); }
.day-progress-block { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem; }
.day-progress-block .muted { white-space: nowrap; }

/* ---------- Job detail ---------- */
.job-summary { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.job-facts { margin-bottom: 1rem; }
.job-facts p { margin: 0.15rem 0; }

.days { display: flex; flex-direction: column; gap: 0.85rem; }
.day-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.95rem;
}
.day-card.is-today { border-left-color: var(--leaf); background: #fdfcf6; }
.day-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.day-label { font-weight: 600; margin: 0; color: var(--brand); }
.day-sub { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0 0; }
.task-preview { list-style: none; padding: 0; margin: 0.7rem 0 0; display: flex; flex-direction: column; gap: 0.35rem; }
.task-preview li { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; flex-wrap: wrap; }
.task-preview .done { text-decoration: line-through; color: var(--ink-soft); }
.day-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.85rem; padding-top: 0.7rem; border-top: 1px dashed var(--border); }
.day-admin form { margin: 0; }
.day-admin-label { flex-basis: 100%; font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Day view ---------- */
.back-link { display: inline-flex; align-items: center; min-height: 40px; color: var(--ink-soft); text-decoration: none; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: 600; }
.day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.day-head h1 { margin: 0.1rem 0 0; font-size: 1.4rem; }
.day-head-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Instructions from the boss (cream panel + green heading, like the brand docs) */
.day-instructions { border-left: 4px solid var(--brand); background: #f3f0e2; margin-bottom: 1rem; }
.instructions-label { margin: 0 0 0.35rem; font-weight: 700; color: var(--brand); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.instructions-body { margin: 0; white-space: pre-wrap; }
.day-instructions.compact { margin: 0.6rem 0; padding: 0.7rem 0.85rem; }

.task-list { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1rem; }
.task-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem;
}
.task-main { display: flex; align-items: center; gap: 0.75rem; }
.status-form { margin: 0; }
.task-status-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
}
.task-status-btn.status-not_started { background: #eceadf; color: var(--ink-soft); border: 1px solid var(--border); }
.task-status-btn.status-in_progress { background: #f2ecd4; color: #6b5b1e; border: 1px solid #ded3a8; }
.task-status-btn.status-completed { background: var(--brand); color: #fff; }
.task-status-btn.small { width: 44px; height: 44px; font-size: 1.2rem; }
.task-name-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.task-name { font-size: 1.02rem; }
.task-name.done { text-decoration: line-through; color: var(--ink-soft); }
.task-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
/* An open chip panel takes its own full row, so it never shoves the chips
   beside it out of line (the "gap" Justine spotted). */
.task-tools details[open] { flex-basis: 100%; }

/* Quick edit mode */
.chip-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: #eceadf;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
}
.chip-link:hover { background: var(--leaf-soft); }
.rename-form { display: flex; flex: 1; gap: 0.45rem; align-items: center; min-width: 0; }
.rename-form input[type="text"] { flex: 1; min-width: 0; }
.icon-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { color: var(--danger); border-color: #e0c0bd; background: #fbeeed; }
.notes-form { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.block-details summary.is-blocked { background: #f6dedc; color: var(--danger); }
.add-task-form { margin-bottom: 1rem; }
.day-status-actions { display: flex; gap: 0.5rem; margin: 1rem 0; flex-wrap: wrap; }
.day-status-actions form { margin: 0; }
.day-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; gap: 0.5rem; }

/* ---------- Today dashboard ---------- */
.today-job { border-left: 4px solid var(--leaf); }
.today-job-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.55rem; flex-wrap: wrap; }
.today-job-name { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--brand); }
.today-day-sub { margin: 0.55rem 0; }
.today-tasks { list-style: none; padding: 0; margin: 0.6rem 0 1rem; display: flex; flex-direction: column; gap: 0.55rem; }
.today-task { display: flex; align-items: flex-start; gap: 0.6rem; }
.today-task-body { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; padding-top: 0.5rem; }
.up-next-head { margin: 1.9rem 0 0.7rem; font-size: 0.95rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.up-next-job { border-left: 4px solid var(--sage); }

/* ---------- Desktop refinements ---------- */
@media (min-width: 720px) {
  .topnav { display: flex; align-items: center; gap: 1.25rem; padding: 0.75rem 1.5rem; }
  .topnav-row { flex: 1; }
  .topnav-row .brand { order: 0; }
  .nav-links { margin-top: 0; order: 1; flex: 0 0 auto; }
  .nav-link { flex: 0 0 auto; min-height: 40px; padding: 0 1rem; background: none; }
  .nav-link:hover { background: rgba(255, 255, 255, 0.12); }
  .nav-user { max-width: none; }

  .page { padding: 1.75rem 1.5rem 4.5rem; }
  h1 { font-size: 1.9rem; }

  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-actions { grid-column: 1 / -1; }

  .job-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

  .table thead { display: table-header-group; }
  .table { display: table; }
  .table tbody { display: table-row-group; }
  .table tr { display: table-row; border: none; border-radius: 0; margin: 0; padding: 0; background: transparent; }
  .table td { display: table-cell; width: auto; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
  .table td::before { display: none; }
  .table th { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }

  .login { padding: 2.5rem 2.25rem; }
}

/* Wide screens (Lachie planning at the computer): day cards two across so a
   whole week fits on screen; the add-day button spans the full width. */
@media (min-width: 1000px) {
  .days { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 0.9rem; }
  .days > form { grid-column: 1 / -1; }
}
