/* Modern and Clean Styles for Health Tracker */
:root {
  /* Health-focused color palette */
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --secondary: #2196F3;
  --accent: #FF9800;
  --light-gray: #f5f7fa;
  --medium-gray: #e0e0e0;
  --dark-gray: #616161;
  --text-dark: #212121;
  --white: #ffffff;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--light-gray);
  background-image: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header Styles */
.main-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  padding: 2rem 0;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.main-header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  transform: rotate(30deg);
}

.header-content {
  position: relative;
  z-index: 2;
}

.main-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.main-header p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Main Content */
.main-content {
  padding: 2rem 0 4rem;
}

/* Grid Layout for Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

/* Card Styles */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--medium-gray);
}

.card h2 {
  color: var(--primary-dark);
  font-size: 1.4rem;
  font-weight: 600;
}

/* Stats Summary */
.stats-summary {
  grid-column: span 2;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  background: var(--light-gray);
  border-radius: 10px;
  gap: 0.75rem;
  text-align: center;
  min-height: 140px;
  justify-content: center;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.current-weight-icon {
  background: linear-gradient(135deg, #81C784 0%, #4CAF50 100%);
}

.target-weight-icon {
  background: linear-gradient(135deg, #64B5F6 0%, #2196F3 100%);
}

.difference-icon {
  background: linear-gradient(135deg, #FFB74D 0%, #FF9800 100%);
}

.progress-icon {
  background: linear-gradient(135deg, #BA68C8 0%, #9C27B0 100%);
}

.stat-details {
  flex-grow: 1;
}

.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  color: var(--dark-gray);
  margin-top: 0.25rem;
}

/* Chart Section */
.chart-section {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex-grow: 1;
  min-height: 300px;
}

#weight-chart {
  width: 100% !important;
  height: 100% !important;
}

/* Quick Add Form */
.quick-add form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-weight: 600;
  color: var(--dark-gray);
  font-size: 0.95rem;
}

.input-group input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--medium-gray);
  border-radius: 10px;
  font-size: 1.1rem;
  transition: var(--transition);
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.btn-primary, .btn-secondary {
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
  background: var(--light-gray);
  color: var(--dark-gray);
}

.btn-secondary:hover {
  background: var(--medium-gray);
}

/* Weight History */
.weight-history {
  grid-column: span 2;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--medium-gray);
}

th {
  background-color: var(--light-gray);
  font-weight: 600;
  color: var(--dark-gray);
}

tr:hover {
  background-color: rgba(76, 175, 80, 0.05);
}

.delete-btn {
  background: #f44336;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition);
  min-height: 44px; /* iOS recommended touch target size */
}

.delete-btn:hover {
  background: #d32f2f;
  transform: scale(1.05);
}

/* Tips Section */
.tips-section {
  margin-top: 2.5rem;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.tip-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}

.tip-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.tip-card h3 {
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.tip-card p {
  color: var(--dark-gray);
  line-height: 1.7;
  font-size: 1rem;
}

/* Footer */
.main-footer {
  background: var(--text-dark);
  color: var(--white);
  text-align: center;
  padding: 2rem 0;
  margin-top: 3rem;
}

/* iPhone and Mobile Specific Styles */
@media screen and (max-width: 414px) {
  .container {
    padding: 0 15px;
  }

  .main-header h1 {
    font-size: 2rem;
  }

  .main-header p {
    font-size: 1rem;
  }

  .card {
    padding: 1.25rem;
  }

  .dashboard-grid {
    gap: 1.25rem;
  }

  .stats-summary,
  .chart-section,
  .weight-history {
    grid-column: span 1;
  }

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

  .stat-item {
    padding: 1rem;
    min-height: 120px;
  }

  .stat-icon {
    width: 50px;
    height: 50px;
  }

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

  .stat-label {
    font-size: 0.85rem;
  }

  .chart-container {
    min-height: 250px;
  }

  .input-group input {
    padding: 1rem;
    font-size: 1rem;
  }

  .btn-primary, .btn-secondary {
    padding: 1rem 1.25rem;
    font-size: 1rem;
  }

  th, td {
    padding: 0.875rem 0.75rem;
    font-size: 0.9rem;
  }

  .tip-card {
    padding: 1.25rem;
  }

  .tip-card h3 {
    font-size: 1.15rem;
  }

  .tip-card p {
    font-size: 0.95rem;
  }
}

/* iPhone SE specific */
@media screen and (max-width: 320px) {
  .stat-item {
    min-height: 110px;
  }

  .stat-icon {
    width: 45px;
    height: 45px;
  }

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

  .stat-label {
    font-size: 0.8rem;
  }

  .input-group input {
    padding: 0.875rem;
  }

  .btn-primary, .btn-secondary {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
  }
}

/* iPhone 12 Pro Max and larger mobile screens */
@media screen and (min-width: 415px) and (max-width: 768px) {
  .stats-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .stat-item {
    min-height: 130px;
    padding: 1.1rem;
  }

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

  .chart-container {
    min-height: 280px;
  }
}

/* iPad and larger tablets */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .stats-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .stat-item {
    min-height: 140px;
  }

  .chart-container {
    min-height: 320px;
  }
}

