/* ── WHO Growth Percentile Chart ── */

/* Child Profile Bar */
.child-profile-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.profile-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.sex-toggle {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.sex-toggle button {
  padding: 0.4rem 1rem;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sex-toggle button.active-boy {
  background: #3b82f6;
  color: #fff;
}

.sex-toggle button.active-girl {
  background: #ec4899;
  color: #fff;
}

/* Date select dropdowns */
.date-selects {
  display: flex;
  gap: 0.3rem;
}

.date-selects select {
  padding: 0.4rem 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
  min-width: 0;
  cursor: pointer;
}

.profile-group-dob {
  flex-wrap: wrap;
}

.profile-group-dob .date-selects select:first-child { width: 4.5rem; }
.profile-group-dob .date-selects select:nth-child(2) { width: 3.5rem; }
.profile-group-dob .date-selects select:last-child { width: 4.5rem; }

.form-group-date .date-selects select:first-child { width: 4.5rem; }
.form-group-date .date-selects select:nth-child(2) { width: 3.5rem; }
.form-group-date .date-selects select:last-child { width: 4.5rem; }

.age-display {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
}

/* Chart Tabs */
.chart-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border-light);
  margin-bottom: 1rem;
}

.chart-tab {
  padding: 0.6rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.chart-tab:hover {
  color: var(--color-text);
  background: var(--color-bg-secondary);
}

.chart-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Chart Container */
.chart-container {
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.chart-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.chart-empty span {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Measurement Entry Form */
.measurement-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.unit-hint {
  font-weight: 500;
  text-transform: none;
  opacity: 0.7;
}

.form-group input,
.form-group select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--color-bg);
  color: var(--color-text);
  min-width: 0;
}

.form-group input[type="number"] {
  width: 100%;
}

.form-group-date {
  min-width: 200px;
}

.form-group .unit-label {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-left: 0.25rem;
}

.measurement-form .btn-add {
  flex: none;
  padding: 0.5rem 1.25rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.measurement-form .btn-add:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Unit Toggle */
.unit-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.unit-toggle {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.unit-toggle button {
  padding: 0.35rem 0.9rem;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.unit-toggle button.active {
  background: var(--color-primary);
  color: #fff;
}

/* Measurements Table */
.measurements-table-wrap {
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.measurements-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.measurements-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.measurements-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
}

.measurements-table tr:hover td {
  background: var(--color-bg-secondary);
}

.measurements-table .percentile-cell {
  font-weight: 600;
}

.percentile-low { color: #ef4444; }
.percentile-normal { color: #22c55e; }
.percentile-high { color: #f59e0b; }

.btn-delete-entry {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  opacity: 0.5;
}

.btn-delete-entry:hover {
  opacity: 1;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.table-empty {
  text-align: center;
  padding: 1.5rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* Tool Actions */
.tool-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.tool-actions .btn {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--color-surface);
  color: var(--color-text);
}

.tool-actions .btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.tool-actions .btn-clear {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.tool-actions .btn-clear:hover {
  color: #ef4444;
  border-color: #ef4444;
  opacity: 1;
}

/* Chart Legend */
.chart-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.5rem 0;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

/* References */
.references-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.references-list li {
  padding: 0.5rem 0 0.5rem 1.25rem;
  position: relative;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
}

.references-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.85rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
}

.references-list a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.references-list a:hover {
  text-decoration: underline;
}

.references-note {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-style: italic;
  padding: 0.75rem 1rem;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary);
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .child-profile-bar {
    gap: 1rem;
  }

  .measurement-form {
    flex-wrap: wrap;
  }

  .measurement-form .form-group {
    flex: 1 1 calc(50% - 0.75rem);
    min-width: 120px;
  }

  .form-group input[type="number"] {
    width: 100%;
  }

  .measurement-form .btn-add {
    flex: 1 1 100%;
  }

  .chart-tabs {
    gap: 0;
  }

  .chart-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .child-profile-bar {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .profile-group {
    width: 100%;
    justify-content: space-between;
  }

  .chart-container {
    padding: 0.5rem;
  }

  .chart-legend {
    gap: 0.75rem;
    font-size: 0.75rem;
  }
}

/* Print */
@media print {
  .measurement-form,
  .tool-actions,
  .unit-toggle-row,
  .btn-delete-entry {
    display: none !important;
  }

  .chart-container {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
