/* ====================== BODY MEASUREMENTS ====================== */

.body-measurements-section {
  position: relative;
  margin: 10px 0 24px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.body-measurements-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 14px;
}



/* Плюс, аналогичный кнопке добавления веса */

.body-measurements-add {
  position: relative;
  min-width: 0;
}

.body-measurements-add > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  list-style: none;
}

.body-measurements-add > summary::-webkit-details-marker {
  display: none;
}

.body-measurements-add > summary i {
  position: relative;
  display: block;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--lime);
  border-radius: 50%;
}

.body-measurements-add > summary i::before,
.body-measurements-add > summary i::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: var(--lime);
  transform: translate(-50%, -50%);
}

.body-measurements-add > summary i::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.body-measurements-add[open] > summary i {
  transform: rotate(45deg);
}

/* Сетка показателей */

.body-measurements-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 8px;
  row-gap: 25px;
}

.body-measurement-tile {
  --ring-color: #e8e8e8;
  --ring-track: #282828;

  min-width: 0;
  text-align: center;
}

.body-measurement-tile.is-positive {
  --ring-color: var(--lime);
  --ring-track: #293710;
}

.body-measurement-tile.is-negative {
  --ring-color: var(--red);
  --ring-track: #3a1713;
}

.body-measurement-tile.is-neutral {
  --ring-color: #e8e8e8;
  --ring-track: #292929;
}

.body-measurement-tile.is-empty {
  --ring-color: #303030;
  --ring-track: #202020;
}

.body-measurement-ring {
  position: relative;
  width: min(27vw, 108px);
  max-width: 108px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;

  /*
   * Дуга с разрывом снизу, как на референсе:
   * активная часть, затем тёмный остаток и открытый промежуток.
   */
  background:
    radial-gradient(
      circle at center,
      #000 0,
      #000 66%,
      transparent 67%
    ),
    conic-gradient(
      from 135deg,
      transparent 0deg 52deg,
      var(--ring-color) 52deg 282deg,
      var(--ring-track) 282deg 360deg
    );

  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.04));
}

.body-measurement-tile.is-positive .body-measurement-ring {
  filter: drop-shadow(0 0 4px rgba(163, 255, 18, 0.12));
}

.body-measurement-tile.is-negative .body-measurement-ring {
  filter: drop-shadow(0 0 4px rgba(255, 76, 57, 0.12));
}

.body-measurement-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateY(-1px);
}

.body-measurement-value strong {
  display: block;
  max-width: 76%;
  overflow: hidden;
  color: #f4f4f4;
  font-size: clamp(25px, 7.5vw, 34px);
  line-height: 0.92;
  font-weight: 500;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.body-measurement-value small {
  display: block;
  margin-top: 7px;
  color: #a4a4a4;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.body-measurement-tile.is-empty .body-measurement-value strong {
  color: #5c5c5c;
}

.body-measurement-tile.is-empty .body-measurement-value small {
  color: #4c4c4c;
}

.body-measurement-delta {
  position: absolute;
  right: -3px;
  bottom: 5px;
  min-width: 30px;
  padding: 2px 2px;
  background: #000;
  font-size: 17px;
  line-height: 1;
  font-weight: 1000;
  letter-spacing: -0.04em;
  text-align: center;
}

.body-measurement-delta.is-positive {
  color: var(--lime);
}

.body-measurement-delta.is-negative {
  color: var(--red);
}

.body-measurement-delta.is-neutral {
  color: #d8d8d8;
}

.body-measurement-name {
  display: block;
  margin-top: 12px;
  overflow: hidden;
  color: #e6e6e6;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.body-measurements-last-entry {
  margin-top: 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  text-align: center;
}

/* Модальное окно записи */

.body-measurements-add[open]::before {
  content: "";
  position: fixed;
  z-index: 1199;
  inset: 0;
  background: var(--af-sheet-backdrop);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.body-measurements-modal {
  position: fixed;
  z-index: 1200;
  top: 50%;
  left: 50%;
  bottom: auto;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 38px 22px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--af-sheet-border);
  border-radius: 34px;
  background: var(--af-sheet-bg);
  -webkit-backdrop-filter: blur(28px) saturate(120%);
  backdrop-filter: blur(28px) saturate(120%);
  box-shadow: var(--af-sheet-shadow);
  transform: translate(-50%, -50%);
  scrollbar-width: none;
}

.body-measurements-modal::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 50%;
  width: 56px;
  height: 5px;
  border-radius: 999px;
  background: var(--af-sheet-handle);
  transform: translateX(-50%);
}

