* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: max-width 0.3s ease;
}

/* Expand container when dashboard is active */
.container.dashboard-active {
  max-width: 1200px;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

header h1 {
  font-size: 2em;
  margin-bottom: 10px;
}

header p {
  opacity: 0.9;
  margin-bottom: 20px;
}

main {
  padding: 30px;
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  margin-bottom: 30px;
  border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
  flex: 1;
  padding: 15px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn:hover {
  color: #667eea;
  transform: none;
}

.tab-btn.active {
  color: #667eea;
  border-bottom-color: #667eea;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.1) 100%
  );
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Dashboard Form */
.dashboard-form {
  background: #f8f9fa;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
}

.dashboard-form .form-group {
  max-width: 400px;
  margin: 0 auto 20px auto;
}

.dashboard-form button {
  max-width: 300px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

input:focus {
  outline: none;
  border-color: #667eea;
}

button {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

button:hover {
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

.result,
.history {
  margin-top: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
}

.result h2,
.history h2 {
  margin-bottom: 15px;
  color: #333;
}

/* History Header */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

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

.history-controls select {
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  font-size: 14px;
}

.export-btn,
.load-more-btn {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.export-btn:hover,
.load-more-btn:hover {
  background: #5a67d8;
}

/* Statistics Cards */
.history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: white;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-value {
  font-size: 1.8em;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.9em;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chart Container */
.chart-container {
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Chart Legend */
.chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 25px;
  padding: 15px;
  background: white;
  border-radius: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.legend-color.underweight {
  background: #3498db;
}

.legend-color.normal {
  background: #2ecc71;
}

.legend-color.overweight {
  background: #f39c12;
}

.legend-color.obese {
  background: #e74c3c;
}

/* History Details */
.history-details {
  background: white;
  padding: 20px;
  border-radius: 8px;
}

.history-details h3 {
  margin-bottom: 15px;
  color: #333;
  font-size: 1.2em;
}

.load-more-btn {
  width: 100%;
  margin-top: 15px;
  padding: 12px;
}

.bmi-value,
.bmi-category {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background: white;
  border-radius: 8px;
}

.value {
  font-size: 2em;
  font-weight: bold;
  color: #667eea;
}

.category-badge {
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
}

.category-underweight {
  background: #3498db;
  color: white;
}

.category-normal {
  background: #2ecc71;
  color: white;
}

.category-overweight {
  background: #f39c12;
  color: white;
}

.category-obese {
  background: #e74c3c;
  color: white;
}

#historyChart {
  margin: 20px 0;
}

#historyList {
  margin-top: 20px;
}

.history-item {
  padding: 10px;
  margin-bottom: 8px;
  background: white;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.error {
  padding: 15px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  color: #c33;
  margin-top: 20px;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #667eea;
  font-weight: 600;
}

.hidden {
  display: none;
}

footer {
  background: #f8f9fa;
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

@media (max-width: 768px) {
  .container {
    border-radius: 0;
  }

  header h1 {
    font-size: 1.5em;
  }

  main {
    padding: 20px;
  }
}

/* Enhanced History List Styles */
#historyList {
  margin-top: 20px;
}

.history-item {
  padding: 15px;
  margin-bottom: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 15px;
  align-items: center;
  border-left: 4px solid #667eea;
  transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-date strong {
  color: #333;
  font-size: 14px;
}

.history-date small {
  color: #666;
  font-size: 12px;
}

.history-metrics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.history-metrics span {
  color: #555;
}

.history-metrics strong {
  color: #667eea;
}

.history-category {
  display: flex;
  justify-content: flex-end;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
  .history-item {
    grid-template-columns: 1fr;
    gap: 10px;
    text-align: left;
  }

  .history-category {
    justify-content: flex-start;
  }

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

  .chart-legend {
    flex-direction: column;
    gap: 10px;
  }

  .history-header {
    flex-direction: column;
    align-items: stretch;
  }

  .history-controls {
    justify-content: space-between;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 1.5em;
  }
}
