/* Health Data Premium Styles - Matching Main Dashboard */

/* Screen Reader Only */
.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;
}

/* Error Message */
.health-error-message {
  background: #FEF2F2;
  border: 1px solid #FEE2E2;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.health-error-message .material-icons {
  color: #DC2626;
  font-size: 24px;
  flex-shrink: 0;
}

.error-text {
  flex: 1;
}

.error-text strong {
  display: block;
  color: #991B1B;
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.error-text p {
  color: #7F1D1D;
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.error-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: #DC2626;
  transition: background 0.2s;
  flex-shrink: 0;
}

.error-close:hover {
  background: #FEE2E2;
}

.error-close .material-icons {
  font-size: 20px;
}

/* Page Layout */
.main-content {
  padding: var(--spacing-2xl) var(--spacing-xl);
  max-width: 1600px;
  margin: 0 auto;
  padding-top: calc(70px + var(--spacing-2xl)); /* Account for navbar */
}

/* Health Data Page Specific */
.health-data-page {
  max-width: 1400px;
  margin: 0 auto;
}

.health-data-page .page-title {
  font-family: 'LINE Seed Sans TH', 'Noto Sans Thai Looped', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--spacing-sm);
  letter-spacing: -0.02em;
}

.health-data-page .page-subtitle {
  font-family: 'LINE Seed Sans TH', 'Noto Sans Thai Looped', sans-serif;
  font-size: 1.0625rem;
  color: var(--gray-600);
  font-weight: 400;
  margin-bottom: var(--spacing-2xl);
  line-height: 1.6;
}

/* Filters Section */
.filters-section {
  margin-bottom: var(--spacing-2xl);
}

.filters-grid,
.health-filters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
  padding: var(--spacing-xl);
  background: white;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.filter-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.filter-card.filter-date-range {
  grid-column: span 1;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filter-label .material-icons {
  font-size: 16px;
  color: var(--primary-color);
}

.filter-select {
  width: 100%;
  padding: 10px 14px;
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23525252' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-select:hover {
  border-color: var(--gray-400);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.filter-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.08), 0 2px 8px rgba(0, 102, 255, 0.12);
}

/* Date Range */
.date-range-card {
  grid-column: span 2;
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.date-input {
  flex: 1;
  padding: 10px 14px;
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.875rem;
  color: var(--gray-900);
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.date-input:hover {
  border-color: var(--gray-400);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.date-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.08), 0 2px 8px rgba(0, 102, 255, 0.12);
}

.date-separator {
  color: var(--gray-400);
  font-weight: 500;
  font-size: 0.875rem;
}


/* Statistics Section */
.stats-section {
  margin-bottom: var(--spacing-2xl);
}

.stats-grid,
.health-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

.stat-card,
.health-stat-card {
  background: white;
  border-radius: 12px;
  padding: var(--spacing-xl);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-card::before,
.health-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-color);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.stat-card:hover,
.health-stat-card:hover {
  border-color: var(--stat-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.stat-card:hover::before,
.health-stat-card:hover::before {
  transform: scaleY(1.5);
}

.stat-card-primary,
.health-stat-primary {
  --stat-color: var(--primary-color);
}

.stat-card-success,
.health-stat-success {
  --stat-color: var(--success-color);
}

.stat-card-warning,
.health-stat-warning {
  --stat-color: var(--warning-color);
}

.stat-card-purple,
.health-stat-purple {
  --stat-color: var(--purple-color);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--stat-color), color-mix(in srgb, var(--stat-color) 80%, black));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-icon .material-icons {
  font-size: 24px;
  color: white;
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.8125rem;
  color: var(--gray-600);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stat-value {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-unit {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.8125rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-top: 2px;
}

/* Charts Section */
.charts-section,
.health-charts-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

.charts-row,
.health-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--spacing-xl);
}

.chart-card {
  background: white;
  border-radius: 12px;
  padding: var(--spacing-xl);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.chart-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--gray-300);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-lg);
}

.chart-title {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.chart-subtitle {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 0.875rem;
  color: var(--gray-500);
  font-weight: 400;
  line-height: 1.4;
}

.chart-expand-btn {
  width: 36px;
  height: 36px;
  background: var(--gray-50);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.chart-expand-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.chart-expand-btn .material-icons {
  font-size: 20px;
  color: var(--gray-700);
}

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

/* Loading Overlay */
.loading-overlay,
.health-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--spacing-lg);
  z-index: 9999;
}

.loading-overlay.active,
.health-loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: 'LINE Seed Sans TH', sans-serif;
  font-size: 1rem;
  color: var(--gray-700);
  font-weight: 500;
}

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

  .stats-grid,
  .health-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .charts-row,
  .health-charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .health-data-page .page-title {
    font-size: 1.5rem;
  }

  .health-data-page .page-subtitle {
    font-size: 0.9375rem;
  }

  .filters-grid,
  .health-filters-grid {
    grid-template-columns: 1fr;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
  }

  .stats-grid,
  .health-stats-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .stat-value {
    font-size: 2rem;
  }

  .chart-container {
    height: 280px;
  }

  .chart-title {
    font-size: 1rem;
  }
}