.body-measurements-modal::-webkit-scrollbar {
  display: none;
}

.body-measurements-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.body-measurements-modal-head span {
  display: block;
  margin-top: 30px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.body-measurements-modal-head b {
  display: block;
  color: #fff;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 1000;
  letter-spacing: -0.035em;
}

.body-measurements-modal-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.af-sheet-date {
  position: relative;
  display: flex;
  min-height: 72px;
  margin-bottom: 26px;
  padding: 11px 56px 10px 70px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid #303236;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
}

.af-sheet-date::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 10px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(55, 58, 64, 0.34);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239aa1ac' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 10h18'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  transform: translateY(-50%);
}

.af-sheet-date::after {
  content: "";
  position: absolute;
  top: 26px;
  right: 24px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #949ba6;
  border-bottom: 2px solid #949ba6;
  transform: rotate(45deg);
  pointer-events: none;
}

.af-sheet-date > span,
.body-measurement-field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.af-sheet-date .input {
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f6f6f7;
  font-size: 17px !important;
  font-weight: 500;
  color-scheme: dark;
}

.af-sheet-date .input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.body-measurement-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 28px;
  row-gap: 22px;
}

.body-measurement-field {
  min-width: 0;
}

.body-measurement-field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  width: calc((100% - 28px) / 2);
  justify-self: center;
}

.body-measurement-field > div {
  position: relative;
}

.body-measurement-field .input {
  height: 64px;
  min-height: 64px;
  margin: 0;
  padding: 0 48px 0 16px;
  border: 1px solid #303236;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.12);
  color: #f5f5f6;
  font-size: 24px !important;
  font-weight: 450;
}

.body-measurement-field small {
  position: absolute;
  top: 50%;
  right: 15px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 1000;
  pointer-events: none;
  transform: translateY(-50%);
}

.body-measurements-save {
  display: block;
  width: max-content;
  min-height: 44px;
  margin-top: 26px;
  margin-right: auto;
  margin-left: auto;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  color: var(--lime);
  font-size: 16px !important;
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 420px) {
  .body-measurements-grid {
    column-gap: 5px;
    row-gap: 22px;
  }

  .body-measurement-ring {
    width: min(27vw, 94px);
  }

  .body-measurement-value strong {
    font-size: 25px;
  }

  .body-measurement-name {
    margin-top: 10px;
    font-size: 11.5px;
  }

  .body-measurement-delta {
    right: -2px;
    bottom: 4px;
    font-size: 14px;
  }

  .body-measurements-modal {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    padding: 34px 14px 12px;
  }

  .body-measurements-modal-head {
    margin-bottom: 12px;
  }

  .body-measurements-modal-head b {
    font-size: 23px;
  }

  .body-measurements-modal-head span {
    margin-top: 6px;
  }

  .body-measurements-modal-actions {
    gap: 7px;
  }

  .body-measurement-form-grid {
    column-gap: 12px;
    row-gap: 9px;
  }

  .body-measurement-field:last-child:nth-child(odd) {
    width: calc((100% - 12px) / 2);
  }

  .body-measurement-field > span {
    margin-bottom: 5px;
  }

  .body-measurement-field .input {
    height: 50px;
    min-height: 50px;
    border-radius: 18px;
    font-size: 20px !important;
  }

  .body-measurements-modal > .af-sheet-date {
    min-height: 58px;
    margin-bottom: 12px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .body-measurements-save {
    min-height: 40px;
    margin-top: 8px;
    padding-top: 7px;
    padding-bottom: 7px;
  }
}

@media (min-width: 760px) {
  .body-measurements-header,
  .body-measurements-add,
  .body-measurements-add > summary {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .body-measurements-header {
    min-height: 48px;
  }

  .body-measurements-add {
    margin-left: auto;
  }

  .body-measurements-add > summary i {
    width: 42px;
    height: 42px;
  }
}