/* Touch targets optimization for mobile */
@media (max-width: 768px) {
  .delete-btn,
  .btn-primary,
  .btn-secondary {
    min-height: 48px;
    padding: 0.875rem 1.25rem;
  }

  .input-group input {
    min-height: 48px;
  }

  .stat-item {
    padding: 1.25rem;
  }

  /* Prevent zoom on input focus on iOS */
  input[type="date"] {
    font-size: 16px; /* Prevents iOS Safari zoom */
  }
}

/* Landscape orientation adjustments */
@media screen and (max-height: 600px) and (orientation: landscape) {
  .main-header {
    padding: 1.5rem 0;
  }

  .main-header h1 {
    font-size: 1.8rem;
  }

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

  .chart-container {
    min-height: 200px;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.5s ease-out;
}

/* Focus styles for accessibility */
input:focus,
button:focus {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

/* Remove default appearance for date input on iOS */
input[type="date"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
  background-color: white;
}

input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-calendar-picker-indicator {
  -webkit-appearance: none;
  display: none;
}

/* Auth Section Styles */
.header-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.auth-buttons {
  display: flex;
  gap: 0.5rem;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-email {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.btn-auth {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: transparent;
  color: white;
  cursor: pointer;
  transition: var(--transition);
}

.btn-auth:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-auth-primary {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

.btn-auth-primary:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 400px;
  position: relative;
  animation: modalSlideIn 0.3s ease-out;
}

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

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--dark-gray);
  line-height: 1;
  padding: 0.25rem;
}

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

.modal-content h2 {
  margin-bottom: 1.5rem;
  color: var(--primary-dark);
  text-align: center;
}

.modal-content .input-group {
  margin-bottom: 1rem;
}

.error-message {
  color: #f44336;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: #ffebee;
  border-radius: 6px;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--dark-gray);
  font-size: 0.9rem;
}

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

.auth-switch a:hover {
  text-decoration: underline;
}

/* Sync Indicator */
.sync-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--white);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  z-index: 100;
}

.sync-indicator .sync-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.sync-indicator.syncing .sync-icon {
  background: var(--accent);
  animation: pulse 1s infinite;
}

.sync-indicator.offline .sync-icon {
  background: var(--dark-gray);
}

.sync-indicator.synced .sync-icon {
  background: var(--primary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Onboarding Styles */
.onboarding-modal .modal-content {
  max-width: 500px;
  padding: 0;
  overflow: hidden;
}

.onboarding-content-wrapper {
  padding: 0;
}

.onboarding-progress-bar {
  height: 4px;
  background: var(--medium-gray);
  width: 100%;
}

.onboarding-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #81C784 100%);
  width: 33%;
  transition: width 0.3s ease;
}

#onboarding-content {
  padding: 2rem;
}

.onboarding-step {
  text-align: center;
}

.onboarding-step h2 {
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.onboarding-subtitle {
  color: var(--dark-gray);
  margin-bottom: 2rem;
}

.onboarding-field {
  margin-bottom: 1.5rem;
  text-align: left;
}

.onboarding-field label {
  display: block;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 0.75rem;
}

.gender-buttons {
  display: flex;
  gap: 1rem;
}

.gender-btn {
  flex: 1;
  padding: 1.25rem;
  border: 2px solid var(--medium-gray);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.gender-btn:hover {
  border-color: var(--primary);
}

.gender-btn.active {
  border-color: var(--primary);
  background: rgba(76, 175, 80, 0.1);
}

.gender-icon {
  font-size: 2rem;
}

.onboarding-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--medium-gray);
  border-radius: 4px;
  outline: none;
}

