/* =============================================================
   Insight — Shared Stylesheet
   Covers: reset, typography, nav, avatar dropdown, page layout,
           cards, section labels, forms, buttons, loading states.
   Page-specific CSS stays inline in each HTML file.
   ============================================================= */

/* ---------- RESET ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- BASE ---------- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- TOP NAV ---------- */
nav.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 48px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #1a1a1a;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-links a {
  font-size: 14px;
  color: #888;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active { color: #1a1a1a; }
.nav-links a.active { font-weight: 500; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---------- AVATAR ---------- */
.avatar-wrap { position: relative; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1a7a6e;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  user-select: none;
}

.avatar:hover { opacity: 0.8; }

/* ---------- ACCOUNT DROPDOWN ---------- */
.account-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  z-index: 200;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.account-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.account-dropdown-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid #ebebeb;
}

.account-dropdown-name {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-dropdown-email {
  font-size: 12px;
  color: #aaa;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-dropdown-menu { padding: 6px 0; }

.account-menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  font-size: 14px;
  color: #1a1a1a;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.account-menu-item:hover { background: #f9f9f9; }

.account-menu-item .menu-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.account-menu-divider {
  height: 1px;
  background: #f0f0f0;
  margin: 5px 0;
}

.account-menu-item.danger { color: #c0392b; }
.account-menu-item.danger:hover { background: #fdf0f0; }
.account-menu-item.active-page { font-weight: 500; }

/* ---------- PAGE LAYOUT ---------- */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

/* Narrower variant used by profile, billing, medical-history, etc. */
.page.page-narrow {
  max-width: 720px;
  padding: 48px 48px 100px;
}

.page-heading {
  margin-bottom: 36px;
}

.page-heading h1,
.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.page-heading p,
.page-header .greeting {
  font-size: 13px;
  color: #aaa;
  margin-top: 6px;
}

/* Large hero h1 on dashboard */
.page-header h1.large {
  font-size: 36px;
}

/* ---------- SECTIONS ---------- */
.section { margin-bottom: 28px; }

.section-title,
.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 14px;
}

/* ---------- CARDS ---------- */
.card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid #e8e8e8;
  padding: 28px 32px;
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: #1a1a1a;
  color: #fff;
}

.btn-primary:hover { background: #155f56; }

.btn-secondary {
  background: #f0f0f0;
  color: #1a1a1a;
}

.btn-secondary:hover { background: #e0e0e0; }

.btn-green {
  background: #1a7a6e;
  color: #fff;
}

.btn-green:hover { background: #155f56; }

.btn:disabled,
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- FORMS ---------- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: #888;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

input,
select,
textarea {
  padding: 12px 16px;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a1a;
  background: #f9f9f9;
  outline: none;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus { border-color: #1a1a1a; background: #fff; }

input:disabled,
input[readonly],
select:disabled { background: #f5f2ec; color: #aaa; cursor: not-allowed; }

input::placeholder,
textarea::placeholder { color: #bbb; }

/* Unit toggle (used in onboarding, biological-age) */
.unit-row { display: flex; align-items: center; gap: 10px; }
.unit-row input { flex: 1; }
.unit-toggle { display: flex; background: #f0f0f0; border-radius: 8px; padding: 3px; gap: 2px; flex-shrink: 0; }
.unit-btn { font-size: 12px; font-weight: 500; padding: 5px 10px; border-radius: 6px; border: none; background: transparent; color: #888; cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s; }
.unit-btn.active { background: #fff; color: #1a1a1a; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ---------- TOAST / STATUS MESSAGES ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- LOADING STATE ---------- */
.loading-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- STATUS BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-green  { background: #e8f4e8; color: #2d7a2d; }
.badge-red    { background: #fdeaea; color: #c0392b; }
.badge-yellow { background: #fef9e7; color: #9a7d0a; }
.badge-grey   { background: #f0f0f0; color: #888; }
.badge-teal   { background: #e0f0ee; color: #1a7a6e; }

/* ---------- DIVIDER ---------- */
hr.divider {
  border: none;
  border-top: 1px solid #ebebeb;
  margin: 24px 0;
}

/* ---------- RESPONSIVE (basic) ---------- */
@media (max-width: 768px) {
  nav.topnav { padding: 16px 20px; }
  .nav-links  { display: none; }
  .page       { padding: 24px 20px 60px; }
  .page.page-narrow { padding: 24px 20px 60px; }
  .form-row   { grid-template-columns: 1fr; }
  .form-row.triple { grid-template-columns: 1fr; }
}
