/*
  Relentless — Dark Theme Tokens and Shared UI
  Only layout/theme styles; no functional changes.
*/
:root {
  --bg: #0B0F14;
  /* page background */
  --panel: #0F172A;
  /* card/panel background */
  --line: #1F2937;
  /* subtle borders */
  --text: #F5F7FB;
  /* primary text */
  --muted: #9CA3AF;
  /* secondary text */
  --accent: #22C55E;
  /* brand accent */
  --ok: #A7F3D0;
  /* success/ok */
}

html,
body {
  overflow-x: hidden;
}

.bg {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, system-ui, sans-serif;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 14px 0;
}

.actions {
  align-items: center;
}

label {
  color: var(--muted);
  font-size: 12px;
}

input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0b0f14;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 14px;
  box-sizing: border-box;
}

.btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn[disabled] {
  opacity: .75;
  cursor: wait;
}

.muted {
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 12px;
}

.helper {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, .8);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
}

.nav a {
  color: var(--text);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  height: 100%;
  background: rgba(17, 24, 39, .9);
  backdrop-filter: blur(6px);
}

.topbar>.topbar-inner {
  width: 100%;

  flex: 1 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
}

.tb-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.tb-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.tb-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-right: 10px;
}

/* Mobile hamburger + drawer */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #1F2937;
  color: #E5E7EB;
  cursor: pointer;
}

