/* ═══════════════════════════════════════════════════════════
   FCC Medical, Safety & Device Info Premium — medical-safety-premium.css
   Scoped to #medicalInfoPanelWrap (.msp-overlay) and the
   .msp-modal-overlay editors appended to <body>.
   Loads after core stylesheets so it wins ties.
   ═══════════════════════════════════════════════════════════ */

.msp-overlay,
.msp-modal-overlay {
  --msp-purple: #6d35f5;
  --msp-purple-deep: #5526cc;
  --msp-purple-soft: #efe9ff;
  --msp-purple-chip: #ece4ff;
  --msp-ink: #1c2240;
  --msp-muted: #6a7186;
  --msp-slate: #8a90a5;
  --msp-line: rgba(109, 53, 245, 0.14);
  --msp-line-soft: rgba(28, 34, 64, 0.08);
  --msp-mint-bg: #e4f7ec;
  --msp-mint-ink: #177245;
  --msp-amber-bg: #fdf1de;
  --msp-amber-ink: #9a5b08;
  --msp-card-shadow: 0 14px 36px rgba(76, 54, 130, 0.1);
  --msp-card-shadow-sm: 0 8px 22px rgba(76, 54, 130, 0.07);
}

/* ── Full-page overlay shell ─────────────────────────────── */
.msp-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  background: #f6f4fb;
  overflow: hidden;
}

.msp-overlay[aria-hidden='true'] { display: none; }

.msp-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.msp-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 28px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--msp-ink);
  font-family: inherit;
  text-align: left;
}

.msp-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.msp-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--msp-line);
  background: #fff;
  color: var(--msp-purple-deep);
  border-radius: 999px;
  padding: 9px 18px 9px 14px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: var(--msp-card-shadow-sm);
  transition: background 0.15s ease, transform 0.15s ease;
}

.msp-back-btn:hover { background: var(--msp-purple-soft); }
.msp-back-btn:focus-visible,
.msp-overlay button:focus-visible,
.msp-modal-overlay button:focus-visible {
  outline: 2px solid var(--msp-purple);
  outline-offset: 2px;
}

.msp-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Child profile header ────────────────────────────────── */
.msp-profile-header {
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 22px;
  background: #fff;
  border: 1px solid var(--msp-line-soft);
  border-radius: 22px;
  padding: 24px 28px;
  box-shadow: var(--msp-card-shadow-sm);
  flex-wrap: wrap;
}

.msp-avatar {
  flex-shrink: 0;
  width: 86px;
  height: 86px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--msp-purple-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

.msp-avatar img,
.msp-avatar .profile-avatar-lg,
.msp-avatar .profile-avatar,
.msp-avatar > * {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border-radius: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msp-headline { flex: 1 1 260px; min-width: 220px; }

.msp-headline h1 {
  margin: 2px 0 6px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--msp-ink);
}

.msp-headline p {
  margin: 2px 0;
  color: var(--msp-muted);
  font-size: 0.94rem;
}

.msp-headline p strong { color: var(--msp-ink); font-weight: 700; }

.msp-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
}

.msp-header-side .msp-review-meta {
  text-align: right;
  color: var(--msp-muted);
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0;
}

.msp-header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* Pills */
.msp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.msp-pill--ok { background: var(--msp-mint-bg); color: var(--msp-mint-ink); }
.msp-pill--warn { background: var(--msp-amber-bg); color: var(--msp-amber-ink); }
.msp-pill svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Buttons */
.msp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid var(--msp-line);
  background: #fff;
  color: var(--msp-ink);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.msp-btn:hover { background: var(--msp-purple-soft); }
.msp-btn:active { transform: translateY(1px); }
.msp-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.msp-btn--primary {
  background: var(--msp-purple);
  border-color: var(--msp-purple);
  color: #fff;
  box-shadow: 0 10px 24px rgba(109, 53, 245, 0.32);
}

.msp-btn--primary:hover { background: var(--msp-purple-deep); }

.msp-btn--ghost { border-color: var(--msp-line-soft); color: var(--msp-muted); }
.msp-btn--ghost:hover { color: var(--msp-ink); }

