/**
 * hub-ui-v2.css — incremental UI refresh ("HUB, Simplified" audit, 2026-08).
 *
 * Contract:
 *   - theme.min.css is READ-ONLY. Every visual change of the refresh lives
 *     here, loaded AFTER the theme so plain specificity wins where needed.
 *   - This file is loaded on EVERY page. Rules are scoped:
 *       body.ui-v2 ...   → only for users with the v2 flag (isUiV2Enabled())
 *       (unscoped)       → site-wide bug fixes, safe for everyone
 *   - Rollback of everything = remove the <link> in head.php +
 *     templates/partials/head.php. Rollback of v2-only = flip the flag.
 *
 * Flag: core/helpers/feature_flags.php → isUiV2Enabled().
 * Turn on per browser with ?ui=v2 on any URL, off with ?ui=v1.
 */

/* ═══════════════════════════════════════════════════════════════════════
   1. Site-wide fixes (safe for everyone) — currently none.
   ═══════════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════════════
   2. UI v2 (flag-gated) — design tokens
   The refresh phases (collapsed filters, form shell, chip diet) build on
   these instead of hard-coding colors per page.
   ═══════════════════════════════════════════════════════════════════════ */
body.ui-v2 {
  /* surfaces */
  --hub-bg: #0f141c;
  --hub-surface: #161c26;
  --hub-surface-2: #1d2430;
  --hub-line: #28303d;
  /* text */
  --hub-ink: #e6ebf3;
  --hub-muted: #9aa5b6;
  /* single action accent (blue); semantic colors are NOT accents */
  --hub-accent: #3b76f0;
  --hub-ok: #2f9e63;      /* success / approved            */
  --hub-warn: #eeb268;    /* pending / in review           */
  --hub-danger: #e05252;  /* destructive                   */
  /* spacing rhythm (audit: 8/12/16/24/40) */
  --hub-gap-1: 8px;
  --hub-gap-2: 12px;
  --hub-gap-3: 16px;
  --hub-gap-4: 24px;
  --hub-gap-5: 40px;
}

/* Small fixed badge so testers always know they are in the v2 preview.
   Remove when the flag goes public. */
body.ui-v2::after {
  content: "UI v2 preview";
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 20000;
  padding: 3px 10px;
  border: 1px solid var(--hub-line);
  border-radius: 999px;
  background: var(--hub-surface);
  color: var(--hub-muted);
  font-size: 11px;
  letter-spacing: .04em;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════════
   3. Locations Manager (flag-gated; markup built by hub-ui-v2.js)
   ═══════════════════════════════════════════════════════════════════════ */

/* Bulk-bar buttons that only exist in v2 (Move to…, Edit…).
   The #id in the selector out-specifies the page's own
   .loc-bulk-action { display:inline-flex } rule, which loads later. */
#locBulkBar .locv2-only { display: none !important; }
body.ui-v2 #locBulkBar .locv2-only { display: inline-flex !important; }

/* Utility */
body.ui-v2 .locv2-hidden { display: none !important; }
/* a section whose only content (the community map) is hidden must not
   keep reserving its mt-4/mb margins */
body.ui-v2 .locv2-mapless { margin: 0 !important; padding: 0 !important; }

/* ── toolbar: search + Filters(n) + layout seg ── */
body.ui-v2 .locv2-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
body.ui-v2 .locv2-search {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--hub-surface);
  border: 1px solid var(--hub-line);
  border-radius: 8px;
  padding: 0 12px;
  min-height: 42px;
}
body.ui-v2 .locv2-search-icon { color: var(--hub-muted); font-size: 18px; }
body.ui-v2 .locv2-search input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: var(--hub-ink);
  min-height: 40px;
  width: 100%;
}
/* the search field's original slot inside the filter panel stays empty */
body.ui-v2 .locv2-search-origin { display: none !important; }

body.ui-v2 .locv2-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--hub-surface);
  border: 1px solid var(--hub-line);
  border-radius: 8px;
  color: var(--hub-ink);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
