/* ============================================================
   PBL × ODZEC Mileage Calculator — Windows 11 / Fluent rebuild
   Mica-style surfaces, Segoe UI Variable, depth shadows,
   NavigationView (left rail) + command bar + list-detail layout.
   Desktop-first.
   ============================================================ */

/* ---------- Fluent design tokens ---------- */
:root {
  /* Accent — emerald (matching brand) */
  --accent-default: #16a34a;
  --accent-secondary: #15803d;
  --accent-tertiary: #064e3b;
  --accent-on:        #ffffff;
  --accent-tint-10:   color-mix(in srgb, #16a34a 10%, transparent);
  --accent-tint-20:   color-mix(in srgb, #16a34a 20%, transparent);
  --accent-tint-30:   color-mix(in srgb, #16a34a 30%, transparent);

  /* Mica & layer-on-mica surfaces (light theme) */
  --bg-mica:           #f3f3f3;            /* base */
  --bg-mica-alt:       #ececec;
  --layer-1:           rgb(255 255 255 / 0.70);  /* card on Mica */
  --layer-1-solid:     #ffffff;
  --layer-2:           rgb(255 255 255 / 0.85);
  --layer-3:           #fbfbfb;
  --layer-control:     rgb(255 255 255 / 0.55);
  --layer-control-hover: rgb(255 255 255 / 0.85);

  /* Text */
  --text-primary:      #1b1b1b;
  --text-secondary:    #5b5b5b;
  --text-disabled:     #9d9d9d;
  --text-on-accent:    #ffffff;

  /* Borders / strokes */
  --stroke-surface:    rgb(0 0 0 / 0.0578);   /* subtle layer border */
  --stroke-divider:    rgb(0 0 0 / 0.0803);
  --stroke-control:    rgb(0 0 0 / 0.0578);
  --stroke-focus:      var(--accent-default);

  /* Elevation shadows */
  --shadow-card:       0 2px 4px rgb(0 0 0 / 0.04), 0 1px 2px rgb(0 0 0 / 0.06);
  --shadow-flyout:     0 8px 16px rgb(0 0 0 / 0.14), 0 0 1px rgb(0 0 0 / 0.12);
  --shadow-dialog:     0 16px 32px rgb(0 0 0 / 0.18), 0 0 1px rgb(0 0 0 / 0.14);

  /* Radius */
  --r-control: 4px;
  --r-card:    8px;
  --r-pill:    9999px;

  /* Motion */
  --ease-out:  cubic-bezier(0, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.55, 0.55, 0, 1);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI Variable Display', 'Segoe UI Variable', 'Segoe UI', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.42;
  color: var(--text-primary);
  background: var(--bg-mica);
  /* Subtle Mica-style gradient */
  background-image:
    radial-gradient(circle at 0% 0%, rgba(22,163,74,0.04), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(22,163,74,0.03), transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3, h4, h5 { font-weight: 600; margin: 0; }
button { font-family: inherit; }
[x-cloak] { display: none !important; }

/* ============================================================
   Title bar (Windows 11 style)
   ============================================================ */
.fluent-titlebar {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--layer-1-solid);
  border-bottom: 1px solid var(--stroke-surface);
  gap: 12px;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 50;
}
.fluent-titlebar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fluent-titlebar-spacer { flex: 1; }
.fluent-titlebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.fluent-titlebar-brand img { height: 20px; }
.fluent-titlebar-brand .odzec { font-weight: 700; letter-spacing: 0.06em; color: var(--text-primary); }

/* ============================================================
   App shell — left rail + content (NavigationView pattern)
   ============================================================ */
.fluent-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  min-height: calc(100vh - 48px - 30px); /* titlebar + status bar */
}
@media (max-width: 900px) {
  .fluent-shell { grid-template-columns: 1fr; }
  .fluent-nav { display: none; }
}

/* ----- Left rail ----- */
.fluent-nav {
  background: var(--layer-1-solid);
  border-right: 1px solid var(--stroke-surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.fluent-nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  padding: 12px 12px 4px;
}
.fluent-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-control);
  color: var(--text-primary);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: background-color 0.12s var(--ease-out);
  text-align: left;
  position: relative;
  width: 100%;
}
.fluent-nav-item:hover { background: rgb(0 0 0 / 0.04); }
.fluent-nav-item.is-active {
  background: var(--accent-tint-10);
  color: var(--text-primary);
  font-weight: 600;
}
.fluent-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-default);
}
.fluent-nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.is-active .fluent-nav-icon { color: var(--accent-default); }

