/* ============================================================
   HealthTracker Pro — shared styles (Bootstrap 5 companion)
   Mobile-first, dark by default (expects <html data-bs-theme="dark">)
   ============================================================ */

/* Root tokens (override-able per theme) */
:root {
  --ht-accent: #5b9cff;            /* primary accent */
  --ht-accent-2: #4ad295;          /* success-ish accent */
  --ht-amber: #f3b14b;             /* warning accent */
  --ht-danger: #ff6b6b;
  --ht-muted: rgba(0,0,0,.55);

  --ht-card-radius: 18px;
  --ht-chip-radius: 999px;
  --ht-shadow-sm: 0 2px 10px rgba(0,0,0,.06);
  --ht-shadow-md: 0 10px 30px rgba(0,0,0,.12);

  --ht-ring-size: 92px;
  --ht-ring-inner: 72px;

  --ht-feed-gap: 10px;
}

/* Dark theme refinements (Bootstrap sets colors; we add polish) */
html[data-bs-theme="dark"] {
  --ht-muted: rgba(255,255,255,.6);
  --bs-body-color: #e9eef5;
  --bs-body-bg: #0e1116;
  --bs-card-bg: #141922;
  --bs-secondary-bg: #0e1116;
  --bs-tertiary-bg: #0a0d12;
  --bs-border-color: rgba(255,255,255,.08);
  --bs-link-color: #9ec1ff;
}

html[data-bs-theme="light"] {
  --bs-body-bg: #f6f8fb;
}

/* ------------------------------------------------------------
   Layout helpers
   ------------------------------------------------------------ */
.container-narrow {
  max-width: 980px;
  margin-inline: auto;
}

.card {
  border: 1px solid var(--bs-border-color) !important;
  border-radius: var(--ht-card-radius) !important;
  box-shadow: var(--ht-shadow-sm);
}

.card-header {
  border-bottom-color: var(--bs-border-color) !important;
}

.sticky-top-shadow {
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
}

.sticky-bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 1030;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
}

/* Sidebar: collapses into offcanvas behavior via markup/JS */
.ht-sidebar {
  min-height: calc(100dvh - 56px);
  border-right: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}
@media (min-width: 992px) {
  .ht-sidebar {
    position: sticky;
    top: 56px;
  }
}

/* ------------------------------------------------------------
   Profile chips & avatars
   ------------------------------------------------------------ */
.ht-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .7rem;
  border-radius: var(--ht-chip-radius);
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  box-shadow: var(--ht-shadow-sm);
  font-weight: 600;
}
.ht-chip .emoji {
  font-size: 1.15rem;
  line-height: 1;
}

.ht-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  font-size: 1.2rem;
}
.ht-avatar.lg { width: 64px; height: 64px; font-size: 1.6rem; }

/* Netflix-like picker tiles */
.ht-profile-tile {
  border-radius: 14px;
  padding: 18px 14px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-card-bg);
  text-align: center;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .2s ease, border-color .2s;
  user-select: none;
}
.ht-profile-tile:hover { transform: translateY(-2px); box-shadow: var(--ht-shadow-md); }
.ht-profile-tile .name { font-weight: 700; margin-top: .6rem; }
.ht-profile-tile .sub { font-size: .8rem; color: var(--ht-muted); }

/* ------------------------------------------------------------
   Score ring & linear tiny bars
   ------------------------------------------------------------ */
.ht-ring {
  width: var(--ht-ring-size);
  height: var(--ht-ring-size);
  border-radius: 50%;
  background: conic-gradient(var(--ht-accent) 0%, rgba(0,0,0,.1) 0% 100%);
  display: grid; place-items: center;
}
html[data-bs-theme="dark"] .ht-ring {
  background: conic-gradient(var(--ht-accent) 0%, rgba(255,255,255,.08) 0% 100%);
}
.ht-ring-inner {
  width: var(--ht-ring-inner); height: var(--ht-ring-inner);
  border-radius: 50%;
  background: var(--bs-body-bg);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
}

.small-bar {
  width: 120px; height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
}
.small-bar > .progress-bar {
  height: 100%;
  border-radius: 999px;
}

/* ------------------------------------------------------------
   Feed items, reactions, comments
   ------------------------------------------------------------ */
.ht-feed-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: .8rem;
  padding: .75rem;
  border-radius: 12px;
  background: var(--bs-card-bg);
  border: 1px solid var(--bs-border-color);
}
.ht-feed-item + .ht-feed-item { margin-top: var(--ht-feed-gap); }

.ht-feed-meta {
  font-size: .8rem;
  color: var(--ht-muted);
}
.ht-react {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  cursor: pointer;
  transition: background .15s, transform .05s;
  line-height: 1;
}
.ht-react:active { transform: scale(.98); }
.ht-react.is-own { opacity: .7; }

/* Comment bubble */
.ht-comment {
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  padding: .55rem .7rem;
  background: var(--bs-secondary-bg);
}

/* ------------------------------------------------------------
   Tabs for profile (Goals / Meals / Workouts)
   ------------------------------------------------------------ */
.ht-tabs .nav-link {
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  color: var(--bs-body-color) !important;
  opacity: .8;
  font-weight: 600;
}
.ht-tabs .nav-link.active {
  border-color: var(--ht-accent) !important;
  opacity: 1;
}

/* List rows in cards */
.ht-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.ht-row:last-child { border-bottom: 0; }

/* ------------------------------------------------------------
   Confetti burst when all goals hit
   ------------------------------------------------------------ */
.ht-confetti {
  position: fixed; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,0,0,.7) 6px, transparent 7px),
    radial-gradient(circle, rgba(0,128,255,.7) 6px, transparent 7px),
    radial-gradient(circle, rgba(255,200,0,.7) 6px, transparent 7px),
    radial-gradient(circle, rgba(60,179,113,.7) 6px, transparent 7px);
  background-size: 24px 24px;
  animation: htConfetti 1.2s linear forwards;
  opacity: .9;
}
@keyframes htConfetti {
  from { transform: translateY(-100%); }
  to   { transform: translateY(100%); opacity: 0; }
}

/* ------------------------------------------------------------
   Buttons & utilities
   ------------------------------------------------------------ */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--bs-border-color);
}
.btn-ghost:hover {
  background: var(--bs-secondary-bg);
}

.btn-pill { border-radius: 999px; }

/* Accent borders for person color */
.ht-border-accent {
  border-left: 6px solid var(--ht-accent);
  padding-left: .6rem;
}

/* Micro badges */
.badge-dot {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700;
}
.badge-dot::before {
  content: ''; width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--ht-accent-2);
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-control, .form-select, .btn {
  border-radius: 12px !important;
}

.input-compact .form-control,
.input-compact .form-select {
  padding-top: .35rem; padding-bottom: .35rem;
}

/* ------------------------------------------------------------
   Mobile first tweaks
   ------------------------------------------------------------ */
@media (max-width: 575.98px) {
  .card { border-radius: 16px !important; }
  .ht-ring { --ht-ring-size: 82px; --ht-ring-inner: 64px; }
  .small-bar { width: 100px; }
  .ht-feed-item { padding: .65rem; border-radius: 10px; }
}

/* ------------------------------------------------------------
   Toasts / notifications
   ------------------------------------------------------------ */
#ht-toast {
  position: fixed;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 1080;
  min-width: 240px;
  border-radius: 12px;
  box-shadow: var(--ht-shadow-md);
}

/* ------------------------------------------------------------
   Accessibility
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--ht-accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   Helpers to show “read-only” states clearly
   ------------------------------------------------------------ */
.ht-readonly .ht-editable {
  pointer-events: none;
  opacity: .6;
}
