/* Application Base Styles - Shared across the application */

/* ============================================
   CSS RESET & BASE STYLES
   ============================================ */

/* Box-sizing reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Basic reset */
* {
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}

html {
  -webkit-text-decoration-skip: ink;
  text-decoration-skip-ink: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  /* Baseline font sizing - responsive (single source of truth for HTML font sizing) */
  font-size: 1.368em; /* fallback: 1.14 * 1.2 */
  font-size: calc(1.14em + (0.2 * 1vw) + (0.2 * 1vh) + (0.1 * 1vmin));
  /* Clamp to reasonable bounds to prevent excessive scaling */
  font-size: clamp(1.14em, calc(1.14em + (0.2 * 1vw) + (0.2 * 1vh) + (0.1 * 1vmin)), 1.4em);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  height: 100%;
}

body {
  position: relative;
  font-size: 0.67rem;
  line-height: 1rem;
  font-weight: normal;
  font-family: "Albert Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  color: var(--gray-dark);
  background-color: var(--blue-lightest);
  overflow-x: hidden;
}

/* Ensure .visible class overrides any inline styles for FOUC prevention */
body.visible {
  visibility: visible !important;
}

/* Prevent body scroll when own results modal is open */
body.own-results-modal-open {
  overflow: hidden;
}

/* Prevent body scroll when mobile navigation menu is open */
body.mobile-navigation-open {
  overflow: hidden;
}

#root {
  height: 100%;
}

