:root {
  --primary: #6C5DD3;
  --primary-light: #CFC8FF;
  --secondary: #FD853A;
  --secondary-light: #FFE2D0;
  --success: #2CBF6E;
  --text-dark: #11142D;
  --text-grey: #808191;
  --bg-body: #F7F7F7;
  --bg-card: #FFFFFF;
  --shadow-card: 0px 10px 40px rgba(29, 22, 23, 0.07);
  --radius-card: 24px;
  --radius-btn: 16px;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-body);
  color: var(--text-dark);
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 1440px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header Section */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.header-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-dark);
}

.header-content p {
  color: var(--text-grey);
  margin: 0.5rem 0 0;
  font-size: 1rem;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Sidebar / Controls Card */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease;
}

.card {
  overflow: hidden;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
  }
}

.card-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-grey);
  margin-bottom: 0.75rem;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #F8FAFC;
  color: var(--text-dark);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  box-sizing: border-box;
}

.form-input:focus {
  background: #fff;
  border-color: var(--primary);
  outline: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Removed old .unit-tag style */
.unit-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-grey);
  white-space: nowrap;
  padding-left: 8px;
  /* Make it sit outside or to the right cleanly */
}

/* Input Wrapper flex to put unit next to input */
.input-wrapper {
  display: flex;
  align-items: center;
}

.age-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-grey);
  margin-top: 4px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 24px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 10px 20px -5px rgba(108, 93, 211, 0.4);
}

.btn-primary:hover {
  background: #5c4ec4;
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-grey);
  border: 2px solid #E4E4E4;
}

.btn-secondary:hover {
  border-color: var(--text-grey);
  color: var(--text-dark);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-icon.orange { background: var(--secondary-light); color: var(--secondary); }
.stat-icon.green { background: #dcfce7; color: var(--success); }

.stat-content h3 {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-grey);
  font-weight: 600;
}

.stat-content .value {
  margin: 4px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
}

.stat-content .trend {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 6px;
}

.trend.up { background: #dcfce7; color: var(--success); }
.trend.neutral { background: #f3f4f6; color: var(--text-grey); }
.trend.down { background: #fee2e2; color: #ef4444; }

/* Main Chart Area */
.main-chart-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.chart-container {
  height: 500px;
  width: 100%;
  position: relative;
}

/* Tabs */
.tabs {
  display: flex;
  background: #F8FAFC;
  padding: 4px;
  border-radius: 12px;
  width: fit-content;
}

.tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-grey);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: white;
  color: var(--text-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Measurements List */
.measurements-list {
  margin-top: 1rem;
}

.measurement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.measurement-item:last-child {
  border-bottom: none;
}

.measurement-info {
  display: flex;
  flex-direction: column;
}

.measurement-date {
  font-size: 0.75rem;
  color: var(--text-grey);
}

.measurement-value {
  font-weight: 700;
  color: var(--text-dark);
}

.measurement-percentile {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 0.75rem;
    gap: 1rem;
  }

  .header {
    margin-bottom: 0.5rem;
  }

  .header-content h1 {
    font-size: 1.5rem;
  }

  .header-content p {
    display: none;
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .card-header {
    margin-bottom: 1rem;
  }

  .card-title {
    font-size: 1.1rem;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .stat-card {
    padding: 12px;
    border-radius: 16px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .stat-content h3 {
    font-size: 0.7rem;
  }

  .stat-content .value {
    font-size: 1.1rem;
  }

  .chart-container {
    height: 300px;
  }

  .tab {
    padding: 6px 14px;
    font-size: 0.85rem;
  }

  .btn {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
  }

  .form-input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .main-chart-section {
    gap: 1rem;
  }
}

/* Child List */
.child-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.child-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.child-item:hover {
  background: #F8FAFC;
}

.child-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.child-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.child-avatar.boy { background: #60a5fa; }
.child-avatar.girl { background: #f472b6; }

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

.child-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.child-detail {
  font-size: 0.75rem;
  color: var(--text-grey);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-grey);
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-dark);
}

/* Social Sign-In Buttons */
.social-signin-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.social-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 22px;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  padding: 0 16px;
  gap: 10px;
}

.social-signin-btn:hover {
  opacity: 0.85;
}

.social-signin-btn:active {
  opacity: 0.7;
}

.social-signin-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Apple: black bg, white text/icon — per Apple HIG */
.apple-signin {
  background: #000;
  color: #fff;
}

/* Google: white bg, dark text, subtle border — per Google branding guidelines */
.google-signin {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}

.google-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Auth UI */
.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.auth-signin,
.auth-signout {
  width: auto !important;
  padding: 8px 16px !important;
  font-size: 0.875rem !important;
}

/* Offline Banner */
.offline-banner {
  background: #FEF3C7;
  color: #92400E;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 12px;
}