/* ============================================================
   Content area
   ============================================================ */
.fluent-content {
  padding: 16px 20px 24px;
  overflow-y: auto;
  background: transparent;
}

/* ----- Empty state ----- */
.fluent-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
  color: var(--text-secondary);
}
.fluent-empty h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0; }
.fluent-empty p { margin: 0; max-width: 480px; }

/* ----- Cards ----- */
.fluent-card {
  background: var(--layer-1-solid);
  border: 1px solid var(--stroke-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ----- Page header (above content) ----- */
.fluent-page-header {
  margin-bottom: 16px;
}
.fluent-page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.fluent-page-header p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }

/* ============================================================
   Command bar
   ============================================================ */
.fluent-commandbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--layer-1-solid);
  border: 1px solid var(--stroke-surface);
  border-radius: var(--r-card);
  margin-bottom: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}
.fluent-commandbar-spacer { flex: 1; }
.fluent-commandbar-divider {
  width: 1px;
  height: 20px;
  background: var(--stroke-divider);
  margin: 0 6px;
}

/* ============================================================
   Buttons (Fluent style)
   ============================================================ */
.fluent-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-control);
  border: 1px solid var(--stroke-control);
  background: var(--layer-1-solid);
  color: var(--text-primary);
  font: 400 14px/1 inherit;
  cursor: pointer;
  transition: background-color 0.12s var(--ease-out), border-color 0.12s var(--ease-out);
  user-select: none;
}
.fluent-btn:hover { background: rgb(0 0 0 / 0.04); }
.fluent-btn:active { background: rgb(0 0 0 / 0.06); transform: translateY(0.5px); }
.fluent-btn[disabled] { color: var(--text-disabled); cursor: not-allowed; }

.fluent-btn--accent {
  background: var(--accent-default);
  color: var(--text-on-accent);
  border-color: transparent;
  font-weight: 600;
}
.fluent-btn--accent:hover { background: color-mix(in srgb, var(--accent-default) 90%, black); }
.fluent-btn--accent:active { background: color-mix(in srgb, var(--accent-default) 80%, black); }

.fluent-btn--subtle {
  background: transparent;
  border-color: transparent;
}
.fluent-btn--subtle:hover { background: rgb(0 0 0 / 0.05); }

.fluent-btn--small { height: 28px; padding: 0 10px; font-size: 13px; }

.fluent-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.12s var(--ease-out);
}
.fluent-icon-btn:hover { background: rgb(0 0 0 / 0.05); color: var(--text-primary); }

/* ============================================================
   Form controls
   ============================================================ */
.fluent-input {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-control);
  border: 1px solid var(--stroke-control);
  background: var(--layer-1-solid);
  font: 400 14px inherit;
  color: var(--text-primary);
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
.fluent-input:focus {
  outline: none;
  border-bottom-color: var(--accent-default);
  box-shadow: inset 0 -2px 0 0 var(--accent-default);
}
.fluent-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='%235b5b5b' d='M1 3l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
}

/* ============================================================
   Drop zone (upload area)
   ============================================================ */