body.ui-v2 .locv2-btn:hover { border-color: var(--hub-muted); }
body.ui-v2 .locv2-btn.locv2-active { border-color: var(--hub-accent); color: #fff; }
body.ui-v2 .locv2-btn.locv2-active .locv2-chev { transform: rotate(180deg); }
body.ui-v2 .locv2-chev { transition: transform .15s ease; font-size: 16px; color: var(--hub-muted); }
body.ui-v2 .locv2-count {
  background: var(--hub-accent);
  color: #fff;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 18px;
  min-width: 18px;
  text-align: center;
  padding: 0 5px;
}

body.ui-v2 .locv2-seg {
  display: inline-flex;
  border: 1px solid var(--hub-line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 42px;
}
body.ui-v2 .locv2-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--hub-surface);
  color: var(--hub-muted);
  padding: 0 13px;
  font-size: 13.5px;
  cursor: pointer;
}
body.ui-v2 .locv2-seg-btn + .locv2-seg-btn { border-left: 1px solid var(--hub-line); }
body.ui-v2 .locv2-seg-btn.locv2-active { background: var(--hub-accent); color: #fff; }

/* ── the whole filter panel collapses behind the Filters button ── */
body.ui-v2 #dashboard-locations-filters:not(.locv2-open) { display: none; }
body.ui-v2 #dashboard-locations-filters.locv2-open {
  border: 1px solid var(--hub-line);
  border-radius: 10px;
  padding: 14px;
  background: var(--hub-surface);
  animation: locv2-drawer .15s ease-out;
}
@keyframes locv2-drawer {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.ui-v2 #dashboard-locations-filters.locv2-open { animation: none; }
}

/* ── folder strip ── */
body.ui-v2 .locv2-folders {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
body.ui-v2 .locv2-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hub-line);
  background: var(--hub-surface);
  color: var(--hub-muted);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
body.ui-v2 .locv2-chip:hover { border-color: var(--hub-muted); color: var(--hub-ink); }
body.ui-v2 .locv2-chip.locv2-active {
  border-color: var(--hub-accent);
  background: rgba(59, 118, 240, .12);
  color: #fff;
}
body.ui-v2 .locv2-chip-count {
  background: rgba(255, 255, 255, .08);
  border-radius: 999px;
  font-size: 11px;
  line-height: 17px;
  min-width: 17px;
  text-align: center;
  padding: 0 5px;
  color: var(--hub-muted);
}
body.ui-v2 .locv2-chip.locv2-active .locv2-chip-count { color: #cfe0ff; }
body.ui-v2 .locv2-chip-new { border-style: dashed; }
body.ui-v2 .locv2-chip-edit {
  border: none;
  background: transparent;
  color: var(--hub-muted);
  padding: 0 0 0 2px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
body.ui-v2 .locv2-chip-edit:hover { color: #fff; }

/* ── cards: one ⋯ menu instead of five icon buttons ── */
body.ui-v2 .locv2-native-actions > *:not(.locv2-kebab):not(.loc-item-select-grid) {
  display: none !important;
}
body.ui-v2 .locv2-kebab .locv2-kebab-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
body.ui-v2 .locv2-kebab .dropdown-menu {
  min-width: 220px;
  font-size: 14px;
}
/* the open menu is portaled to <body> (still under body.ui-v2) — keep it
   above everything and opt out of the theme's .show animation so it can
   never be caught mid-fade or have its transform overridden */
body.ui-v2 .locv2-kebab-portal {
  min-width: 220px;
  font-size: 14px;
  display: block;
  animation: none !important;
  transform: none !important;
  margin: 0;
}

/* chip diet: drop the continent badge, mute the country into plain text.
   #locList raises specificity above the page's own badge rules. */
body.ui-v2 #locList .loc-region-continent { display: none !important; }
body.ui-v2 #locList .loc-region-badge {
  background: transparent !important;
  color: var(--hub-muted) !important;
  font-weight: 500;
  padding-left: 0;
}

/* ── layout modes ── */
body.ui-v2.locv2-lay-map #locList,
body.ui-v2.locv2-lay-map #locPagination,
body.ui-v2.locv2-lay-map #locationsTabs,
body.ui-v2.locv2-lay-map .loc-view-switcher,
body.ui-v2.locv2-lay-map #locSortWrap,
body.ui-v2.locv2-lay-map #locBulkBar,
body.ui-v2.locv2-lay-map .locv2-folders,
body.ui-v2.locv2-lay-map #locEmptyMine,
body.ui-v2.locv2-lay-map #locEmptyFavs {
  display: none !important;
}
body.ui-v2.locv2-lay-map #user-locations-map { height: 72vh !important; }

/* ── modals (folder picker / bulk edit) ── */
body.ui-v2 .locv2-modal .modal-content {
  background: #14181f;
  border: 1px solid var(--hub-line);
}
body.ui-v2 .locv2-pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}
body.ui-v2 .locv2-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--hub-line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--hub-ink);
}
body.ui-v2 .locv2-pick:hover { border-color: var(--hub-muted); }
body.ui-v2 .locv2-pick input { margin: 0; }
body.ui-v2 .locv2-pick i { color: var(--hub-muted); }