/* ── Profile tabs ────────────────────────────────────────── */
.msp-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--msp-line-soft);
  border-radius: 18px;
  padding: 8px 12px 0;
  box-shadow: var(--msp-card-shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.msp-tabs::-webkit-scrollbar { display: none; }

.msp-tab {
  appearance: none;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 14px;
  color: var(--msp-muted);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.msp-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.msp-tab:hover { color: var(--msp-ink); }

.msp-tab.is-active {
  color: var(--msp-purple);
  border-bottom-color: var(--msp-purple);
}

/* ── Medical panel container ─────────────────────────────── */
.msp-panel {
  background: #fff;
  border: 1px solid var(--msp-line-soft);
  border-radius: 22px;
  padding: 26px 28px 28px;
  box-shadow: var(--msp-card-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msp-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.msp-panel-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--msp-purple-soft);
  color: var(--msp-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msp-panel-icon svg { width: 22px; height: 22px; }

.msp-panel-titles { flex: 1 1 240px; min-width: 200px; }

.msp-panel-titles h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--msp-ink);
}

.msp-panel-titles p { margin: 0; color: var(--msp-muted); font-size: 0.92rem; }

.msp-panel-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ── Card grid ───────────────────────────────────────────── */
.msp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.msp-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--msp-line-soft);
  border-radius: 20px;
  padding: 20px 20px 48px;
  box-shadow: var(--msp-card-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.msp-card--wide { grid-column: span 2; }

.msp-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.msp-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--msp-purple-soft);
  color: var(--msp-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msp-card-icon svg { width: 16px; height: 16px; }

.msp-card-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--msp-ink);
  flex: 1;
  min-width: 0;
}

.msp-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.msp-edit-btn {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--msp-slate);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.msp-edit-btn:hover { background: var(--msp-purple-soft); color: var(--msp-purple); }
.msp-edit-btn svg { width: 15px; height: 15px; }

/* label / value rows */
.msp-field { min-width: 0; }

.msp-label {
  display: block;
  color: var(--msp-muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0 0 2px;
}

.msp-value {
  margin: 0;
  color: var(--msp-ink);
  font-size: 0.94rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.msp-value--muted { color: var(--msp-slate); font-weight: 600; }

.msp-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.msp-divider { border: none; border-top: 1px solid var(--msp-line-soft); margin: 2px 0; }

.msp-note {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--msp-line-soft);
  color: var(--msp-slate);
  font-size: 0.82rem;
  line-height: 1.45;
}

.msp-note strong { color: var(--msp-muted); font-weight: 700; }

.msp-empty {
  margin: 0;
  color: var(--msp-slate);
  font-size: 0.88rem;
  font-style: italic;
}

/* Emergency contact rows */
.msp-contact { display: flex; gap: 12px; align-items: flex-start; }

.msp-contact-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--msp-purple-soft);
  color: var(--msp-purple-deep);
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.msp-contact-info { min-width: 0; flex: 1; }

.msp-contact-name {
  margin: 0 0 3px;
  font-weight: 800;
  font-size: 0.93rem;
  color: var(--msp-ink);
  overflow-wrap: anywhere;
}

.msp-contact-line {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.msp-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--msp-muted);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.msp-phone svg { width: 13px; height: 13px; color: var(--msp-purple); flex-shrink: 0; }

.msp-contact-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--msp-purple-deep);
  font-size: 0.8rem;
  font-weight: 700;
}

.msp-contact-tag svg { width: 13px; height: 13px; }

/* Medications mini-table */
.msp-med-table { display: flex; flex-direction: column; gap: 0; }

.msp-med-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.1fr;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--msp-line-soft);
  font-size: 0.86rem;
  align-items: baseline;
}

.msp-med-row:last-child { border-bottom: none; }

.msp-med-row--head {
  color: var(--msp-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.msp-med-row .msp-med-name { font-weight: 800; color: var(--msp-ink); overflow-wrap: anywhere; }
.msp-med-row .msp-med-cell { color: var(--msp-muted); font-weight: 600; overflow-wrap: anywhere; }

/* Health history rows */
.msp-hh-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 26px;
}

.msp-hh-row {
  display: grid;
  grid-template-columns: 1.4fr auto 0.9fr;
  gap: 10px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--msp-line-soft);
  font-size: 0.86rem;
}

.msp-hh-row:last-child { border-bottom: none; }
.msp-hh-label { color: var(--msp-muted); font-weight: 600; }
.msp-hh-flag { font-weight: 800; color: var(--msp-ink); }
.msp-hh-flag--yes { color: var(--msp-purple-deep); }
.msp-hh-detail {
  color: var(--msp-slate);
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msp-hh-extra {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0 0;
  font-size: 0.88rem;
}

.msp-hh-extra .msp-hh-label { font-weight: 700; }
.msp-hh-extra .msp-hh-value { font-weight: 800; color: var(--msp-ink); }

/* ── Review banner ───────────────────────────────────────── */
.msp-review-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(110deg, #f3eeff 0%, #faf7ff 55%, #f1e9ff 100%);
  border: 1px solid var(--msp-line);
  border-radius: 18px;
  padding: 18px 22px;
  flex-wrap: wrap;
}

.msp-review-banner .msp-panel-icon { background: #fff; }

.msp-review-text { flex: 1 1 280px; min-width: 220px; }
.msp-review-text p { margin: 2px 0; font-size: 0.9rem; color: var(--msp-muted); }
.msp-review-text p strong { color: var(--msp-ink); }

/* ── Secondary tab content (overview / contacts / etc.) ──── */
.msp-simple-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.msp-note-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msp-note-composer textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--msp-line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--msp-ink);
  background: #fbfaff;
  resize: vertical;
}

