/* MowRight Work Manager — page styles.
   Builds on /style.css design tokens (sage green, Inter, light surface). */

.wm-shell { max-width: 1280px; margin: 0 auto; padding: 24px 28px 80px; }
@media (max-width: 720px) { .wm-shell { padding: 16px 14px 60px; } }

/* ----- Section nav (sticky pill bar) ------------------------------------- */
.wm-subnav {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin: 0 0 22px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
}
.wm-subnav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
}
.wm-subnav a:hover { text-decoration: none; color: var(--ink); background: var(--bg); }
.wm-subnav a[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent-deep); font-weight: 600;
}

/* ----- Page header ------------------------------------------------------- */
.wm-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; margin-bottom: 22px; flex-wrap: wrap;
}
.wm-head h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -0.3px; }
.wm-head .sub { color: var(--muted); margin: 0; font-size: 14px; }
.wm-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ----- Layout for /work/ (today) ----------------------------------------- */
.wm-today-grid {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) { .wm-today-grid { grid-template-columns: 1fr; } }

.wm-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px;
}
.wm-panel h2 {
  font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 14px;
}

/* Day-plan summary card */
.wm-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  padding: 16px; border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  margin-bottom: 14px;
}
.wm-summary > div { text-align: center; }
.wm-summary .num { font-size: 22px; font-weight: 700; color: var(--accent-deep); font-family: 'JetBrains Mono', monospace; }
.wm-summary .lab { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-sub); margin-top: 2px; }

/* Job list (route stop cards) */
.wm-stops { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.wm-stop {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.wm-stop.is-complete { background: #f5f8f3; opacity: 0.85; }
.wm-stop-seq {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-deep); color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px;
}
.wm-stop-seq.fixed { background: var(--warning); }
.wm-stop-body .name { font-weight: 600; font-size: 15px; }
.wm-stop-body .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wm-stop-body .meta .sep { margin: 0 6px; opacity: 0.5; }
.wm-stop-time { text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink-sub); }
.wm-stop-time .arrive { font-weight: 700; font-size: 15px; color: var(--ink); }
.wm-stop-time .drive { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Map panel */
.wm-map-wrap {
  position: relative;
  height: 520px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.wm-map { width: 100%; height: 100%; }
.wm-map-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px;
  color: var(--muted); font-size: 14px;
}
.wm-map-empty strong { color: var(--ink); font-size: 16px; margin-bottom: 6px; }

/* Date picker + start-address controls (sits above panels) */
.wm-controls {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: end;
  background: var(--surface);
  padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px;
  margin-bottom: 18px;
}
.wm-controls .field { display: flex; flex-direction: column; gap: 4px; }
.wm-controls label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.wm-controls input, .wm-controls select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 14px; color: var(--ink); min-width: 160px;
}
.wm-controls input[type="date"] { min-width: 150px; }
.wm-controls input[type="text"] { min-width: 240px; flex: 1; }
.wm-controls .grow { flex: 1; }
.wm-controls .actions { display: flex; gap: 8px; }

/* ----- Tables (jobs list / customers list) ------------------------------ */
.wm-table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  font-size: 14px;
}
.wm-table th, .wm-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.wm-table th {
  background: var(--bg); font-weight: 600; font-size: 12px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.wm-table tr:last-child td { border-bottom: none; }
.wm-table tr:hover td { background: var(--accent-soft); }
.wm-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.wm-table .row-actions button {
  background: transparent; border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
  color: var(--ink-sub);
}
.wm-table .row-actions button:hover { background: var(--bg); color: var(--ink); }
.wm-table .row-actions button.danger { color: var(--error); border-color: #f0c8c8; }
.wm-table .row-actions button.danger:hover { background: #fde8e8; }

/* Status badges */
.wm-badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: capitalize;
}
.wm-badge--scheduled  { background: var(--accent-soft); color: var(--accent-deep); }
.wm-badge--in_progress { background: var(--cat-electric-bg); color: var(--cat-electric-fg); }
.wm-badge--complete   { background: #e0f3e0; color: #1f7a3a; }
.wm-badge--cancelled  { background: #eef0ec; color: #6b7280; }

/* ----- Forms (add job, customer) ---------------------------------------- */
.wm-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px;
}
.wm-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px;
}
.wm-form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .wm-form-grid { grid-template-columns: 1fr; } }

.wm-field { display: flex; flex-direction: column; gap: 5px; }
.wm-field label {
  font-size: 12px; font-weight: 600; color: var(--ink-sub); letter-spacing: 0.02em;
}
.wm-field label .req { color: var(--error); }
.wm-field input, .wm-field select, .wm-field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 14px; color: var(--ink);
}
.wm-field input:focus, .wm-field select:focus, .wm-field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.wm-field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.wm-field .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.wm-form-actions {
  display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end;
  border-top: 1px solid var(--border-soft); padding-top: 16px;
}