.fluent-dropzone {
  position: relative;
  border: 1px dashed var(--accent-default);
  border-radius: var(--r-card);
  padding: 36px 24px;
  background: var(--accent-tint-10);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-out), transform 0.2s var(--ease-out);
}
.fluent-dropzone:hover {
  background: var(--accent-tint-20);
}
.fluent-dropzone.is-dragover {
  background: var(--accent-tint-30);
  transform: scale(1.005);
}
.fluent-dropzone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}
.fluent-dropzone-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  background: var(--accent-default);
  color: var(--text-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.fluent-dropzone-title { font-weight: 600; color: var(--text-primary); }
.fluent-dropzone-hint  { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.fluent-dropzone-files { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 8px; }
.fluent-dropzone-file {
  background: var(--layer-1-solid);
  border: 1px solid var(--stroke-control);
  border-radius: var(--r-control);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-primary);
}

/* ============================================================
   Trips list (Outlook-style rows)
   ============================================================ */
.fluent-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 1100px) {
  .fluent-grid { grid-template-columns: 1.4fr 1fr; }
}

.fluent-list {
  background: var(--layer-1-solid);
  border: 1px solid var(--stroke-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 660px;
}
.fluent-list-header {
  display: grid;
  grid-template-columns: 24px 110px 90px 16px 90px 1fr 28px;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--stroke-divider);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  align-items: center;
}
.fluent-list-header > :last-child { text-align: right; }
.fluent-list-scroll { overflow: auto; flex: 1; }

.trip-row {
  display: grid;
  grid-template-columns: 24px 110px 90px 16px 90px 1fr 28px;
  gap: 8px;
  align-items: center;
  padding: 6px 14px;
  border-bottom: 1px solid var(--stroke-divider);
  cursor: pointer;
  transition: background-color 0.1s var(--ease-out);
  background: transparent;
}
.trip-row:hover { background: rgb(0 0 0 / 0.025); }
.trip-row.is-selected {
  background: var(--accent-tint-10);
  box-shadow: inset 3px 0 0 0 var(--accent-default);
}
.trip-row.is-missing { background: rgb(245 158 11 / 0.06); }
.trip-row.is-missing:hover { background: rgb(245 158 11 / 0.10); }
.trip-row.is-missing.is-selected {
  background: var(--accent-tint-10);
  box-shadow: inset 3px 0 0 0 var(--accent-default);
}
.trip-row.htmx-swapping { opacity: 0.55; }

.trip-handle {
  color: var(--text-disabled);
  cursor: grab;
  opacity: 0;
  font-size: 12px;
  user-select: none;
  text-align: center;
}
.trip-row:hover .trip-handle { opacity: 1; }
.trip-cell-date input {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  border-radius: var(--r-control);
  font-size: 13px;
  width: 100%;
  color: var(--text-primary);
  cursor: pointer;
}
.trip-cell-date input::-webkit-calendar-picker-indicator { opacity: 0; display: none; }
.trip-cell-date input:focus {
  outline: none;
  background: var(--layer-1-solid);
  box-shadow: inset 0 -2px 0 0 var(--accent-default);
}
.trip-pc-input {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  border-radius: var(--r-control);
  font-family: 'Cascadia Code', 'Consolas', ui-monospace, monospace;
  font-size: 13px;
  width: 100%;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.3px;
  font-weight: 500;
}
.trip-pc-input:focus {
  outline: none;
  background: var(--layer-1-solid);
  box-shadow: inset 0 -2px 0 0 var(--accent-default);
}
.trip-arrow { color: var(--text-secondary); text-align: center; font-size: 13px; }

.trip-miles {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  position: relative;
}
.trip-miles-num { font-weight: 600; }
.trip-miles-unit { color: var(--text-secondary); font-size: 11px; margin-left: 2px; }
.trip-miles-dash { color: rgb(245 158 11); font-weight: 600; }

/* Spinner inline in miles cell */
.miles-spinner { display: none; align-items: center; justify-content: flex-end; gap: 4px; color: var(--accent-default); font-size: 12px; font-weight: 500; }
.miles-spinner.htmx-request,
.miles-spinner.force-show { display: inline-flex; }
.miles-spinner.htmx-request ~ .trip-miles-value,
.miles-spinner.force-show ~ .trip-miles-value { display: none; }