.onboarding-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.onboarding-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.onboarding-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--light-gray);
  border-radius: 12px;
}

.onboarding-stat-item {
  text-align: center;
}

.onboarding-stat-item .stat-number {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
}

.onboarding-stat-item .stat-desc {
  font-size: 0.85rem;
  color: var(--dark-gray);
}

.activity-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.activity-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid var(--medium-gray);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.activity-btn:hover {
  border-color: var(--primary);
}

.activity-btn.active {
  border-color: var(--primary);
  background: rgba(76, 175, 80, 0.1);
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-title {
  font-weight: 600;
  display: block;
}

.activity-desc {
  font-size: 0.85rem;
  color: var(--dark-gray);
}

.onboarding-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.onboarding-buttons .btn-secondary {
  flex: 0 0 auto;
}

.onboarding-buttons .btn-primary {
  flex: 1;
}

.onboarding-next,
.onboarding-submit {
  width: 100%;
  margin-top: 1.5rem;
}

.onboarding-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Onboarding Result */
.onboarding-result {
  text-align: center;
}

.result-header {
  margin-bottom: 1.5rem;
}

.result-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.result-header h2 {
  color: var(--primary-dark);
  font-size: 1.25rem;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.result-stat {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  border-radius: 12px;
  min-width: 80px;
}

.result-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.result-stat-label {
  font-size: 0.75rem;
  color: var(--dark-gray);
}

.result-analysis {
  background: var(--light-gray);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  text-align: left;
}

.result-tips {
  text-align: left;
  margin-bottom: 1rem;
}

.result-tips h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--primary-dark);
}

.result-tips ul {
  margin: 0;
  padding-left: 1.25rem;
}

.result-tips li {
  margin-bottom: 0.5rem;
  color: var(--dark-gray);
  line-height: 1.4;
}

.result-motivation {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  text-align: left;
}

.result-motivation p {
  margin: 0;
  color: #E65100;
}

.result-target {
  margin-bottom: 1.5rem;
  color: var(--dark-gray);
}

.onboarding-finish {
  width: 100%;
}

/* Mobile onboarding styles */
@media screen and (max-width: 414px) {
  #onboarding-content {
    padding: 1.5rem;
  }

  .gender-buttons {
    flex-direction: column;
  }

  .onboarding-stats {
    gap: 1rem;
  }

  .onboarding-stat-item .stat-number {
    font-size: 1.5rem;
  }

  .result-stats {
    flex-wrap: wrap;
  }
}

/* Admin Panel Styles */
.admin-panel {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-left: 4px solid #9C27B0;
}

.admin-panel h2 {
  color: #9C27B0;
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
}

.admin-panel h3 {
  color: var(--dark-gray);
  margin: 1.5rem 0 1rem;
  font-size: 1.1rem;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.admin-stat {
  background: linear-gradient(135deg, #E1BEE7 0%, #CE93D8 100%);
  padding: 1.25rem;
  border-radius: 10px;
  text-align: center;
}

.admin-stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #4A148C;
}

.admin-stat-label {
  display: block;
  font-size: 0.85rem;
  color: #6A1B9A;
  margin-top: 0.25rem;
}

.admin-users-section {
  margin-top: 1.5rem;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-users-table th {
  background: #F3E5F5;
  color: #6A1B9A;
  font-weight: 600;
  padding: 0.75rem;
  text-align: left;
}

.admin-users-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--medium-gray);
}

.admin-users-table tr:hover {
  background: #FCE4EC;
}

.admin-badge {
  background: #9C27B0;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
}

/* Mobile auth styles */
@media screen and (max-width: 414px) {
  .header-top {
    justify-content: center;
  }

  .btn-auth {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }

  .user-section {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-content {
    padding: 1.5rem;
  }

  .sync-indicator {
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

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

  .admin-stat-value {
    font-size: 1.5rem;
  }

  .admin-users-table {
    font-size: 0.8rem;
  }

  .admin-users-table th,
  .admin-users-table td {
    padding: 0.5rem;
  }
}