/* ============================================================
   GymTrack – Custom Styles
   ============================================================ */

:root {
  --gt-primary:   #2C4251;   /* dark navy/teal */
  --gt-accent:    #B6C649;   /* lime green     */
  --gt-danger:    #D16666;   /* muted red      */
  --gt-warn:      #B6C649;   /* reuse accent   */
  --gt-surface:   #F4F6F4;
  --gt-card-bg:   #fff;
  --gt-ink:       #1a2830;
  --gt-sidebar-w: 250px;

  /* Derived hovers */
  --gt-primary-dark:  #1e2f3a;
  --gt-primary-light: #e8edf0;
  --gt-accent-dark:   #99aa38;
  --gt-accent-light:  #f4f7d9;

  /* Accent as *text* — #B6C649 itself is only 1.9:1 on a white card, so the
     lime is reserved for fills and this darker tone carries labels and
     borders on light surfaces (5.0:1 on #fff, 4.6:1 on the page surface).
     Dark mode flips it back to the pure lime, which reads 7.6:1 there. */
  --gt-accent-text:   #69761F;
  /* Label on an accent fill — 8.0:1 against #B6C649. */
  --gt-on-accent:     #1a2830;

  /* Text tint of primary — lightened in dark mode for readability */
  --gt-primary-text:       #2C4251;
  --gt-primary-text-hover: #1e2f3a;

  /* Tinted tile backgrounds (stat boxes, icon chips) */
  --gt-tile-primary-bg: #f0eeff;
  --gt-tile-info-bg:    #e0f7fa;
  --gt-tile-warning-bg: #fff3e0;
  --gt-tile-danger-bg:  #fce4ec;
  --gt-tile-success-bg: #e8f5e9;

  /* Measurement site colours — single source of truth for the body map,
     the history chart and its legend. Mid-tone on purpose: each one is
     legible on the light card (#fff) and the dark card (#1c2c38), so they
     stay theme-invariant like every other chart series in the app. */
  --gt-series-arm:    #4C8DAE;   /* blue   */
  --gt-series-thighs: #8FA22E;   /* deep lime */
  --gt-series-chest:  #8E6FB8;   /* violet */
  --gt-series-waist:  #D16666;   /* red — same as --gt-danger */
}