body.ui-v2 .locv2-be-section {
  border: 1px solid var(--hub-line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
body.ui-v2 .locv2-be-head {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  margin: 0;
  color: var(--hub-ink);
  font-weight: 500;
}
body.ui-v2 .locv2-be-head small { color: var(--hub-muted); font-weight: 400; margin-left: auto; }
body.ui-v2 .locv2-be-body { margin-top: 10px; opacity: .45; pointer-events: none; }
body.ui-v2 .locv2-be-section.locv2-be-on .locv2-be-body { opacity: 1; pointer-events: auto; }
/* description preview on cards — v2 only, all view modes */
.locv2-desc { display: none; }
body.ui-v2 .locv2-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  color: #b9c3d2;              /* one step brighter than --hub-muted — the
                                  muted grey read as "almost impossible" */
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 68ch;
}
body.ui-v2 #locList.view-compact .locv2-desc { -webkit-line-clamp: 1; }
/* compact view hides the chips but their &nbsp; separators still rendered a
   ghost empty line between title and description — hide the whole row */
body.ui-v2 #locList.view-compact .loc-badges { display: none; }

body.ui-v2 .locv2-be-section.locv2-be-invalid { border-color: var(--hub-danger); }
body.ui-v2 .locv2-region-row { display: flex; gap: 8px; }
body.ui-v2 .locv2-region-row select { flex: 1; min-width: 0; }
@media (max-width: 480px) {
  body.ui-v2 .locv2-region-row { flex-direction: column; }
}
body.ui-v2 .locv2-checks { display: flex; flex-wrap: wrap; gap: 6px; }
body.ui-v2 .locv2-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hub-line);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
  color: var(--hub-ink);
}
body.ui-v2 .locv2-check:has(input:checked) {
  border-color: var(--hub-accent);
  background: rgba(59, 118, 240, .12);
}
body.ui-v2 .locv2-check input { margin: 0; }

/* mobile: toolbar wraps, seg goes full width */
@media (max-width: 640px) {
  body.ui-v2 .locv2-seg { width: 100%; }
  body.ui-v2 .locv2-seg-btn { flex: 1; justify-content: center; }
}


/* ═══════════════════════════════════════════════════════════════════════
   4. Public hub list pages + GPX Manager (flag-gated)
   ═══════════════════════════════════════════════════════════════════════ */

/* the shared filter panel collapses behind the toolbar's Filters button */
body.ui-v2 .hub-list-page .hub-list-filters:not(.locv2-open) { display: none; }
body.ui-v2 .gpx-toolbar-section:not(.locv2-open) { display: none; }

/* hub toolbars sit on the shared .locv2-toolbar styles; the relocated
   /gpx/ Map + Reset buttons keep their own loc-hero-btn look and just
   need vertical alignment */
body.ui-v2 .locv2-hub-toolbar .loc-hero-btn { min-height: 42px; }
body.ui-v2 .locv2-gpx-toolbar { margin-bottom: 16px; }

/* chip diet on the public locations cards: country + category say it
   all — the continent pill is redundant with the country */
body.ui-v2 .loc-card-meta-row .pill--success { display: none; }

/* ── Phase 3: location form shell (add/edit) ── */
body.ui-v2 .locv2-ftabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--hub-line);
  margin: 0 0 20px;
}
body.ui-v2 .locv2-ftab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--hub-muted);
  font-size: 14.5px;
  cursor: pointer;
}
body.ui-v2 .locv2-ftab:hover { color: var(--hub-ink); }
body.ui-v2 .locv2-ftab.locv2-active {
  color: #fff;
  border-bottom-color: var(--hub-accent);
}
body.ui-v2 .locv2-ftab i { font-size: 17px; }
body.ui-v2 .locv2-tab-hidden { display: none !important; }

body.ui-v2 .locv2-form-save {
  position: sticky;
  bottom: 10px;
  z-index: 500;
  background: #131923;
  border: 1px solid var(--hub-line);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .35);
}

body.ui-v2 .locv2-req-badge {
  display: inline-block;
  background: var(--hub-accent);
  color: #fff;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 2px;
}
body.ui-v2 .locv2-opt-tag {
  color: var(--hub-muted);
  font-style: italic;
  font-size: 12px;
  margin-left: 6px;
}

/* ── drawer re-grid ──
   The hubs' filter rows are Bootstrap columns sized around cells that
   v2 relocates (search, map) — leaving uneven widths and stranded
   buttons. Under the flag each row becomes equal flexible cells;
   the Reset cell pins to the row end at its natural width. */
body.ui-v2 .locv2-grid .row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
  margin-left: 0;
  margin-right: 0;
}
body.ui-v2 .locv2-grid .row > [class*="col-"] {
  flex: 1 1 190px;
  width: auto;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
body.ui-v2 .locv2-grid .row > [class*="col-"]:has(#resetFiltersBtn) {
  flex: 0 0 auto;
  margin-left: auto;
}
body.ui-v2 .locv2-grid .form-label { margin-bottom: 6px; }