@media (max-width: 900px) {
  .hamburger {
    display: inline-flex;
  }
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  width: 240px;
  background: #0F172A;
  border-right: 1px solid #1F2937;
  transform: translateX(-100%);
  transition: transform .2s ease;
  z-index: 1000;
  padding: 12px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive modal (used for confirmations) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .18s ease;
}
.modal-overlay.open { opacity: 1; }
.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}
.modal-title { font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.modal-body { color: var(--muted); line-height: 1.4; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
@media (max-width: 520px){
  .modal-card { max-width: 92vw; padding: 14px; border-radius: 12px; }
  .modal-title { font-size: 16px; }
  .modal-actions .btn { width: auto; padding: 10px 12px; }
}

.phase-btn,
.tier-btn {
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid #374151;
  background: #1F2937;
  color: #E5E7EB;
  font-size: 12px;
}

.phase-btn.active,
.tier-btn.active {
  background: #22C55E;
  color: #0B0F14;
  border-color: #16A34A;
}

/* Tablet adjustments: tighter buttons */
@media (max-width: 900px) {
  .tb-center {
    gap: 6px;
  }

  .phase-btn,
  .tier-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

/* Mobile: hide center controls and shrink gaps */
/* Mobile layout: stack navbar and center section */
/* Better card responsiveness on mobile */
@media (max-width: 600px) {
  .card {
    padding: 12px;
    border-radius: 14px;
    margin: 10px 0;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 10px;
    border-radius: 12px;
  }
}

@media (max-width: 600px) {
  .topbar-inner {
    flex-direction: column;
    /* stack vertically */
    align-items: flex-start;
    /* left-align content */
    gap: 6px;
    padding: 8px;
  }

  .tb-left {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* space between hamburger and logo */
  }

  .tb-center {
    display: flex;
    /* show middle section again */
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
  }

  .tb-right {
    display: none !important;
    /* hide user info and signout */
  }

  .hamburger {
    display: inline-flex;
  }
}

.brand {
  display: flex;
  align-items: center;
}

.brand img {
  height: 48px;
  /* default size for non-topbar contexts */
  width: auto;
  object-fit: contain;
  display: block;
  max-width: 360px;
}

/* Larger, readable logo in the sticky topbar across apps */
.topbar .brand img {
  height: 65px;
}

@media (max-width: 900px) {
  .topbar .brand img {
    height: 48px;
  }
}

@media (max-width: 600px) {
  .topbar .brand img {
    height: 42px;
  }
}


.wordmark {
  font-weight: 900;
  letter-spacing: 0.12em;
  font-size: 12px;
  line-height: 1;
  margin-bottom: 2px;
}

.brand>div {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Center text elements */
  text-align: center;
}

.tag {
  color: white;
  font-weight: 700;
  font-size: 6px;
  letter-spacing: 0.08em;
}

/* Utility: centered full-height layout (landing) */
.screen-center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text);
}

/* Utility: buttons row */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Utility: small code badge */
code.badge {
  background: var(--bg);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

@media (max-width: 700px) {
  .wrap {
    padding: 12px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  label {
    align-self: start;
  }

  .nav {
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .btn-row {
    flex-wrap: wrap;
  }

  input {
    padding: 6px 8px;
    font-size: 13px;
  }
}

/* Global responsive helpers */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

img,
video {
  max-width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  .shell {
    padding: 14px;
  }
}

@media (max-width: 600px) {
  .shell {
    padding: 12px;
  }

  .nav {
    position: sticky;
    top: 0;
  }
}

/* Phase 6 – Equipment UI */
.chip {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #374151;
  border-radius: 999px;
  background: transparent;
  color: #E5E7EB;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  line-height: 1.3;
}

/* Make chip-as-button clickable when used on goal modes */
.chip.goalModeBtn,
.goalModeBtn.chip {
  cursor: pointer;
  user-select: none;
}

.chip.goalModeBtn[aria-pressed="true"],
.goalModeBtn.chip[aria-pressed="true"] {
  background: #22C55E;
  color: #0B0F14;
  border-color: #16A34A;
}

.chip:hover {
  border-color: var(--accent);
}

/* Status chips with metrics - allow multi-line display */
#a_status,
#k_status,
#workoutTime,
#goalTierBadge,
#equipmentProfileName {
  white-space: normal;
  word-break: break-word;
  text-align: center;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Readiness/progress bar (reusable) */
.progress-rail {
  width: 100%;
  height: 8px;
  background: #374151;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #22C55E;
}

.equip-list {
  min-height: 40px;
}


/* Card emphasis variants */
.card.emphasis {
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

/* Width helpers used across pages */
.span6 {
  grid-column: span 6;
}

.span12 {
  grid-column: span 12;
}

/* Meraki-style dark UI skin (scoped; no functional changes) */
.meraki {
  background: #000;
  color: #D1D5DB;
}

.meraki .nav {
  background: rgba(17, 24, 39, .9);
  border-bottom: 1px solid #1F2937;
  color: #E5E7EB;
}

.meraki .nav a {
  color: #E5E7EB;
}

.meraki .wordmark {
  color: #FFFFFF;
}

.meraki .card {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.meraki .muted {
  color: #9CA3AF;
}

.meraki .btn {
  background: #22C55E;
  color: #0B0F14;
  border-radius: 12px;
  font-weight: 700;
}

.meraki .btn.ghost {
  background: #1F2937;
  color: #E5E7EB;
  border: 1px solid #374151;
}

/* Text/link button variant (no background, green text, underline on hover) */
.btn.link,
.meraki .btn.link {
  background: transparent !important;
  color: #22C55E !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.btn.link:hover,
.meraki .btn.link:hover {
  text-decoration: underline;
}

.meraki .pill {
  border-color: #374151;
  background: #0B0F14;
  color: #E5E7EB;
}

.meraki table {
  font-size: 14px;
}

.meraki th {
  color: #9CA3AF;
}

.meraki td {
  color: #D1D5DB;
}

/* Sidebar layout */
.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-right: 1px solid var(--line);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.side-item:hover {
  background: #1F2937;
  color: var(--text);
  border-color: #374151;
}

.side-item.active {
  background: #111827;
  color: #E5E7EB;
  border-color: #374151;
}

.side-section {
  margin: 6px 4px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}

/* ===========================================
   Themed Select Dropdown — Relentless Dark UI
   =========================================== */
select {
  width: 100%;
  padding: 8px 32px 8px 10px;
  /* space for arrow */
  border-radius: 8px;
  border: 1px solid var(--line);
  /* background: #ffffff; */
  background-color: #ffffff;
  /* matches .bg / input fields */
  color: #111827;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;

  /* remove native styles */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  /* custom dropdown arrow */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 12px center, right 6px center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

select:hover {
  border-color: #374151;
  /* slight highlight on hover */
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.25);
  /* subtle glow of accent color */
}

select option {
  background-color: #0F172A;
  /* dropdown list background */
  color: var(--text);
}

/* Compact variant for narrow viewports */
@media (max-width: 600px) {
  select {
    padding: 6px 28px 6px 8px;
    font-size: 13px;
  }
}

/* Markdown/Description styling (Plan preview)
   Matches JSX/screenshot spacing and typography*/
.markdown,
.desc {
  color: #D1D5DB;
  /* slightly dimmer body like the screenshot */
  font-size: 14px;
  line-height: 1.55;
  font-family: Inter, -apple-system, system-ui, Segoe UI, Roboto, sans-serif;
}

.markdown h1,
.markdown h2,
.markdown h3,
.desc h1,
.desc h2,
.desc h3 {
  margin: 10px 0 6px;
  line-height: 1.3;
  font-weight: 800;
}

.markdown h3,
.desc h3 {
  font-size: 16px;
  color: #E5E7EB;
}

.markdown p,
.desc p {
  margin: 8px 0;
}

.markdown ul,
.desc ul {
  margin: 6px 0 6px 1.25rem;
  padding-left: 1rem;
}

.markdown li,
.desc li {
  margin: 2px 0;
}

.markdown> :first-child,
.desc> :first-child {
  margin-top: 0 !important;
}

.markdown> :last-child,
.desc> :last-child {
  margin-bottom: 0 !important;
}

/* ===========================================
   Card header row + time badge styles
   =========================================== */
.time-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #E5E7EB;
  border: 1px solid #374151;
  background: #1F2937;
  padding: 6px 10px;
  border-radius: 999px;
}

/* Apply pill look to dashboard workout time id without editing HTML */
#workoutTime {
  color: #ffffff;
  border: 1px solid #374151;
  /* background: #1F2937; */
  padding: 6px 10px;
  border-radius: 999px;
}


/* Contain chips/badges in card headers - allow wrapping */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Changed from center to flex-start to allow wrapping */
  margin-bottom: 12px;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap; /* Allow items to wrap if needed */
}

.card-header h3 {
  flex-shrink: 0;
  min-width: 0;
  margin: 0;
}

.card-header .chip {
  max-width: calc(100% - 20px);
  flex-shrink: 1;
  /* Allow multi-line text in chips */
  white-space: normal;
  text-align: center;
}

/* ===========================================
   Buttons: primary CTA (matches screenshot)
   =========================================== */
.btn.btn-primary {
  padding: 14px 18px;
  font-size: 16px;
  border-radius: 14px;
  border: 2px solid black;
}

/* Link-looking action inside cards (e.g., Open tracker link style) */
.action-link {
  color: #34D399;
  font-weight: 700;
  text-decoration: none;
}

.action-link:hover {
  text-decoration: underline;
}

/* Top-row helper: keep three key cards in a single horizontal row.
   On narrow screens the row becomes horizontally scrollable to preserve single-row layout. */
.top-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  box-sizing: border-box;
  scroll-snap-type: x mandatory;
}

/* Make each child card flexible, equal-width, and ensure a sensible minimum size.
   Use column flex so inner elements flow top→bottom and content can stretch. */
.top-row>section,
.top-row>div.card {
  flex: 1 1 0;
  min-width: 280px;
  /* Increased from 240px */
  min-height: 260px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  scroll-snap-align: start;
}

@media (max-width: 600px) {
  .chip {
    font-size: 11px;
    padding: 4px 8px;
    max-width: 100%;
    line-height: 1.4;
  }
  
  /* Allow chips to take more space on mobile if needed */
  .card-header {
    align-items: flex-start;
  }
  
  .card-header .chip {
    max-width: 65%; /* Give chip more room on mobile */
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .chip {
    font-size: 10px;
    padding: 3px 7px;
    line-height: 1.4;
  }
  
  .card-header .chip {
    max-width: 60%;
    font-size: 9px;
    padding: 3px 6px;
  }
}

@media (max-width: 400px) {
  .card-header .chip {
    max-width: 55%;
    font-size: 9px;
  }
}

/* Responsive reductions for smaller viewports */
@media (max-width: 900px) {

  .top-row>section,
  .top-row>div.card {
    min-width: 260px;
    min-height: 240px;
  }
}

@media (max-width: 600px) {
  .top-row {
    gap: 12px;
  }

  .top-row>section,
  .top-row>div.card {
    min-width: 85vw;
    /* Make cards almost full-width for better mobile UX */
    min-height: auto;
    /* Allow height to be content-driven */
  }
}

@media (max-width: 480px) {
  .top-row {
    gap: 10px;
    padding: 0 4px 4px 4px;
  }

  .top-row>section,
  .top-row>div.card {
    min-width: 90vw;
  }
}

/* Responsive timer display */
@media (max-width: 600px) {
  #restTimer {
    font-size: 40px !important;
  }
}

@media (max-width: 480px) {
  #restTimer {
    font-size: 36px !important;
  }
}

/* Better button layouts on mobile */
@media (max-width: 600px) {
  .tracker-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .tracker-actions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 4px);
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 14px;
    font-size: 14px;
  }

  .btn.ghost {
    padding: 8px 12px;
  }
}

/* Responsive chips */
@media (max-width: 600px) {
  .chip {
    font-size: 11px;
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  .chip {
    font-size: 10px;
    padding: 3px 7px;
  }
}

.tracker-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  font-size: 14px;
}

@media (max-width: 600px) {
  .tracker-modes {
    gap: 8px;
    font-size: 13px;
  }

  .tracker-modes button {
    padding: 10px 8px !important;
  }
}

@media (max-width: 520px) {
  .tracker-modes {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 380px) {
  .tracker-modes {
    grid-template-columns: 1fr;
  }
}

/* Small visual smoothing for the horizontal container on dark backgrounds */
.top-row::-webkit-scrollbar {
  height: 8px;
}

.top-row::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.top-row::-webkit-scrollbar-track {
  background: transparent;
}