/* ----- Filters bar ------------------------------------------------------- */
.wm-filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 14px;
}
.wm-filters input, .wm-filters select {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 13px;
}
.wm-filters input[type="search"] { min-width: 220px; }

/* ----- Empty state ------------------------------------------------------ */
.wm-empty {
  text-align: center; padding: 56px 20px;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: 14px; color: var(--muted);
}
.wm-empty h3 { color: var(--ink); margin: 0 0 8px; font-size: 18px; }
.wm-empty p { margin: 0 auto 18px; max-width: 420px; line-height: 1.55; }

/* ----- Toast ------------------------------------------------------------- */
.wm-toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink); color: white;
  padding: 11px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.4);
  opacity: 0; transition: all 0.25s ease; z-index: 1000;
  max-width: 90vw;
}
.wm-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.wm-toast--ok { background: var(--accent-deep); }
.wm-toast--warn { background: var(--warning); }
.wm-toast--err { background: var(--error); }

/* ----- Leaflet overrides ------------------------------------------------ */
.leaflet-container { font: inherit; background: var(--bg); }
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 6px 24px -6px rgba(15, 31, 15, 0.25);
}
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content strong { color: var(--accent-deep); }
.wm-marker {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-deep); color: white;
  border: 3px solid white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px;
  box-shadow: 0 4px 10px -2px rgba(15,31,15,0.4);
}
.wm-marker--start { background: var(--accent); color: white; }
.wm-marker--end   { background: var(--warning); color: white; }
.wm-marker--fixed { background: var(--warning); }

/* ----- Address autocomplete --------------------------------------------- */
.wm-ac { position: relative; display: block; width: 100%; min-width: 0; }
.wm-ac > input { width: 100%; }
.wm-ac-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px -10px rgba(15, 31, 15, 0.25);
  max-height: 320px; overflow-y: auto;
  padding: 4px;
}
.wm-ac-item {
  padding: 9px 11px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.wm-ac-item:hover, .wm-ac-item.is-active {
  background: var(--accent-soft);
}
.wm-ac-item .wm-ac-main {
  color: var(--ink); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wm-ac-item .wm-ac-sub {
  color: var(--muted); font-size: 12px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ----- Written itinerary (below the map) -------------------------------- */
.wm-itinerary {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px;
  margin-top: 22px;
}
.wm-itinerary header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 14px;
}
.wm-itinerary h2 {
  margin: 0; font-size: 18px; letter-spacing: -0.2px;
}
.wm-itinerary .iti-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wm-iti-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 0;
}
.wm-iti-step {
  display: grid; grid-template-columns: 36px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.wm-iti-step:last-child { border-bottom: none; }
.wm-iti-marker {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-deep); color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px;
}
.wm-iti-marker.start { background: var(--accent); }
.wm-iti-marker.end   { background: var(--warning); }
.wm-iti-marker.fixed { background: var(--warning); }
.wm-iti-body .iti-time {
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  font-size: 15px; color: var(--ink); margin-right: 8px;
}
.wm-iti-body .iti-name { font-weight: 600; font-size: 15px; color: var(--ink); }
.wm-iti-body .iti-addr {
  color: var(--ink-sub); font-size: 14px; margin-top: 3px;
}
.wm-iti-body .iti-meta {
  color: var(--muted); font-size: 12px; margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.wm-iti-body .iti-meta .sep { margin: 0 6px; opacity: 0.5; }
.wm-iti-body .iti-notes {
  font-size: 13px; color: var(--ink-sub);
  margin-top: 6px; padding: 6px 10px;
  background: var(--bg); border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.wm-iti-leg {
  font-size: 12px; color: var(--muted);
  padding: 6px 0 6px 50px;
  font-family: 'JetBrains Mono', monospace;
  display: flex; align-items: center; gap: 6px;
}
.wm-iti-leg::before {
  content: '↓'; font-size: 14px; color: var(--accent);
}

/* ----- Inline note / fallback warning ----------------------------------- */
.wm-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-radius: 10px;
  background: var(--warning-soft); color: #7a3d00;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  font-size: 13px; line-height: 1.5; margin: 12px 0;
}
.wm-note--ok { background: var(--accent-soft); color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.wm-note strong { font-weight: 700; }

/* ----- Print: hide everything except the written itinerary -------------- */
@media print {
  body * { visibility: hidden; }
  .wm-itinerary, .wm-itinerary * { visibility: visible; }
  .wm-itinerary { position: absolute; left: 0; top: 0; width: 100%; border: none; padding: 0; margin: 0; }
  .wm-itinerary .iti-actions { display: none; }
  .wm-iti-marker { background: #333 !important; color: white !important; }
  .wm-iti-marker.start { background: #0f3d2e !important; }
  .wm-iti-marker.end { background: #d97706 !important; }
  a { color: inherit; text-decoration: none; }
}