.react-root--app-loading:empty {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.react-root--app-loading:empty::before {
  content: "";
  display: block;
  width: 3rem;
  height: 3rem;
  background-image: var(--app-loading-logo-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  animation-name: app-loading-spin;
  animation-duration: 3000ms;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

.react-root--app-loading:empty::after {
  content: attr(data-loading-label);
  margin-top: 1rem;
  color: var(--gray-dark);
}

/* Blood test React home (/ and /orders/:id) only — see UserLayout @react */
.react-app-main {
  position: relative;
}

.blood-test-react-mount {
  position: relative;
  min-height: 16rem;
}

.blood-test-react-boot-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #e2ecf6;
  text-align: center;
}

.blood-test-react-mount:has(#root:empty) .blood-test-react-boot-overlay {
  display: flex;
}

.blood-test-react-boot-overlay__logo {
  display: block;
  width: 3rem;
  height: 3rem;
  animation-name: app-loading-spin;
  animation-duration: 3000ms;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

.blood-test-react-boot-overlay__label {
  margin-top: 1rem;
  color: var(--gray-dark, #39235d);
  font-weight: 500;
}

.loading-spinner {
  text-align: center;
}

.loading-spinner__logo {
  display: block;
  margin: 0 auto;
  width: 3rem;
  height: 3rem;
  animation-name: app-loading-spin;
  animation-duration: 3000ms;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

.loading-spinner__text {
  margin-top: 1rem;
  color: var(--gray-dark);
}

@keyframes app-loading-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Typography elements */
strong,
b {
  font-weight: bold;
}

em,
i {
  font-style: italic;
}

/* Links */
a {
  background-color: transparent;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* Buttons and forms */
button,
[type="button"],
[type="submit"],
[type="reset"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  white-space: normal;
}

::-webkit-input-placeholder,
::-moz-placeholder,
:-ms-input-placeholder,
::placeholder {
  opacity: 0.618;
  color: inherit;
}

:disabled {
  opacity: 0.618;
  cursor: not-allowed;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

input[type="search"] {
  -webkit-appearance: textfield;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

textarea {
  resize: vertical;
  display: block;
}

/* Touch action optimization */
a,
button,
input,
textarea,
select,
label,
canvas {
  -ms-touch-action: manipulation;
  touch-action: manipulation;
}

/* Keep dashboard tab buttons stable after history restore/back navigation. */
.dashboard-tab-button {
  -webkit-appearance: none;
  appearance: none;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
  box-shadow: none;
}

.dashboard-tab-button:focus,
.dashboard-tab-button:focus-visible {
  outline: none;
  box-shadow: none;
}

/* ============================================
   FONT FACE DECLARATIONS
   ============================================ */


/* ============================================
   CSS VARIABLES (DESIGN SYSTEM)
   ============================================ */

:root {
  /* Color Values - Design System */
  --purple-light: #67318e;
  --purple-base: #39235d;
  --blue-lightest: #f3f7fb;
  --blue-lighter: #e2ecf6;
  --blue-light: #8ab4db;
  --blue-base: #6e9fd5;
  --blue-dark: #3e7cb2;
  --gray-lightest: #e0e2e9;
  --gray-light: #a1a7bb;
  --gray-base: #626e8e;
  --gray-dark: #1c1f28;
  --dark: #646464;
  --orange: #fc8020;
  --green: #43c45f;
  --red: #ef686f;
  --yellow: #ffd44f;
  --white: #ffffff;
  --black: #000000;

  /* Animation easing */
  --animation-easing: cubic-bezier(0.236, 0, 0.236, 1);
  --animation-time: 200ms;
  --animation-short-time: 100ms;

  /* Typography */
  --font-family-sans: "Albert Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;

  /* Spacing */
  --side-padding: 0.5rem;
  --max-width: 1200px;
  --spacing: 0.2rem;
}

/* ============================================
   TYPOGRAPHY UTILITY CLASSES
   ============================================
   Typography utilities have been consolidated in phlex_utilities.css
   */

/* Body composition order select */

/* Show mobile actions row */
.order-select-container .body-composition-order-select__actions-mobile {
  display: block;
}

/* Hide desktop actions row */
.order-select-container .body-composition-order-select__actions-desktop {
  display: none;
}

/* Swap mobile/desktop action rows */
@media (min-width: 768px) {
  .order-select-container .body-composition-order-select__actions-mobile {
    display: none;
  }

  .order-select-container .body-composition-order-select__actions-desktop {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}

/* Section links row layout */
.order-select-container .body-composition-order-select__section-links,
.order-select-container .body-composition-order-select__secondary-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  margin: 0.4rem 0 0;
}

/* Mobile section links spacing */
.order-select-container .body-composition-order-select__actions-mobile .body-composition-order-select__section-links {
  margin-top: 0.8rem;
}

/* Center mobile secondary row */
.order-select-container .body-composition-order-select__secondary-row--mobile {
  justify-content: center;
}

/* Right-align desktop secondary row */
.order-select-container .body-composition-order-select__secondary-row--desktop {
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Inline print button form */
.order-select-container .body-composition-order-select__secondary-row form.button_to {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

/* Shared link and text button */
.order-select-container .body-composition-order-select__section-link,
.order-select-container .body-composition-order-select__text-button {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.4rem 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: rgb(45, 90, 138);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

/* Section jump link emphasis */
.order-select-container .body-composition-order-select__section-link {
  font-weight: 600;
  white-space: nowrap;
  text-align: left;
}

/* Full-width mobile section link */
.order-select-container .body-composition-order-select__section-link--mobile {
  justify-content: center;
  width: 100%;
  text-align: center;
}

/* Link hover state */
.order-select-container .body-composition-order-select__section-link:hover,
.order-select-container .body-composition-order-select__text-button:hover {
  color: rgb(110, 159, 213);
  text-decoration: underline;
}

/* Link focus ring */
.order-select-container .body-composition-order-select__section-link:focus,
.order-select-container .body-composition-order-select__text-button:focus {
  outline: 2px solid rgb(45, 90, 138);
  outline-offset: 2px;
}

/* Text button icon gap */
.order-select-container .body-composition-order-select__text-button {
  gap: 0.4rem;
  padding-right: 0.4rem;
}

/* Right-aligned text button */
.order-select-container .body-composition-order-select__text-button--align-right {
  text-align: right;
}

/* Text button icon size */
.order-select-container .body-composition-order-select__text-button img {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Print button wrapper */
.order-select-container .body-composition-order-select__print-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

/* InBody range sliders */

/* Fixed-height bar track row */
#inbody_results_list .range-slider__track,
.result-card .range-slider__track {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  height: 11px;
  min-height: 11px;
  max-height: 11px;
  flex: 0 0 auto;
}

/* Stack charts vertically */
.result-card .result-card__chart-area-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

/* Label space above bar */
#inbody_results_list .range-slider,
.result-card .range-slider {
  width: 100%;
  overflow: visible;
  padding-top: 1.75rem;
  margin-top: calc(var(--spacing) * 8);
}

/* Gap between two charts */
#inbody_results_list .range-slider + .range-slider,
.result-card .range-slider + .range-slider,
.result-card__chart-area-wrapper > div.pt-8 .range-slider {
  margin-top: calc(var(--spacing) * 16);
}

/* Two-chart cards: result text spacing */
.result-card__chart-area-wrapper:has(> div.pt-8) + .result-card__result-text-wrapper .result-text {
  margin-top: 0.5rem !important;
}

@media (min-width: 768px) {
  /* Gap between two charts on desktop */
  #inbody_results_list .range-slider + .range-slider,
  .result-card .range-slider + .range-slider,
  .result-card__chart-area-wrapper > div.pt-8 .range-slider {
    margin-top: calc(var(--spacing) * 10);
  }

  /* Clear second chart on desktop */
  .result-card__chart-area-wrapper:has(> div.pt-8) + .result-card__result-text-wrapper .result-text {
    margin-top: 1.5rem !important;
  }
}

/* Colored zone bar height */
#inbody_results_list .range-slider__bar,
.result-card .range-slider__bar {
  position: relative;
  height: 11px;
  min-height: 11px;
  border-radius: 0.75rem;
}

/* Min/max labels under bar */
#inbody_results_list .range-slider__bar > p,
.result-card .range-slider__bar > p {
  position: absolute;
  top: calc(var(--spacing) * 4);
  margin: 0;
  font-size: 0.67rem;
  line-height: 1rem;
}

/* Midpoint tick position */
#inbody_results_list .range-slider .range-slider__green-midpoint-marker,
.result-card .range-slider .range-slider__green-midpoint-marker {
  position: absolute;
}

/* Value marker anchor */
#inbody_results_list .range-slider .marker-wrapper,
.result-card .range-slider .marker-wrapper {
  position: absolute;
  display: block;
  visibility: visible;
  overflow: visible;
  z-index: 10;
}

/* Black current value line */
#inbody_results_list .range-slider .marker-wrapper__line--current,
.result-card .range-slider .marker-wrapper__line--current {
  position: absolute;
  width: 4px;
  height: 24px;
  border-radius: 0;
  background-color: #000000;
}

/* Gray previous value line */
#inbody_results_list .range-slider .marker-wrapper__line--previous,
.result-card .range-slider .marker-wrapper__line--previous {
  position: absolute;
  width: 4px;
  height: 21px;
  border-radius: 2px;
  background-color: #646464;
  opacity: 0.85;
}

/* Screen marker line nudge */
@media screen {
  #inbody_results_list .range-slider .marker-wrapper__line--current,
  .result-card .range-slider .marker-wrapper__line--current,
  #inbody_results_list .range-slider .marker-wrapper__line--previous,
  .result-card .range-slider .marker-wrapper__line--previous {
    top: -2px;
  }

  /* Screen current label nudge */
  #inbody_results_list .range-slider .marker-label--screen.marker-label--current,
  .result-card .range-slider .marker-label--screen.marker-label--current {
    margin-top: -1px;
  }
}

/* Previous marker inner position */
#inbody_results_list .range-slider .range-slider__marker--previous > div,
#inbody_results_list .range-slider .range-slider__marker--secondary-previous > div,
.result-card .range-slider .range-slider__marker--previous > div,
.result-card .range-slider .range-slider__marker--secondary-previous > div {
  position: absolute;
}

/* Floating value label */
#inbody_results_list .range-slider .marker-label,
.result-card .range-slider .marker-label {
  position: absolute;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: visible;
  z-index: 10;
  font-size: 0.67rem;
  line-height: 1rem;
}

/* Show screen labels */
#inbody_results_list .range-slider .marker-label--screen,
.result-card .range-slider .marker-label--screen {
  display: flex;
  visibility: visible;
  opacity: 1;
}

/* Hide print labels on screen */
#inbody_results_list .range-slider .marker-label--print,
.result-card .range-slider .marker-label--print {
  display: none;
  visibility: hidden;
  opacity: 0;
}

/* Bold previous value text */
#inbody_results_list .range-slider .marker-label__value--previous,
.result-card .range-slider .marker-label__value--previous {
  font-weight: 700;
}

/* Semibold current value text */
#inbody_results_list .range-slider .range-slider__marker--current .marker-label,
.result-card .range-slider .range-slider__marker--current .marker-label,
#inbody_results_list .range-slider .range-slider__marker--secondary-current .marker-label,
.result-card .range-slider .range-slider__marker--secondary-current .marker-label {
  font-weight: 600;
}

/* Smaller previous value label */
#inbody_results_list .range-slider .range-slider__marker--previous .marker-label,
.result-card .range-slider .range-slider__marker--previous .marker-label,
#inbody_results_list .range-slider .range-slider__marker--secondary-previous .marker-label,
.result-card .range-slider .range-slider__marker--secondary-previous .marker-label {
  font-size: 0.57rem;
  line-height: 0.75rem;
  padding: calc(var(--spacing) * 0.5) calc(var(--spacing) * 1);
}

/* Hide screen labels in print */
@media print {
  #inbody_results_list .range-slider .marker-label--screen,
  .result-card .range-slider .marker-label--screen {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }

  /* Show print labels */
  #inbody_results_list .range-slider .marker-label--print,
  .result-card .range-slider .marker-label--print {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* Historical line chart box */
.result-card .result-chart-container {
  position: relative;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
  height: 400px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Chart controller fills box */
.result-card .result-chart-container > [data-controller*="result-chart"] {
  width: 100%;
  height: 100%;
  margin-bottom: calc(var(--spacing) * 12);
}
