/* Shared chrome for every /app/ screen — responsive replacement for the old fixed-size phone mock-ups. */

body.app-body {
  background: #E9EEF6;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-bg);
  position: relative;
}

@media (min-width: 560px) {
  .app-shell {
    min-height: calc(100vh - 48px);
    margin: 24px auto;
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }
}

.app-content {
  flex: 1 0 auto;
  padding: 20px 20px 32px;
  width: 100%;
}
/* แถบเมนูล่างเป็น sticky มันจึงลอยทับเนื้อหาท้ายหน้าเมื่อหน้ายาวกว่าจอ
   หน้าไหนมีแถบล่างให้เว้นที่ไว้เท่าความสูงแถบ + safe area ของ iPhone */
.app-shell:has(.app-bottomnav) .app-content {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.app-content--centered {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Top bar (back + title) */
.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.app-topbar__back {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.app-topbar__title {
  font-size: var(--fs-lead);
  font-weight: 700;
}
.app-topbar__spacer { flex: 1; }

/* Bottom nav */
.app-bottomnav {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--color-white);
  padding: 12px 6px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.app-bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-note);
  font-weight: 600;
  color: var(--color-text-faint);
}
.app-bottomnav a.active { color: var(--color-primary-dark); }

/* Cards & sections */
.app-card {
  background: var(--color-white);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.app-section-title {
  font-size: var(--fs-body);
  font-weight: 700;
  margin: 24px 0 12px;
}
.app-section-title:first-child { margin-top: 0; }

/* Forms */
.app-field { margin-bottom: 16px; }
.app-field label {
  display: block;
  font-size: var(--fs-note);
  font-weight: 700;
  margin-bottom: 8px;
}
.hint,
.app-field .hint {
  font-size: var(--fs-note);
  color: var(--color-text-muted);
  margin-top: 6px;
}
.app-input,
.app-select {
  width: 100%;
  background: var(--color-primary-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-input);
  padding: 13px 14px;
  font-size: var(--fs-body);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.app-input:focus, .app-select:focus { border-color: var(--color-primary); }
.app-input.error { border-color: var(--color-danger); background: var(--color-danger-light); }
.app-error-text {
  color: var(--color-danger);
  font-size: var(--fs-note);
  font-weight: 600;
  margin-top: 6px;
  display: none;
}
.app-error-text.show { display: block; }

.app-btn-full { width: 100%; }

/* Badges */
.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-note);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}
.app-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.app-badge--success { background: var(--color-success-light); color: var(--color-success); }
.app-badge--warning { background: var(--color-warning-light); color: var(--color-warning); }
.app-badge--danger { background: var(--color-danger-light); color: var(--color-danger); }

/* Progress (assessment steps) */
.app-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.app-progress__bar {
  flex: 1;
  height: 6px;
  border-radius: 6px;
  background: #E3EAF2;
  overflow: hidden;
}
.app-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
  border-radius: 6px;
  transition: width 0.3s var(--ease);
}
.app-progress__label {
  font-size: var(--fs-note);
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* Empty state */
.app-empty {
  text-align: center;
  padding: 48px 16px;
}
.app-empty__icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.app-empty h3 { font-size: var(--fs-lead); margin: 0 0 8px; }
.app-empty p { font-size: var(--fs-small); color: var(--color-text-muted); margin: 0 0 20px; }

/* Medical disclaimer — used anywhere a health score/result is shown */
.disclaimer-note {
  display: flex;
  gap: 10px;
  background: #F4F6F9;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: var(--fs-note);
  line-height: 1.6;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}
.disclaimer-note::before {
  content: "";
  flex-shrink: 0;
  width: 16px; height: 16px;
  margin-top: 1px;
  background: var(--color-text-faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8v.01' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8v.01' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Toast */
.hm-toast-host {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 360px);
}
.hm-toast {
  background: var(--color-text);
  color: #fff;
  font-size: var(--fs-small);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.hm-toast.show { opacity: 1; transform: translateY(0); }
.hm-toast--success { background: var(--color-success); }
.hm-toast--danger { background: var(--color-danger); }

/* Pills (symptom chooser, etc.) */
.app-pill-group { display: flex; flex-wrap: wrap; gap: 10px; }
.app-pill {
  border: 1.5px solid #E3EAF2;
  background: var(--color-white);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.app-pill.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* ---------- ลูกศรท้ายปุ่มและแถวรายการ วาดด้วย SVG เพราะฟอนต์ไม่มี glyph → ---------- */
.arrow-r::after {
  content: "";
  display: inline-block;
  width: 1em; height: 1em;
  margin-left: 6px;
  vertical-align: -0.12em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chev {
  display: inline-block;
  width: 18px; height: 18px;
  background: currentColor;
  opacity: 0.45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.arrow-l::before {
  content: "";
  display: inline-block;
  width: 1em; height: 1em;
  margin-right: 6px;
  vertical-align: -0.12em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