.msp-note-composer textarea:focus { outline: 2px solid var(--msp-purple); outline-offset: 1px; }

.msp-note-item {
  border: 1px solid var(--msp-line-soft);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfaff;
}

.msp-note-item p { margin: 0 0 6px; color: var(--msp-ink); font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.msp-note-item .msp-note-meta { margin: 0; color: var(--msp-slate); font-size: 0.78rem; font-weight: 600; }

.msp-activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--msp-line-soft);
}

.msp-activity-item:last-child { border-bottom: none; }
.msp-activity-item .msp-card-icon { width: 28px; height: 28px; border-radius: 9px; }
.msp-activity-item .msp-card-icon svg { width: 14px; height: 14px; }
.msp-activity-item p { margin: 0; font-size: 0.9rem; color: var(--msp-ink); }
.msp-activity-item .msp-note-meta { margin: 2px 0 0; color: var(--msp-slate); font-size: 0.78rem; font-weight: 600; }

/* ── Edit modals ─────────────────────────────────────────── */
.msp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 360;
  background: rgba(28, 22, 54, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.msp-modal {
  position: relative;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(40, 24, 90, 0.35);
  width: 100%;
  max-width: 640px;
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msp-modal--wide { max-width: 880px; }

.msp-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--msp-line-soft);
}

.msp-modal-head .msp-card-icon { width: 36px; height: 36px; border-radius: 12px; }

.msp-modal-head h3 {
  margin: 0;
  flex: 1;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--msp-ink);
}

.msp-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: none;
  background: #f3f1fa;
  color: var(--msp-muted);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msp-modal-close:hover { background: var(--msp-purple-soft); color: var(--msp-purple-deep); }

.msp-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.msp-modal-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 24px 0;
}

.msp-modal-tabs button {
  border: 1px solid var(--msp-line);
  background: #fff;
  color: var(--msp-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.msp-modal-tabs button.is-active {
  background: var(--msp-purple);
  border-color: var(--msp-purple);
  color: #fff;
}

.msp-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--msp-line-soft);
  background: #fbfaff;
}

/* Form fields inside modals (reuses .medical-info-field markup) */
.msp-modal .medical-info-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.msp-modal .medical-info-field { min-width: 0; }
.msp-modal .medical-info-field--full { grid-column: 1 / -1; }

.msp-modal .medical-info-field label {
  display: block;
  color: var(--msp-muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0 0 5px;
}

.msp-modal .medical-info-field input,
.msp-modal .medical-info-field select,
.msp-modal .medical-info-field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--msp-line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--msp-ink);
  background: #fbfaff;
  box-sizing: border-box;
}

.msp-modal .medical-info-field input:focus,
.msp-modal .medical-info-field select:focus,
.msp-modal .medical-info-field textarea:focus {
  outline: 2px solid var(--msp-purple);
  outline-offset: 1px;
}

/* Access denied / not found state */
.msp-blocked {
  background: #fff;
  border: 1px solid var(--msp-line-soft);
  border-radius: 20px;
  padding: 38px 30px;
  text-align: center;
  color: var(--msp-muted);
  box-shadow: var(--msp-card-shadow-sm);
}

.msp-blocked h2 { color: var(--msp-ink); margin: 0 0 8px; font-size: 1.15rem; }
.msp-blocked p { margin: 0; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .msp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .msp-shell { padding: 14px 14px 44px; }
  .msp-grid { grid-template-columns: 1fr; }
  .msp-card--wide { grid-column: auto; }
  .msp-hh-cols { grid-template-columns: 1fr; gap: 0; }
  .msp-two-col { grid-template-columns: 1fr; }
  .msp-simple-grid { grid-template-columns: 1fr; }
  .msp-profile-header { padding: 18px; gap: 14px; }
  .msp-header-side { align-items: flex-start; margin-left: 0; }
  .msp-header-side .msp-review-meta { text-align: left; }
  .msp-panel { padding: 18px 16px 20px; }
  .msp-panel-actions { margin-left: 0; }
  .msp-modal .medical-info-fields { grid-template-columns: 1fr; }
  .msp-modal .medical-info-field--full { grid-column: auto; }
  .msp-modal-overlay { padding: 10px; }
}
