/* Copyright Rapid Surveys Pty Ltd. Task Helper — the Map's spanner + its icon rows. Namespace: .thtm-  (maptoolsmenu.js says how it works)
 * Closed: only the spanner. Open: ONE row of icons beside it (search first); Plans + Satellite | Street in a row at the bottom, by the round +.
 * A tool picked: every other tool button goes (.thtm-picked / .thtm-active). Icons only — a tool's name is its title / aria-label. */
.thtm-ctl.leaflet-bar { border:0; box-shadow:none; background:none; }
.leaflet-container.th-maptools .thtm-ctl > button.thtm-btn,
.thtm-ctl > button.thtm-btn { box-sizing:border-box; display:flex; align-items:center; justify-content:center; position:relative;
  width:44px !important; height:44px !important; padding:0; margin:0; border:2px solid #fff !important; border-radius:50% !important; background:var(--tools, #2e7d32) !important; color:#fff !important; cursor:pointer;
  box-shadow:0 2px 8px rgba(20,28,40,.35) !important; }   /* !important: beats the shared tool-square rules (maptools.css) */
.leaflet-container.th-maptools .thtm-ctl > button.thtm-btn:hover { background:var(--tools-hover, #276b2b) !important; }
.thtm-btn svg { width:24px; height:24px; }
.thtm-btn:focus-visible { outline:3px solid var(--accent, #9E8C5B); outline-offset:2px; }

/* ── the top row: spanner, then (open) the search box and the tools, left to right ── */
.leaflet-container.th-maptools.thtm-on .leaflet-top.leaflet-left { display:flex; flex-direction:row; flex-wrap:wrap; align-items:center; gap:4px; top:8px; left:8px; right:8px; }
.leaflet-container.th-maptools.thtm-on .leaflet-top.leaflet-left > .leaflet-control { margin:0 !important; float:none; clear:none; }
/* closed: every other control in the corners and the bottom row is put away */
.leaflet-container.thtm-on:not(.thtm-open) .leaflet-top > .leaflet-control:not(.thtm-ctl):not(.thf-lyr),   /* .thf-lyr: the request form's own Plans button while a spot is picked — it must always show */
.leaflet-container.thtm-on:not(.thtm-open) .thtm-bottom { display:none !important; }
/* a tool picked: all the others go; the picked one (and its panel) stays */
.leaflet-container.thtm-picked .thtm-tool:not(.thtm-active) { display:none !important; }
.leaflet-container.thtm-picked .thtm-bottom:not(:has(.thtm-active)) { display:none !important; }

/* the ONE ✕ Close every picked tool shares: same look, same place — the top right of the map. Only while a tool is picked; the row stops short of it. */
.leaflet-container .thtm-x { display:none; position:absolute; float:none; margin:0; z-index:1001; top:8px; right:calc(8px + var(--thtm-x-gap, 0px)); box-sizing:border-box; width:44px; height:44px; padding:0; margin:0; border:1px solid rgba(0,0,0,.25); border-radius:50%;
  background:var(--card, #fff); color:var(--ink, #1a2733); font:700 18px/1 sans-serif; cursor:pointer; box-shadow:0 2px 8px rgba(20,28,40,.35); align-items:center; justify-content:center; }
.thtm-x:hover { background:var(--hover, #eef1f4); }
.thtm-x:focus-visible { outline:3px solid var(--accent, #9E8C5B); outline-offset:2px; }
.leaflet-container.thtm-picked .thtm-x { display:flex; }
.leaflet-container.th-maptools.thtm-on.thtm-picked .leaflet-top.leaflet-left { right:60px; }
body.panel-open .thtm-x { right:calc(var(--pw, var(--pw-def, 420px)) + 8px); }
/* every tool's own Close / Done is replaced by that one ✕ on the Map (a tool's own save-style actions stay) */
body.thtm-mapview [data-thtm-close] { display:none !important; }

/* a small control that keeps ONE fixed place (traffic's sign size): the right edge, the middle of the screen — never moves when a panel opens, a tool is picked or the view changes */
.thtm-fixed { position:fixed; z-index:1100; right:12px; top:50%; transform:translateY(-50%); display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.thtm-fixed > .leaflet-control { margin:0 !important; float:none; clear:none; position:relative; }
body.panel-open .thtm-fixed { right:calc(var(--pw, var(--pw-def, 420px)) + 12px); }

/* the search box (the Tasks toolbar's own input, moved here on the Map) */
.thtm-search { flex:0 1 300px; min-width:0; }
.thtm-search input[type="search"] { box-sizing:border-box; display:block; width:100%; height:var(--mt-size, 36px); margin:0; padding:0 10px; border:var(--mt-border, 1px solid rgba(0,0,0,.25)); border-radius:var(--mt-radius, 8px);
  background:var(--card, #fff); color:var(--ink, #1a2733); font:400 15px/1 inherit; box-shadow:var(--mt-shadow, 0 1px 4px rgba(20,28,40,.25)); }
.thtm-search input[type="search"]:focus-visible { outline:2px solid var(--accent, #9E8C5B); outline-offset:1px; }

/* the bottom row: Plans + Satellite | Street — its own row, right-aligned, level with the round + and just left of it (a phone: ABOVE the bottom strip, which never changes) */
.thtm-bottom { position:fixed; z-index:1100; display:flex; flex-direction:row; align-items:center; gap:6px; right:calc(24px + 56px + 10px); bottom:24px; }
.thtm-bottom > .leaflet-control { margin:0 !important; float:none; position:relative; }
body.panel-open .thtm-bottom { right:calc(var(--pw, var(--pw-def, 420px)) + 24px + 56px + 10px); }
/* the bottom row's panel (Plans) opens UPWARD, never over the spanner row */
.leaflet-container.th-maptools .thtm-bottom .th-mt-panel { position:absolute; left:auto; right:0; top:auto; bottom:calc(100% + 8px); width:min(340px, calc(100vw - 24px)); max-height:calc(100vh - 220px); overflow:auto; box-sizing:border-box; }

/* the Map view: the Tasks toolbar's own bits are not shown (the search lives in the row; Filter is a tool; no sort / List / Board / Select / + New task) */
body.thtm-mapview #toolbar .tool-row > :not(#qInput):not(.filt-anchor) { display:none !important; }
body.thtm-mapview #toolbar .filt-anchor > #filtBtn { display:none; }
body.thtm-mapview #toolbar .tool-count { display:none; }
body.thtm-mapview #overviewSheet .sheet { position:relative; }
body.thtm-mapview #mapToolbarSlot { position:absolute; top:0; left:0; width:0; height:0; margin:0; padding:0; overflow:visible; }   /* no row of its own above the map: the map fills the view */
body.thtm-mapview #mapToolbarSlot #toolbar { margin:0; }
.thtm-filter button#mapFiltBtn[data-n]:not([data-n=""])::after { content:attr(data-n); position:absolute; top:-5px; right:-5px; min-width:16px; height:16px; border-radius:8px; background:var(--accent, #9E8C5B); color:#fff; font:700 10px/16px sans-serif; text-align:center; }
/* computer: the Filter popover opens under the row */
@media (min-width: 768px) {
  body.thtm-mapview .filt-pop { position:fixed; top:var(--thtm-below, 60px); left:var(--thtm-left, 8px); right:auto; width:min(640px, calc(100vw - 16px)); }
}

/* ── phone ── */
@media (max-width: 767px) {
  .th-maptools { --mt-size:44px; --mt-icon:20px; }   /* 44 px tap targets */
  /* the company row (project, cog, Company, call, bell, initial) shows on Tasks only; the Map is full screen under the notice strip */
  body.thtm-mapview #topbar { display:none !important; }
  body.thtm-mapview #overviewSheet.mapview { top:var(--thtm-notice-b, 0px); }
  /* the search is a magnifier-sized box until it is used; then it takes the row */
  .thtm-search { flex:0 0 44px; }
  .thtm-search input[type="search"] { padding:0; background:var(--card, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a2733' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6'/%3E%3Cpath d='m20 20-4.2-4.2'/%3E%3C/svg%3E") center / 22px no-repeat; color:transparent; caret-color:var(--ink, #1a2733); }
  .thtm-search input[type="search"]::placeholder { color:transparent; }
  .thtm-search input[type="search"]::-webkit-search-cancel-button { display:none; }
  .thtm-search:focus-within { flex:1 1 auto; }
  .thtm-search input[type="search"]:focus { padding:0 10px; background-image:none; color:var(--ink, #1a2733); }
  .thtm-search input[type="search"]:focus::placeholder { color:var(--muted, #6b7785); }
  /* bottom: the strip (Tasks · Map · More, the round +) is IDENTICAL on Tasks and on the Map — nothing here touches it. Plans + Satellite | Street
     are their own row just above the strip, on the round +'s row, left of it. */
  .thtm-bottom { right:calc(16px + env(safe-area-inset-right) + 56px + 8px); bottom:calc(76px + env(safe-area-inset-bottom)); gap:4px; }
  /* any tool's panel: under the row, full width, above the bar */
  .leaflet-container.th-maptools.thtm-open .th-mt .th-mt-panel,
  .leaflet-container.th-maptools .thtm-bottom .th-mt-panel { position:fixed; left:8px; right:8px; top:var(--thtm-below, 60px); bottom:auto; width:auto; max-height:calc(100dvh - var(--thtm-below, 60px) - 130px); }
  body.thtm-mapview .filt-backdrop { inset:var(--thtm-below, 60px) 0 0 0; }   /* the dim starts UNDER the spanner row: the spanner stays pressable while the Filter sheet is open */
  body.thtm-mapview.nb-on .filt-pop { bottom:calc(60px + env(safe-area-inset-bottom)); max-height:calc(80vh - 60px); }   /* the Filter sheet sits ABOVE the bottom bar (its Done was under it) */
  body.thtm-mapview:has(#filtPanel:not([hidden])) .nb-plusw,
  body.thtm-mapview:has(#filtPanel:not([hidden])) .thtm-bottom { display:none !important; }   /* the Filter sheet's Done is never under the + */
}

/* the "Map tools didn't load" note (maptoolsmenu.js missingNote): under the row, one calm line + a Reload button */
.leaflet-container .thtm-note { position:absolute; z-index:1000; float:none; left:8px; right:8px; top:var(--thtm-below, 60px); box-sizing:border-box; padding:8px 12px; border-radius:8px; background:var(--card, #fff); color:var(--ink, #1a2733);
  border:1px solid rgba(0,0,0,.25); box-shadow:0 2px 8px rgba(20,28,40,.25); font:600 14px/1.3 inherit; display:flex; flex-wrap:wrap; align-items:center; gap:4px 10px; }
.thtm-note-b { flex:0 0 auto; width:auto; min-width:96px; min-height:44px; padding:0 16px; border:0; border-radius:8px; background:var(--accent, #2f6df6); color:#fff; font:600 14px/1 inherit; cursor:pointer; }
.thtm-note-q { flex:1 0 100%; font:400 12px/1.3 inherit; color:var(--muted, #6b7785); }
