/* OBED Blood Manager — 모바일 퍼스트 */
:root {
  --bm-danger: #c82333;
  --bm-header-h: 52px;
  --bm-nav-h: 56px;
  /* 하단: 알림 링크 + 전폭 기록 + 홈/내정보 */
  --bm-bottom-hint: 28px;
  --bm-record-cta-h: 52px;
  --bm-safe-top: env(safe-area-inset-top, 0px);
  --bm-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-tap-highlight-color: transparent;
}

body.bm-app {
  min-height: 100dvh;
  background: #f6f7fb;
  padding-bottom: calc(
    var(--bm-record-cta-h) + var(--bm-nav-h) + var(--bm-bottom-hint) + var(--bm-safe-bottom) + 16px
  );
}

body.bm-app.has-app-header {
  padding-top: calc(var(--bm-safe-top) + var(--bm-header-h));
}

/* 네이티브 스타일 상단 앱 바 */
.bm-app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  padding-top: var(--bm-safe-top);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

/* 제목: 가운데 정렬. PDF: 헤더 박스 오른쪽 끝 고정(플로우 밖 → 제목 옆에 붙지 않음) */
.bm-app-header-inner {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  min-height: var(--bm-header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
}

.bm-app-header-inner--has-pdf .bm-app-header-title {
  padding-left: 3.25rem;
  padding-right: 3.25rem;
}

.bm-app-header-title {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
  color: #111418;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.bm-app-header-pdf {
  position: absolute;
  top: 50%;
  right: max(0.65rem, env(safe-area-inset-right, 0px));
  transform: translateY(-50%);
  z-index: 2;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  line-height: 1.2;
  white-space: nowrap;
}

.bm-dashboard {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  padding-top: 1rem;
}

body.bm-page-dashboard .bm-dashboard {
  padding-bottom: 0.75rem;
}

.bm-dashboard-greet {
  line-height: 1.4;
}

/* 체중: 투석 관리 핵심 — 상단 강조 카드 */
.bm-chart-hero {
  border-radius: 1.125rem;
  background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%);
  border: 1px solid rgba(13, 110, 253, 0.22);
  box-shadow:
    0 0.5rem 1.75rem rgba(13, 110, 253, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

.bm-chart-hero .card-body {
  min-height: 240px;
}

body.bm-auth {
  min-height: 100dvh;
  background: linear-gradient(180deg, #fff5f5 0%, #ffffff 40%);
}

.bm-auth-main {
  min-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 100%;
}

.bm-login-alert.bm-alert-pending {
  border: 1px solid rgba(255, 193, 7, 0.5);
  background: linear-gradient(135deg, #fffbeb 0%, #fff8e6 100%);
  color: #664d03;
  font-weight: 500;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(102, 77, 3, 0.08);
}

.bm-card {
  border-radius: 1rem;
}

.bm-main {
  max-width: 720px;
}

/* 코칭 카드: 상태별 색 (🟢🟡🔴) */
.bm-coach-summary-card {
  border-radius: 1rem;
  border-left: 4px solid transparent;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}

.bm-coach-level-ok {
  border-left-color: #198754;
  background: linear-gradient(90deg, rgba(25, 135, 84, 0.07) 0%, #fff 32%);
}

.bm-coach-level-warn {
  border-left-color: #ffc107;
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.12) 0%, #fff 32%);
}

.bm-coach-level-danger {
  border-left-color: #dc3545;
  background: linear-gradient(90deg, rgba(220, 53, 69, 0.09) 0%, #fff 32%);
}

.bm-coach-encourage {
  color: #146c43 !important;
  font-weight: 600;
}

.bm-coach-lines-tight {
  letter-spacing: -0.01em;
}

.bm-evening-note {
  border-radius: 1rem;
  color: #495057;
}

/* 💡 오늘 행동 (그래프 사이·상태 색과 동일) */
.bm-today-action-panel {
  border-radius: 1rem;
  border-left: 4px solid transparent;
}

.bm-today-action-line {
  letter-spacing: -0.02em;
}

.bm-today-action-panel.bm-coach-level-ok .bm-today-action-line {
  color: #146c43;
}

.bm-today-action-panel.bm-coach-level-warn .bm-today-action-line {
  color: #856404;
}

.bm-today-action-panel.bm-coach-level-danger .bm-today-action-line {
  color: #842029;
}

/* 저장 피드백 (0.5초) */
.bm-save-toast {
  position: fixed;
  top: 42%;
  left: 50%;
  z-index: 1080;
  transform: translate(-50%, -50%) scale(0.96);
  padding: 0.65rem 1.35rem;
  border-radius: 2rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: rgba(25, 135, 84, 0.94);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}

.bm-save-toast--show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.bm-hour-recommended:not(.btn-primary):not(.active) {
  border-color: #198754;
  color: #198754;
  font-weight: 600;
}

.bm-chart-card {
  border-radius: 1rem;
  overflow: hidden;
}

.bm-chart-card .card-body {
  position: relative;
  min-height: 200px;
}

.bm-chart-emphasis {
  border: 2px solid rgba(13, 110, 253, 0.35);
  box-shadow: 0 0.35rem 1rem rgba(13, 110, 253, 0.12);
}

/* 하단 네비게이션 (+ 버튼 위 알림 링크) */
.bm-bottom-nav-shell {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  padding-bottom: var(--bm-safe-bottom);
}

/* PWA: 홈 화면 추가 안내 줄 — 본문 하단 여백은 JS로 bm-has-pwa-snippet 클래스 부여 */
.bm-pwa-install-wrap {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: linear-gradient(180deg, rgba(220, 53, 69, 0.06) 0%, transparent 100%);
}

body.bm-app.bm-has-pwa-snippet {
  padding-bottom: calc(
    var(--bm-record-cta-h) + var(--bm-nav-h) + var(--bm-bottom-hint) + var(--bm-safe-bottom) + 16px + 5.5rem
  );
}

.bm-bottom-nav-hint {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--bm-bottom-hint);
  padding: 4px 10px 2px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.bm-record-cta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--bm-record-cta-h);
  margin: 0 0.65rem 0.4rem;
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  border-radius: 0.85rem;
  border: none;
  color: #fff !important;
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  box-shadow: 0 5px 16px rgba(192, 57, 43, 0.42);
  -webkit-tap-highlight-color: transparent;
}

.bm-record-cta:active {
  filter: brightness(0.95);
  transform: scale(0.99);
}

.bm-record-cta-plus {
  margin-right: 0.35rem;
  font-size: 1.1rem;
}

.bm-alert-settings-link {
  font-size: 0.72rem;
  font-weight: 500;
  color: #5c636a;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.bm-alert-settings-link:hover,
.bm-alert-settings-link:focus-visible {
  color: var(--bm-danger);
  text-decoration: underline;
}

/* 마이페이지 — 시간 알림 (모바일 터치) */
.bm-rs-time {
  min-height: 3rem;
  font-variant-numeric: tabular-nums;
}

.bm-rs-save {
  min-height: 2.75rem;
}

.bm-bottom-nav {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: auto;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: var(--bm-nav-h);
  padding-bottom: 0;
  background: transparent;
  backdrop-filter: none;
  border-top: none;
  box-shadow: none;
}

.bm-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #6c757d;
  font-size: 0.7rem;
  border: 0;
  background: transparent;
  padding: 8px 4px 10px;
  transition: color 0.15s ease;
}

.bm-nav-item.active {
  color: var(--bm-danger);
  font-weight: 600;
}

.bm-nav-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.bm-modal .modal-content {
  border-radius: 1rem;
}

.bm-record-form .form-label {
  font-size: 0.875rem;
}

.bm-memo-field {
  font-size: 0.9rem;
  resize: vertical;
  min-height: 3.25rem;
}

.bm-admin-page .bm-admin-list .list-group-item {
  border-color: rgba(0, 0, 0, 0.08);
}

.bm-admin-row {
  transition: opacity 0.38s ease, transform 0.38s ease;
  will-change: opacity, transform;
}

.bm-admin-row.bm-admin-row-exit {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

@media (min-width: 768px) {
  .bm-app-header {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 720px;
    transform: translateX(-50%);
    border-radius: 0 0 1rem 1rem;
    border-left: 1px solid rgba(0, 0, 0, 0.06);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
  }

  .bm-app-header-inner {
    border-radius: 0 0 1rem 1rem;
  }

  .bm-bottom-nav-shell {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 1rem 1rem 0 0;
  }
}

/* 개인 건강 보고서 (화면) */
body.bm-report-page {
  padding-bottom: 1.5rem;
}

.bm-report-main {
  max-width: 960px;
}

.bm-report-meta th {
  font-weight: 500;
}

.bm-report-table {
  font-size: 0.8rem;
}

.bm-report-cell-memo {
  white-space: normal;
  max-width: 12rem;
  word-break: break-word;
  vertical-align: top;
}

/* 인쇄 → PDF 저장 (브라우저 대화상자) */
@media print {
  .bm-no-print {
    display: none !important;
  }

  body.bm-report-page {
    padding: 0 !important;
    padding-bottom: 0 !important;
    background: #fff !important;
  }

  body.bm-report-page.has-app-header {
    padding-top: 0 !important;
  }

  .bm-app-header {
    display: none !important;
  }

  .bm-report-main {
    padding: 0 !important;
    max-width: none !important;
  }

  .bm-report-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .bm-report-table {
    font-size: 8.5pt;
    page-break-inside: auto;
  }

  .bm-report-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .bm-report-cell-memo {
    max-width: none !important;
  }
}

/* 기록 마법사 · 코치 패널 */
.bm-coach-modal .modal-body {
  padding-top: 0.5rem;
}

.bm-record-date-bar {
  border-color: rgba(13, 110, 253, 0.15) !important;
}

.bm-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.75rem;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.bm-bs-input-hero {
  font-size: 1.35rem !important;
  min-height: 3rem;
}

.bm-hour-btn {
  min-width: 2.75rem;
  font-variant-numeric: tabular-nums;
}

.bm-coach-emphasis {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.bm-btn-analyze {
  font-weight: 600;
}

/* 대시보드 코칭 */
.bm-header-coach-strip {
  background: rgba(255, 243, 205, 0.65);
  color: #664d03;
  border-color: rgba(0, 0, 0, 0.08) !important;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.bm-page-dashboard .bm-coach-summary-card {
  border: 1px solid rgba(13, 110, 253, 0.15) !important;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.bm-chart-foot {
  min-height: 2.75rem;
}

.bm-one-line-comment {
  font-size: 1rem;
}

.bm-one-line-comment::placeholder {
  color: rgba(33, 37, 41, 0.45);
  font-size: 0.9rem;
}