/* ---------- Reset / Base ---------- */
body {
  background-color: var(--gt-surface);
  color: var(--gt-ink);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

a { color: var(--gt-primary-text); }
a:hover { color: var(--gt-primary-text-hover); }

/* ---------- Auth Page ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2C4251 0%, #3d5a6e 50%, #4a6b82 100%);
}

.auth-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 16px;
}

.auth-brand h3 {
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.auth-brand p { color: rgba(255,255,255,.75); }

.auth-brand-icon {
  color: var(--gt-accent);
  filter: drop-shadow(0 2px 6px rgba(182,198,73,.4));
}

.auth-card {
  border: none;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  border-top: 3px solid var(--gt-accent);
}

/* ---------- App Layout ---------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--gt-sidebar-w);
  background: var(--gt-primary);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--gt-accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gt-primary); font-size: 18px;
}
.sidebar-brand h6 { margin: 0; font-weight: 700; font-size: 1rem; color: #fff; }
.sidebar-brand small { color: rgba(255,255,255,.5); font-size: 11px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all .15s;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}

.sidebar-nav a.active {
  color: var(--gt-primary);
  background: var(--gt-accent);
  font-weight: 600;
  border-right: none;
}

.sidebar-nav a.active i { color: var(--gt-primary); }
.sidebar-nav a i { font-size: 1rem; width: 20px; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a {
  color: rgba(255,255,255,.55) !important;
}
.sidebar-footer a:hover { color: var(--gt-danger) !important; }

/* --- Main content --- */
.main-wrapper {
  margin-left: var(--gt-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --- Topbar --- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: 8px 24px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
}

/* min-width:0 lets the heading shrink so its title can ellipsize instead of
   growing the flex row past the bar and clipping against the action buttons. */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-heading { min-width: 0; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.topbar-title {
  font-weight: 600; font-size: 1.05rem; color: var(--gt-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-date  { font-size: .8rem; color: #9eacb4; white-space: nowrap; }
.topbar-date-short { display: none; }

.topbar-icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}

/* --- Page content --- */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gt-ink);
  margin: 0;
}
.page-header p { color: #6b8090; font-size: .875rem; margin: 4px 0 0; }

/* ---------- Cards ---------- */
.gt-card {
  background: var(--gt-card-bg);
  border-radius: 14px;
  border: none;
  box-shadow: 0 2px 10px rgba(44,66,81,.07);
  padding: 20px;
  height: auto;
}

/* Equal-height cards only when the card is the sole child of its column;
   stacked cards keep natural height so they don't overflow into the next row */
.gt-card:only-child { height: 100%; }

/* Fixed-height wrapper so responsive Chart.js canvases can't inflate the card */
.chart-box { position: relative; width: 100%; }

.gt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.gt-card-title {
  font-size: .875rem;
  font-weight: 600;
  color: #6b8090;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.gt-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gt-ink);
  line-height: 1;
}

.gt-stat-sub {
  font-size: .75rem;
  color: #9eacb4;
  margin-top: 4px;
}

/* ---------- Progress Bars ---------- */
.progress { border-radius: 6px; height: 8px; background: #edf0f2; }
.progress-bar { border-radius: 6px; }

/* ---------- Metric Badges ---------- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

/* ---------- Quick-Add Buttons ---------- */
.quick-add-btn {
  border: 2px solid var(--gt-accent-text);
  color: var(--gt-accent-text);
  background: transparent;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.quick-add-btn:hover {
  background: var(--gt-accent);
  border-color: var(--gt-accent);
  color: var(--gt-on-accent);
}

/* ---------- Tables ---------- */
.table { font-size: .875rem; }
/* Paired header labels: the full wording on desktop, a one-or-two letter
   abbreviation on phones, so wide macro tables fit without side-scrolling. */
.th-abbr { display: none; }
/* Repeated per-cell units (" cm") and phone-only hints, same idea. */
.mobile-only { display: none; }
/* Calorie sparkbar in the history table — a fixed 80px here forced the whole
   column wider than its content needed. */
.cal-bar { height: 4px; width: 80px; }
.table thead th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #9eacb4;
  border-bottom: 2px solid #edf0f2;
  font-weight: 600;
}

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-radius: 8px;
  border-color: #dce3e8;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--gt-primary);
  box-shadow: 0 0 0 3px rgba(44,66,81,.14);
}

/* ---------- Buttons ---------- */
/* Buttons carry the lime accent; the navy stays structural (sidebar, headings,
   focus rings on inputs). These go through Bootstrap 5.3's own button custom
   properties rather than plain background/color overrides, so :active,
   :disabled, .show and the btn-check states retheme with them instead of
   falling back to Bootstrap blue. */
.btn-primary {
  --bs-btn-bg:                    var(--gt-accent);
  --bs-btn-border-color:          var(--gt-accent);
  --bs-btn-color:                 var(--gt-on-accent);
  --bs-btn-hover-bg:              var(--gt-accent-dark);
  --bs-btn-hover-border-color:    var(--gt-accent-dark);
  --bs-btn-hover-color:           var(--gt-on-accent);
  --bs-btn-active-bg:             var(--gt-accent-dark);
  --bs-btn-active-border-color:   var(--gt-accent-dark);
  --bs-btn-active-color:          var(--gt-on-accent);
  --bs-btn-disabled-bg:           var(--gt-accent);
  --bs-btn-disabled-border-color: var(--gt-accent);
  --bs-btn-disabled-color:        var(--gt-on-accent);
  --bs-btn-focus-shadow-rgb:      182, 198, 73;
}
.btn-outline-primary {
  --bs-btn-color:                 var(--gt-accent-text);
  --bs-btn-border-color:          var(--gt-accent-text);
  --bs-btn-hover-bg:              var(--gt-accent);
  --bs-btn-hover-border-color:    var(--gt-accent);
  --bs-btn-hover-color:           var(--gt-on-accent);
  --bs-btn-active-bg:             var(--gt-accent);
  --bs-btn-active-border-color:   var(--gt-accent);
  --bs-btn-active-color:          var(--gt-on-accent);
  --bs-btn-disabled-color:        var(--gt-accent-text);
  --bs-btn-disabled-border-color: var(--gt-accent-text);
  --bs-btn-focus-shadow-rgb:      182, 198, 73;
}
/* Kept as an alias now that .btn-primary is the accent; it predates the
   retheme and is not used by any view. */
.btn-accent {
  background: var(--gt-accent);
  border-color: var(--gt-accent);
  color: var(--gt-on-accent);
  font-weight: 600;
}
.btn-accent:hover { background: var(--gt-accent-dark); color: var(--gt-on-accent); }

/* FullCalendar's toolbar buttons and Bootstrap's pagination pills are buttons
   too, and both default to Bootstrap blue — left alone they read as a bug next
   to the lime ones. */
.fc {
  --fc-button-bg-color:             var(--gt-accent);
  --fc-button-border-color:         var(--gt-accent);
  --fc-button-text-color:           var(--gt-on-accent);
  --fc-button-hover-bg-color:       var(--gt-accent-dark);
  --fc-button-hover-border-color:   var(--gt-accent-dark);
  --fc-button-active-bg-color:      var(--gt-accent-dark);
  --fc-button-active-border-color:  var(--gt-accent-dark);
}
.fc .fc-button:focus-visible { box-shadow: 0 0 0 3px rgba(182, 198, 73, .4); }

.pagination {
  --bs-pagination-color:            var(--gt-accent-text);
  --bs-pagination-hover-color:      var(--gt-on-accent);
  --bs-pagination-hover-bg:         var(--gt-accent-light);
  --bs-pagination-focus-color:      var(--gt-on-accent);
  --bs-pagination-focus-bg:         var(--gt-accent-light);
  --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(182, 198, 73, .3);
  --bs-pagination-active-bg:        var(--gt-accent);
  --bs-pagination-active-border-color: var(--gt-accent);
  --bs-pagination-active-color:     var(--gt-on-accent);
}

/* ---------- Dashboard KPI Icons ---------- */
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

/* ---------- Area Chips ---------- */
.area-chip {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
  background: var(--gt-primary-light); color: var(--gt-primary);
  cursor: pointer; user-select: none;
  border: 2px solid transparent;
  transition: all .15s;
}
.area-chip.selected {
  background: var(--gt-primary); color: #fff;
  border-color: var(--gt-primary);
}
.area-chip:hover { border-color: var(--gt-primary); }

/* ---------- Bootstrap overrides ---------- */
.text-primary   { color: var(--gt-primary-text) !important; }

/* Theme-aware tinted tiles */
.tile-primary { background: var(--gt-tile-primary-bg); }
.tile-info    { background: var(--gt-tile-info-bg); }
.tile-warning { background: var(--gt-tile-warning-bg); }
.tile-danger  { background: var(--gt-tile-danger-bg); }
.tile-success { background: var(--gt-tile-success-bg); }
.bg-primary     { background: var(--gt-primary) !important; color: #fff !important; }
.border-primary { border-color: var(--gt-primary) !important; }

.badge.bg-primary { background: var(--gt-primary) !important; color: #fff !important; }

/* Ensure readable text inside primary-colored containers */
.bg-primary a, .bg-primary span, .bg-primary small,
.bg-primary .text-primary { color: #fff !important; }

/* Accent utility */
.text-accent  { color: var(--gt-accent) !important; }
.bg-accent    { background: var(--gt-accent) !important; }

/* Danger */
.text-danger  { color: var(--gt-danger) !important; }
.btn-outline-danger { color: var(--gt-danger); border-color: var(--gt-danger); }
.btn-outline-danger:hover { background: var(--gt-danger); border-color: var(--gt-danger); color: #fff; }

/* ---------- Form submit loader ---------- */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: .85;
}
.btn-loading .btn-text  { visibility: hidden; }
.btn-loading .btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Full-page overlay loader (auth pages) */
.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(44,66,81,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.page-loader.show {
  opacity: 1;
  pointer-events: all;
}
.page-loader-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  min-width: 200px;
}
.page-loader-card .spinner-border {
  width: 2.5rem; height: 2.5rem;
  border-width: 3px;
  color: var(--gt-primary);
}
.page-loader-card p {
  margin: 12px 0 0;
  font-weight: 600;
  color: var(--gt-primary);
  font-size: .9rem;
}

/* ---------- Mobile ---------- */
.sidebar-toggle {
  display: none;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gt-ink);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 999px rgba(0,0,0,.35);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .sidebar-toggle { display: block; }
  .page-content { padding: 16px; }

  /* --- Topbar: reclaim horizontal room so the title isn't crushed --- */
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-left { gap: 8px; }
  .topbar-title { font-size: .95rem; }
  /* "Saturday, September 5 2026" wraps to two lines at this width and pushes
     the bar's content past its own height; "Sat, Sep 5" fits on one. */
  .topbar-date-full  { display: none; }
  .topbar-date-short { display: inline; }
  /* The username is recoverable from the dropdown, the avatar is the target. */
  .topbar-username { display: none; }
  .topbar-user-btn { padding-left: .5rem !important; padding-right: .5rem !important; }

  /* --- Touch targets: 44px is the minimum comfortable tap size ---
     General rules first: these share specificity with the per-component rules
     below, so source order is what decides the winner. */
  .btn-sm { min-height: 40px; }
  .quick-add-btn,
  .area-chip { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  .sidebar-nav a { padding-top: 12px; padding-bottom: 12px; }
  .sidebar-toggle,
  .topbar-icon-btn,
  .topbar-user-btn { min-width: 44px; min-height: 44px; }
  .dataTables_wrapper .pagination .page-link { min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center; }
  /* Row-level icon actions (delete/edit) sit inside dense tables */
  .table .btn-sm { min-width: 40px; min-height: 40px; }
  /* Data entry is the main mobile job — inputs get the full 44px */
  .form-control,
  .form-select { min-height: 44px; }
  .form-control-sm,
  .form-select-sm { min-height: 40px; }
  /* .bm-toolbar shrinks its buttons to .2rem padding for the desktop chart
     header; that lands at 26px, too small to hit reliably on a phone. */
  .bm-toolbar .btn { min-height: 40px; }
  .sidebar-footer a { padding-top: 12px; padding-bottom: 12px; }

  /* --- Tables: keep more columns on screen before scrolling kicks in --- */
  .table { font-size: .8rem; }
  /* Scoped so this tightens the default table without loosening .table-sm,
     whose Bootstrap padding is already tighter than the value below. */
  .table:not(.table-sm) > :not(caption) > * > * { padding: .4rem .35rem; }
  .table-sm > :not(caption) > * > *             { padding: .3rem .25rem; }
  /* Uppercase + .05em tracking + DataTables' sort arrow make these headers,
     not the cell values, the thing setting each column's width. */
  .table thead th { font-size: .7rem; letter-spacing: 0; }
  .th-full   { display: none; }
  .th-abbr   { display: inline; }
  .cell-unit { display: none; }
  .mobile-only { display: inline; }
  .cal-bar   { width: 44px; }

  /* --- FullCalendar: its toolbar is a single nowrap row by default, which
         overflows the viewport and side-scrolls the whole page. --- */
  .fc .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 1em;
  }
  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  .fc .fc-toolbar-title { font-size: 1.05rem; text-align: center; }
  .fc .fc-button { padding: .35em .65em; min-height: 40px; }
  .fc .fc-daygrid-day-number { font-size: .8rem; }
  .fc .fc-col-header-cell-cushion { font-size: .75rem; padding: 6px 2px; }
  .fc .fc-event-title { font-size: .7rem; }
}

/* Swipe affordance for horizontally scrollable tables: a soft edge shadow that
   rides the scroll container, so it fades out once you reach either end.
   `background-attachment: local` pins the white "cover" layers to the content
   and `scroll` pins the shadows to the frame — the classic pure-CSS pattern. */
.table-responsive {
  background:
    linear-gradient(to right, var(--gt-card-bg) 0%, rgba(255,255,255,0) 100%) 0 0 / 24px 100% no-repeat local,
    linear-gradient(to left,  var(--gt-card-bg) 0%, rgba(255,255,255,0) 100%) 100% 0 / 24px 100% no-repeat local,
    linear-gradient(to right, rgba(0,0,0,.10), rgba(0,0,0,0)) 0 0 / 10px 100% no-repeat scroll,
    linear-gradient(to left,  rgba(0,0,0,.10), rgba(0,0,0,0)) 100% 0 / 10px 100% no-repeat scroll;
}

/* ---------- Dark Mode ---------- */
[data-bs-theme="dark"] {
  --gt-surface: #141d24;
  /* The pure lime is legible on the dark card (7.6:1), so accent text goes
     back to it and the outline/quick-add buttons need no separate override. */
  --gt-accent-text: #B6C649;
  --gt-card-bg: #1c2c38;
  --gt-ink:     #d8e4ea;

  --gt-primary-text:       #8ab4d0;
  --gt-primary-text-hover: #aecfe4;

  --gt-tile-primary-bg: rgba(138,180,208,.12);
  --gt-tile-info-bg:    rgba(13,202,240,.12);
  --gt-tile-warning-bg: rgba(253,203,110,.13);
  --gt-tile-danger-bg:  rgba(225,112,85,.15);
  --gt-tile-success-bg: rgba(0,184,148,.13);
}
[data-bs-theme="dark"] .area-chip {
  background: rgba(138,180,208,.14);
  color: #aecfe4;
}
[data-bs-theme="dark"] .area-chip:hover { border-color: var(--gt-primary-text); }
[data-bs-theme="dark"] .area-chip.selected {
  background: #37576e;
  border-color: var(--gt-primary-text);
  color: #fff;
}

/* Muted supporting text needs a lighter tint on dark cards */
[data-bs-theme="dark"] .gt-card-title  { color: #8ba3b3; }
[data-bs-theme="dark"] .page-header p  { color: #8ba3b3; }

/* Light-locked borders and tracks */
[data-bs-theme="dark"] .table thead th { border-bottom-color: rgba(255,255,255,.12); }
[data-bs-theme="dark"] .progress       { background: rgba(255,255,255,.09); }
[data-bs-theme="dark"] .hover-bg:hover { background: rgba(255,255,255,.05); }

/* Form controls: app.css light borders/focus ring don't work on dark inputs */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { border-color: #3a4c5c; }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  border-color: var(--gt-primary-text);
  box-shadow: 0 0 0 3px rgba(138,180,208,.18);
}

/* Tom Select (food search) */
[data-bs-theme="dark"] .ts-control {
  background-color: var(--bs-body-bg);
  color: var(--gt-ink);
  border-color: #3a4c5c;
}
[data-bs-theme="dark"] .ts-control input { color: var(--gt-ink); }
[data-bs-theme="dark"] .ts-dropdown {
  background: #1f303d;
  color: var(--gt-ink);
  border-color: #3a4c5c;
}
[data-bs-theme="dark"] .ts-dropdown .option.active {
  background: #2a3f4f;
  color: #fff;
}

/* Flatpickr popup calendar */
[data-bs-theme="dark"] .flatpickr-calendar {
  background: #1f303d;
  box-shadow: 0 3px 13px rgba(0,0,0,.5);
}
[data-bs-theme="dark"] .flatpickr-calendar.arrowTop:after  { border-bottom-color: #1f303d; }
[data-bs-theme="dark"] .flatpickr-calendar.arrowBottom:after { border-top-color: #1f303d; }
[data-bs-theme="dark"] .flatpickr-day { color: var(--gt-ink); }
[data-bs-theme="dark"] .flatpickr-day.flatpickr-disabled,
[data-bs-theme="dark"] .flatpickr-day.prevMonthDay,
[data-bs-theme="dark"] .flatpickr-day.nextMonthDay { color: #5a6f7d; }
[data-bs-theme="dark"] .flatpickr-day:hover,
[data-bs-theme="dark"] .flatpickr-day:focus {
  background: #2a3f4f;
  border-color: #2a3f4f;
  color: #fff;
}
[data-bs-theme="dark"] .flatpickr-day.today { border-color: var(--gt-accent); }
[data-bs-theme="dark"] .flatpickr-day.selected {
  background: var(--gt-accent);
  border-color: var(--gt-accent);
  color: #1a2830;
}
[data-bs-theme="dark"] .flatpickr-months .flatpickr-month,
[data-bs-theme="dark"] .flatpickr-current-month input.cur-year,
[data-bs-theme="dark"] .flatpickr-monthDropdown-months,
[data-bs-theme="dark"] .flatpickr-weekday,
[data-bs-theme="dark"] .flatpickr-months .flatpickr-prev-month,
[data-bs-theme="dark"] .flatpickr-months .flatpickr-next-month {
  color: var(--gt-ink);
  fill: var(--gt-ink);
}
[data-bs-theme="dark"] .flatpickr-monthDropdown-months { background: #1f303d; }

/* SweetAlert2 confirm dialogs */
[data-bs-theme="dark"] .swal2-popup {
  background: #1f303d;
  color: var(--gt-ink);
}
[data-bs-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-html-container { color: var(--gt-ink); }

/* FullCalendar (training history) */
[data-bs-theme="dark"] .fc {
  --fc-border-color: rgba(255,255,255,.14);
  --fc-today-bg-color: rgba(182,198,73,.12);
  --fc-page-bg-color: transparent;
}
[data-bs-theme="dark"] .fc-event { border: 1px solid rgba(255,255,255,.25); }
[data-bs-theme="dark"] body { background: var(--gt-surface); }
[data-bs-theme="dark"] .sidebar { background: #0e171d; }
[data-bs-theme="dark"] .topbar,
[data-bs-theme="dark"] .gt-card {
  background: var(--gt-card-bg);
  border-color: #263544;
}
[data-bs-theme="dark"] .sidebar-nav a { color: rgba(255,255,255,.55); }
[data-bs-theme="dark"] .sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
[data-bs-theme="dark"] .sidebar-nav a.active { background: var(--gt-accent); color: var(--gt-primary); }

/* ============================================================
   Body Map (measurements) — interactive front-body diagram
   ============================================================ */

.body-map {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
}

/* Non-interactive filler (head, forearms, hands, shins, feet) */
.bm-base {
  fill: var(--gt-primary-light);
  stroke: rgba(44,66,81,.16);
  stroke-width: 1;
}

/* Clickable sites */
.bm-region { cursor: pointer; outline: none; }
.bm-region .bm-shape {
  stroke: rgba(44,66,81,.22);
  stroke-width: 1;
  opacity: .72;
  transition: opacity .18s ease, stroke-width .18s ease;
}
.bm-region[data-site="arm_cm"]    .bm-shape { fill: var(--gt-series-arm); }
.bm-region[data-site="thighs_cm"] .bm-shape { fill: var(--gt-series-thighs); }
.bm-region[data-site="chest_cm"]  .bm-shape { fill: var(--gt-series-chest); }
.bm-region[data-site="waist_cm"]  .bm-shape { fill: var(--gt-series-waist); }

.bm-region:hover .bm-shape { opacity: .92; }
.bm-region.is-active .bm-shape {
  opacity: 1;
  stroke: var(--gt-ink);
  stroke-width: 2;
}
.body-map.has-active .bm-region:not(.is-active) .bm-shape { opacity: .28; }

.bm-region:focus-visible .bm-shape {
  stroke: var(--gt-ink);
  stroke-width: 2;
  stroke-dasharray: 3 2;
}

/* Leader lines + value labels — never intercept clicks meant for a region */
.bm-annotations { pointer-events: none; }
.bm-lead { stroke: rgba(44,66,81,.35); stroke-width: 1; }
.bm-label {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  fill: var(--gt-ink);
  transition: font-size .15s ease;
}
.bm-label.is-active { font-size: 12.5px; }
.bm-label tspan.bm-label-name {
  font-size: 9.5px;
  font-weight: 500;
  fill: #6b8090;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- Legend / site list ---------- */
.bm-legend { display: flex; flex-direction: column; gap: 2px; }

.bm-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.bm-legend-item:hover { background: rgba(44,66,81,.05); }
.bm-legend-item.is-active {
  background: rgba(44,66,81,.06);
  border-color: rgba(44,66,81,.18);
}
.bm-legend-item.is-muted { opacity: .45; }

.bm-swatch {
  flex: 0 0 auto;
  width: 22px;
  height: 10px;
  border-radius: 3px;
  position: relative;
}
.bm-swatch::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: #fff;
  transform: translate(-50%, -50%);
}
/* Point-style glyph per series, so the lines stay separable without colour */
.bm-swatch.glyph-circle::after   { border-radius: 50%; }
.bm-swatch.glyph-rect::after     { border-radius: 1px; }
.bm-swatch.glyph-rectRot::after  { border-radius: 1px; transform: translate(-50%,-50%) rotate(45deg); }
.bm-swatch.glyph-triangle::after {
  background: none;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid #fff;
  width: 0; height: 0;
}

.bm-legend-name  { flex: 1 1 auto; font-size: .875rem; font-weight: 600; color: var(--gt-ink); }
.bm-legend-value { font-size: .875rem; font-weight: 600; color: var(--gt-ink); white-space: nowrap; }

.bm-delta {
  flex: 0 0 auto;
  min-width: 62px;
  text-align: right;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Direction is carried by the arrow icon, not by colour: a rising waist and a
   rising arm are not the same news, so the badge stays value-neutral. */
.bm-delta.up,
.bm-delta.down { color: var(--gt-ink); }
.bm-delta.flat { color: #9eacb4; }

/* ---------- Chart toolbar ---------- */
.bm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bm-toolbar .btn { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .55rem; --bs-btn-font-size: .75rem; }

/* Highlight the active site's column in the history table */
#measTable th.col-active,
#measTable td.col-active {
  background: rgba(44,66,81,.05);
  font-weight: 600;
}

/* Highlight the form field for the active site */
.form-control.is-site-active {
  border-color: var(--gt-primary);
  box-shadow: 0 0 0 .2rem rgba(44,66,81,.12);
}

/* ---------- Dark mode ---------- */
[data-bs-theme="dark"] .bm-base {
  fill: rgba(255,255,255,.08);
  stroke: rgba(255,255,255,.16);
}
[data-bs-theme="dark"] .bm-region .bm-shape { stroke: rgba(255,255,255,.22); }
[data-bs-theme="dark"] .bm-region.is-active .bm-shape,
[data-bs-theme="dark"] .bm-region:focus-visible .bm-shape { stroke: #d8e4ea; }
[data-bs-theme="dark"] .bm-lead { stroke: rgba(255,255,255,.3); }
[data-bs-theme="dark"] .bm-label tspan.bm-label-name { fill: #8ba3b3; }
[data-bs-theme="dark"] .bm-swatch::after { background: #1c2c38; }
[data-bs-theme="dark"] .bm-swatch.glyph-triangle::after { background: none; border-bottom-color: #1c2c38; }
[data-bs-theme="dark"] .bm-legend-item:hover { background: rgba(255,255,255,.06); }
[data-bs-theme="dark"] .bm-legend-item.is-active {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
}
[data-bs-theme="dark"] #measTable th.col-active,
[data-bs-theme="dark"] #measTable td.col-active { background: rgba(255,255,255,.06); }
[data-bs-theme="dark"] .form-control.is-site-active {
  border-color: var(--gt-primary-text);
  box-shadow: 0 0 0 .2rem rgba(138,180,208,.18);
}
