/* CSS Design System and Styling for GrowthSprout */

:root {
  /* Color Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-sidebar: #0f172a;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary-color: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.15);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.1);
  --info: #06b6d4;
  --info-glow: rgba(6, 182, 212, 0.1);
  
  --border-light: #e2e8f0;
  --border-focus: #cbd5e1;
  
  /* Layout Dimensions */
  --sidebar-width: 280px;
  --header-height: 70px;
  
  /* UI Tokens */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.12);
  
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* App Layout Grid */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* App Header styling */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
  color: var(--success);
  filter: drop-shadow(0 2px 4px var(--success-glow));
}

.logo h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sidebar-width); /* using dark blue colors */
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* App Layout Grid */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar Component */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar h2 {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  margin-bottom: 1.25rem;
}

/* Profiles List */
.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex-grow: 1;
}

/* Profile List Card */
.profile-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: var(--transition-normal);
  user-select: none;
}

.profile-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.profile-item.active {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-color, var(--primary-color));
  box-shadow: 0 0 12px var(--accent-glow, var(--primary-glow));
}

.profile-avatar-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--accent-color, var(--primary-color));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-right: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  overflow: hidden; /* Ensure image fits boundary */
}

.profile-avatar-img,
.child-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.profile-details {
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
}

.profile-age {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}

/* Main Content styling */
.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background-color: var(--bg-primary);
  min-width: 0; /* Prevent flex item from overflowing */
}

/* Cards Design */
.card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  min-width: 0; /* Prevent grid item from overflowing */
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/* Empty State Card styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 550px;
  margin: 4rem auto;
  padding: 3rem;
  animation: slideUp var(--transition-normal);
}

.empty-state-icon {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  background-color: var(--primary-glow);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 1.5rem;
  animation: bounce 2s infinite ease-in-out;
}

.empty-state h2 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  color: var(--sidebar-width);
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 10px var(--primary-glow);
}
.btn-primary:hover {
  background-color: #3b31d0;
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--success);
  color: white;
  box-shadow: 0 4px 10px var(--success-glow);
}
.btn-success:hover {
  background-color: #0d9f6e;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-icon-danger {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: #fef2f2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fee2e2;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon-danger:hover {
  background-color: #fee2e2;
  transform: translateY(-1px);
}

/* Dashboard Layout Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  animation: fadeIn var(--transition-normal);
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 350px 1fr;
  }
  .table-card {
    grid-column: span 2;
  }
}

/* Overview Card and Stats styling */
.child-overview-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 5px solid var(--accent-color, var(--primary-color));
}

.child-badge-header {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.child-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background-color: var(--accent-glow, var(--primary-glow));
  color: var(--accent-color, var(--primary-color));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.child-meta {
  flex-grow: 1;
}

.child-meta h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--sidebar-width);
}

.child-submeta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.stats-row {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--sidebar-width);
}

.stat-value small {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value-sub {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sidebar-width);
}

.stat-diff {
  position: absolute;
  right: 1rem;
  bottom: 1.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.stat-diff.positive {
  background-color: #ecfdf5;
  color: var(--success);
}

.stat-diff.info {
  background-color: #ecfeff;
  color: var(--info);
}

.overview-footer {
  margin-top: auto;
}

/* Growth Trend Charts Container */
.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

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

.card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-toggle {
  background-color: #f1f5f9;
  border: 1px solid var(--border-light);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.15rem;
}

.btn-toggle {
  background-color: transparent;
  color: var(--text-muted);
  border: none;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-toggle.active {
  background-color: white;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.chart-container {
  flex-grow: 1;
  position: relative;
  width: 100%;
}

/* Historical Data Table styling */
.table-card {
  padding-bottom: 1rem;
}

.table-container {
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  background-color: #f8fafc;
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 0.95rem;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f8fafc;
}

.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
  text-align: center;
  color: var(--text-muted);
  gap: 0.75rem;
}

.table-empty i {
  font-size: 2.2rem;
  color: var(--text-light);
}

.table-empty p {
  font-size: 0.95rem;
}

/* Modal Overlay Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-normal);
}

.modal-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  animation: scaleUp var(--transition-normal);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--sidebar-width);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

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

.modal-form {
  padding: 1.75rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

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

input[type="text"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background-color: #f8fafc;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-fast);
}

input:focus,
select:focus {
  border-color: var(--primary-color);
  background-color: white;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Custom Accent Color picker */
.color-picker-grid {
  display: flex;
  gap: 0.75rem;
}

.color-swatch {
  cursor: pointer;
  position: relative;
  display: inline-block;
  width: 32px;
  height: 32px;
}

.color-swatch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.color-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background-color: var(--swatch-color);
  border: 2px solid transparent;
  transition: var(--transition-fast);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.color-swatch input:checked + span {
  border-color: #0f172a;
  transform: scale(1.15);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-light);
  padding: 1.25rem 1.75rem 0;
  margin-top: 1rem;
}
/* Utilities */
.hidden {
  display: none !important;
}

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ==========================================================================
   Responsive and Mobile UI Support
   ========================================================================== */

/* Logo Group inside Header */
.logo-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-main);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  outline: none;
}

.btn-menu-toggle:hover {
  background-color: var(--bg-primary);
}

.btn-menu-toggle:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Sidebar overlay background */
.sidebar-overlay-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 80;
  transition: opacity var(--transition-normal);
}

/* Tablet & Mobile Screens (Under 1024px) */
@media (max-width: 1023.98px) {
  .btn-menu-toggle {
    display: inline-flex;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Off-canvas width */
    height: 100vh;
    z-index: 90;
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-xl);
  }
  
  .sidebar.open {
    transform: translateX(280px);
  }
  
  .app-header {
    padding: 0 1.25rem;
  }
  
  .main-content {
    padding: 1.5rem;
  }
}

/* Mobile Screens (Under 768px) */
@media (max-width: 767.98px) {
  .app-header {
    padding: 0 1rem;
  }
  
  .logo h1 {
    font-size: 1.25rem;
  }
  
  .btn {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
  }
  
  .btn-primary {
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }
  
  .child-avatar {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
  }
  
  .child-meta h2 {
    font-size: 1.15rem;
  }
  
  .stats-row {
    gap: 0.85rem;
  }
  
  .stat-box {
    padding: 0.85rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  .stat-value-sub {
    font-size: 1.1rem;
  }
  
  /* Make tables horizontal scrollable nicely */
  th, td {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  
  /* Modals adaptive sizing */
  .modal-card {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
  }
  
  .modal-form {
    padding: 1.25rem;
    overflow-y: auto;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .color-picker-grid {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  
  .modal-footer {
    padding: 1rem 1.25rem 0;
  }
  
  .chart-card {
    min-height: 350px;
  }
  
  .chart-container {
    height: 260px;
  }
}