.recalc-btn {
  background: transparent;
  border: 1px solid rgb(245 158 11);
  color: rgb(180 83 9);
  padding: 2px 8px;
  border-radius: var(--r-control);
  font-size: 11px;
  cursor: pointer;
}
.recalc-btn:hover {
  background: rgb(245 158 11);
  color: white;
}

.trip-cell-notes { /* takes the wide column */
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-delete {
  opacity: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--r-control);
}
.trip-row:hover .trip-delete { opacity: 1; }
.trip-delete:hover { background: rgb(220 38 38 / 0.12); color: rgb(220 38 38); }

.fluent-list-footer {
  border-top: 1px solid var(--stroke-divider);
  padding: 8px 14px;
}

/* Info row */
.trip-info {
  grid-column: 1 / -1;
  padding: 4px 0 8px 132px;
  color: rgb(180 83 9);
  font-size: 12px;
  font-style: italic;
}

/* ============================================================
   Right pane: inspector (map + alternatives)
   ============================================================ */
.fluent-inspector {
  background: var(--layer-1-solid);
  border: 1px solid var(--stroke-surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 660px;
}
.fluent-inspector-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--layer-3);
}
.fluent-inspector-header h3 { font-size: 13px; font-weight: 600; margin: 0; }
.fluent-inspector-header p { font-size: 11px; color: var(--text-secondary); margin: 1px 0 0; }
.fluent-inspector-map { height: 320px; position: relative; }
.fluent-inspector-routes { padding: 10px 14px; overflow: auto; flex: 1; min-height: 0; }
.fluent-inspector-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 20px;
  height: 100%;
}

.route-pivot {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.route-alt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--stroke-control);
  border-radius: var(--r-control);
  background: var(--layer-1-solid);
  cursor: pointer;
  transition: background-color 0.12s var(--ease-out), border-color 0.12s var(--ease-out);
}
.route-alt:hover { background: rgb(0 0 0 / 0.025); border-color: var(--text-secondary); }
.route-alt.is-selected {
  border-color: var(--accent-default);
  background: var(--accent-tint-10);
}
.route-alt-radio {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-secondary);
  margin-top: 2px;
  position: relative;
}
.route-alt.is-selected .route-alt-radio { border-color: var(--accent-default); }
.route-alt.is-selected .route-alt-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent-default);
}
.route-alt-summary { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.route-alt-meta { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ============================================================
   Status bar (bottom)
   ============================================================ */
.fluent-statusbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  height: 30px;
  background: var(--layer-1-solid);
  border-top: 1px solid var(--stroke-surface);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 30;
}
.fluent-statusbar strong { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 600; }
.fluent-statusbar .divider { width: 1px; height: 14px; background: var(--stroke-divider); }
.fluent-statusbar a { color: var(--accent-default); text-decoration: none; }
.fluent-statusbar a:hover { text-decoration: underline; }
.fluent-statusbar .spacer { flex: 1; }

/* ============================================================
   Map markers (A/B + cylinders work with the existing JS)
   ============================================================ */
.map-marker-ab {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: white;
  font: 700 14px/1 'Segoe UI Variable', system-ui;
  border: 2px solid white;
  box-shadow: var(--shadow-flyout);
}
.map-marker-ab--a { background: var(--accent-default); }
.map-marker-ab--b { background: #dc2626; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 700px) {
  .fluent-titlebar-brand img { display: none; }
  .fluent-titlebar-title { font-size: 13px; }
  .fluent-list-header { display: none; }
  .trip-row { grid-template-columns: 90px 70px 16px 70px 1fr; padding: 8px 12px; gap: 6px; }
  .trip-handle, .trip-delete { display: none; }
  .trip-pc-input, .trip-cell-date input { font-size: 12px; }
  .fluent-inspector-map { height: 220px; }
}
