/* styles.css — Family Health Record */

/* ===== Design Tokens ===== */
:root {
  /* Backgrounds */
  --bg: #0d1117;
  --bg-gradient: linear-gradient(160deg, #0d1117 0%, #0a0e14 100%);
  --surface: #161b22;
  --card: #161b22;
  --input-bg: #0d1117;
  --hover-bg: #1c2431;

  /* Borders */
  --line: #30363d;
  --line-hover: #484f58;
  --focus-ring: rgba(63, 185, 80, 0.28);

  /* Text */
  --text: #e6edf3;
  --muted: #b1bac4;
  --muted-dim: #6e7681;

  /* Accent — green */
  --accent: #3fb950;
  --accent-hover: #2ea043;
  --accent-subtle: rgba(63, 185, 80, 0.1);

  /* Status Colors */
  --issue-bg: rgba(245, 158, 11, 0.12);
  --issue-border: rgba(245, 158, 11, 0.35);
  --issue-text: #fbbf24;

  --med-bg: rgba(6, 182, 212, 0.12);
  --med-border: rgba(6, 182, 212, 0.35);
  --med-text: #22d3ee;

  --allergy-bg: rgba(239, 68, 68, 0.12);
  --allergy-border: rgba(239, 68, 68, 0.35);
  --allergy-text: #f87171;

  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.3);
  --danger-text: #f87171;
  --danger-hover: rgba(239, 68, 68, 0.18);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 8px 20px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-gradient);
  min-height: 100vh;
}

/* ===== Typography ===== */
h1, h2, h3 {
  margin: 0;
  line-height: 1.3;
}

/* ===== Header ===== */
header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 1px 0 rgba(48, 54, 61, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.tagline {
  font-size: 13px;
  color: var(--muted);
  margin-top: 1px;
}

.spacer {
  flex: 1;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--line);
  background: #21262d;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}

.btn:hover {
  border-color: var(--line-hover);
  background: #2d333b;
  color: var(--text);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover {
  background: #1c2431;
  border-color: var(--line-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-text);
  color: var(--danger-text);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 13px;
}

.btn-icon {
  padding: 8px;
  min-width: 38px;
}

/* ===== Layout ===== */
main {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 24px 64px;
}

/* ===== Two-Column Grid ===== */
.layout-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 20px;
  align-items: start;
}

.col-form,
.col-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.grow {
  flex: 1;
  min-width: 160px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}

.form-section {
  border-top: 3px solid var(--accent);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ===== Form Inputs ===== */
input, textarea, select {
  font-family: inherit;
  font-size: 15px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}

input::placeholder, textarea::placeholder {
  color: var(--muted-dim);
}

textarea {
  resize: vertical;
  min-height: 64px;
}

select {
  cursor: pointer;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field-inline {
  min-width: 90px;
}

/* ===== Form Sections ===== */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
}

.section-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted-dim);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 2px;
}

.section-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-dot-identity { background: var(--accent); }
.section-dot-health   { background: var(--issue-text); }
.section-dot-notes    { background: #7c3aed; }
.section-dot-started  { background: var(--med-text); }

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
  border: none;
}

/* ===== Tag Input ===== */
.tag-input {
  display: flex;
  gap: 8px;
}

.tag-input input {
  flex: 1;
}

.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
  min-height: 4px;
}

.tag-group {
  flex: 1;
  min-width: 180px;
}

/* ===== Pills / Tags ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity var(--transition-fast);
}

.pill-issue {
  background: var(--issue-bg);
  border: 1px solid var(--issue-border);
  color: var(--issue-text);
}

.pill-med {
  background: var(--med-bg);
  border: 1px solid var(--med-border);
  color: var(--med-text);
}

.pill-allergy {
  background: var(--allergy-bg);
  border: 1px solid var(--allergy-border);
  color: var(--allergy-text);
}

.pill-remove {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  font-size: 15px;
  line-height: 1;
  transition: opacity var(--transition-fast);
}

.pill-remove:hover {
  opacity: 1;
}

/* ===== Member List ===== */
.member-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Member Card ===== */
.member-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  animation: fadeSlideIn var(--transition-slow) ease both;
}

.member-card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}

.member-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.member-relation {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.member-meta {
  font-size: 14px;
  color: var(--muted);
}

.member-updated {
  font-size: 12px;
  color: var(--muted-dim);
  margin-left: auto;
}

.member-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 6px;
  flex-shrink: 0;
}

.member-field-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}

.member-field-empty {
  font-size: 13px;
  color: var(--muted-dim);
}

.member-notes {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.member-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 14px;
  opacity: 0.7;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--muted-dim);
  max-width: 320px;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--transition-slow) ease both;
  max-width: 360px;
}

.toast-success {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
}

.toast-error {
  border-color: var(--allergy-border);
  background: var(--allergy-bg);
  color: var(--allergy-text);
}

.toast-info {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--accent-subtle);
  color: var(--accent);
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-out {
  animation: toastOut var(--transition-base) ease both;
}

/* ===== Custom Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast) ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 400px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--transition-base) ease both;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-message {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 22px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Animations ===== */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ===== Form Footer ===== */
.form-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.form-hint {
  font-size: 13px;
  color: var(--muted-dim);
}

/* ===== Getting Started ===== */
.getting-started {
  background: #0d1117;
}

.steps-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

.steps-list strong {
  color: var(--accent);
}

.getting-started-note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted-dim);
}

/* ===== Responsive: Collapse to single column ===== */
@media (max-width: 900px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding: 0 16px 56px;
    margin-top: 16px;
  }
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 768px) {
  header {
    padding: 12px 16px;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .spacer {
    display: none;
  }

  .row {
    gap: 10px;
  }

  .grow {
    min-width: 100%;
  }

  .tag-group {
    min-width: 100%;
  }

  .member-header {
    flex-direction: column;
    gap: 4px;
  }

  .member-updated {
    margin-left: 0;
  }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 480px) {
  .tagline {
    display: none;
  }

  .btn .btn-label {
    display: none;
  }

  .toolbar {
    gap: 4px;
  }

  .toolbar-divider {
    display: none;
  }

  .card {
    padding: 14px 16px;
  }

  .member-card {
    padding: 14px 16px;
  }

  .modal {
    padding: 20px;
  }
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted-dim);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-brand {
  font-weight: 600;
  color: var(--muted);
}

.footer-sep {
  opacity: 0.4;
}

/* ===== Button Icons ===== */
.btn-icon-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  pointer-events: none;
}

/* ===== Utility ===== */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
