/* CSS Custom Properties for theming */
:root {
  --primary-color: #8B5FBF;
  --secondary-color: #90C695;
  --accent-color: #E8D5B7;
  --background-color: #F8F6F3;
  --surface-color: #FFFFFF;
  --text-primary: #2D2D2D;
  --text-secondary: #666666;
  --border-color: #E0E0E0;
  --success-color: #4CAF50;
  --warning-color: #FF9800;
  --error-color: #F44336;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Dark theme */
[data-theme="dark"] {
  --background-color: #1A1A1A;
  --surface-color: #2D2D2D;
  --text-primary: #FFFFFF;
  --text-secondary: #CCCCCC;
  --border-color: #404040;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Header */
.header {
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  max-width: 100%;
  min-height: 80px;
}

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

.logo-image {
  height: 60px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo h1 {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 700;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.language-selector {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.theme-toggle {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.theme-toggle:hover {
  background-color: var(--accent-color);
  transform: scale(1.1);
}

/* Main app container */
.app-container {
  margin-top: 80px;
  margin-bottom: 80px;
  min-height: calc(100vh - 160px);
  padding: 1rem;
}

/* Screen management */
.screen {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
  display: block;
}

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

/* Welcome screen */
.welcome-content {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 500px;
  margin: 0 auto;
}

.hero-section {
  margin-bottom: 2rem;
}

.character {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.welcome-content h2 {
  color: var(--primary-color);
  font-size: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.welcome-content p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.motivation-quote {
  background-color: var(--accent-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.motivation-quote p {
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
}

/* Buttons */
.primary-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 300px;
}

.primary-button:hover {
  background-color: #7A4FA3;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.secondary-button {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.secondary-button:hover {
  background-color: #7BB97F;
  transform: translateY(-2px);
}

/* Quiz screen */
.quiz-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

.quiz-content h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.quiz-form {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

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

.question-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.question-group input,
.question-group select {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background-color: var(--surface-color);
  color: var(--text-primary);
}

.question-group input:focus,
.question-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(139, 95, 191, 0.1);
}

.profile-result {
  background-color: var(--accent-color);
  border-radius: 16px;
  padding: 2rem;
  margin-top: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.profile-result h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.profile-result p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.adaptive-profile-info {
  background-color: var(--surface-color);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  border-left: 4px solid var(--primary-color);
  text-align: left;
}

.adaptive-profile-info h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.adaptive-profile-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Challenge screen */
.challenge-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

.challenge-content h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.challenge-content p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.challenge-motivation {
  background-color: var(--accent-color);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0 2rem 0;
  text-align: center;
  border-left: 4px solid var(--primary-color);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.challenge-day {
  background-color: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.challenge-day:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.challenge-day.available {
  border-color: var(--primary-color);
  background-color: var(--accent-color);
}

.challenge-day.completed {
  border-color: var(--success-color);
  background-color: #E8F5E8;
}

.challenge-day.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.challenge-day .day-number {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.challenge-day .day-task {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.challenge-day .completion-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background-color: var(--success-color);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.challenge-progress {
  text-align: center;
}

.progress-bar {
  background-color: var(--border-color);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  background-color: var(--success-color);
  height: 100%;
  transition: width 0.3s ease;
  width: 0%;
}

/* Meal plan screen */
.meal-plan-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

.meal-plan-content h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.fasting-guide {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.fasting-guide h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.fasting-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.fasting-option {
  background-color: var(--accent-color);
  border-radius: 12px;
  padding: 1.5rem;
}

.fasting-option h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.meal-suggestions {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.meal-suggestions h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.meal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.meal-item {
  background-color: var(--accent-color);
  border-radius: 12px;
  padding: 1.5rem;
  border-left: 4px solid var(--secondary-color);
}

.meal-item h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.meal-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.meal-item .meal-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.meal-benefit {
  background-color: var(--secondary-color);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 16px;
  font-size: 0.8rem;
}

/* Recipes screen */
.recipes-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

.recipes-content h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.recipes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.recipe-card {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--secondary-color);
}

.recipe-card h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.recipe-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.recipe-ingredients {
  margin-bottom: 1rem;
}

.recipe-ingredients h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.recipe-ingredients ul {
  list-style: none;
  padding-left: 0;
}

.recipe-ingredients li {
  padding: 0.2rem 0;
  color: var(--text-secondary);
  position: relative;
  padding-left: 1rem;
}

.recipe-ingredients li::before {
  content: "•";
  color: var(--secondary-color);
  position: absolute;
  left: 0;
}

.recipe-instructions h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.recipe-instructions p {
  color: var(--text-secondary);
  line-height: 1.5;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.recipe-tag {
  background-color: var(--accent-color);
  color: var(--primary-color);
  padding: 0.3rem 0.8rem;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Motivation screen */
.motivation-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

.motivation-content h2 {
  color: var(--primary-color);
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.motivation-card {
  background-color: var(--surface-color);
  border-radius: 20px;
  padding: 3rem 2rem;
  box-shadow: var(--shadow);
  border: 2px solid var(--accent-color);
}

.motivation-emoji {
  font-size: 3rem;
  margin-bottom: 1.5rem;
}

.motivation-quote {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--primary-color);
  margin-bottom: 2rem;
  font-style: italic;
  line-height: 1.5;
}

/* Diary screen */
.diary-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

.diary-content h2 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

.diary-entry {
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.date-section {
  margin-bottom: 1.5rem;
}

.date-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.date-section input {
  width: 100%;
  max-width: 200px;
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--surface-color);
  color: var(--text-primary);
}

.weight-mood-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.weight-input label,
.mood-input label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.weight-input input {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--surface-color);
  color: var(--text-primary);
}

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

.mood-btn {
  background-color: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mood-btn:hover {
  border-color: var(--primary-color);
  transform: scale(1.1);
}

.mood-btn.selected {
  border-color: var(--primary-color);
  background-color: var(--accent-color);
}

.notes-section {
  margin-bottom: 1.5rem;
}

.notes-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.notes-section textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--surface-color);
  color: var(--text-primary);
  resize: vertical;
  font-family: inherit;
}

.diary-history h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.diary-entries-list {
  display: grid;
  gap: 1rem;
}

.diary-entry-item {
  background-color: var(--surface-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--secondary-color);
}

.diary-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.diary-entry-date {
  font-weight: 600;
  color: var(--primary-color);
}

.diary-entry-mood {
  font-size: 1.5rem;
}

.diary-entry-details {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.diary-entry-notes {
  color: var(--text-primary);
  line-height: 1.5;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--surface-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0.2rem;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow-x: auto;
}

.nav-item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.3s ease;
  border-radius: 8px;
  flex: 1;
  min-width: 60px;
  max-width: 70px;
}

.nav-item:hover {
  background-color: var(--accent-color);
}

.nav-item.active {
  background-color: var(--primary-color);
  color: white;
}

.nav-icon {
  font-size: 1.1rem;
}

.nav-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

.nav-item.active .nav-label {
  color: white;
}

/* Utility classes */
.hidden {
  display: none !important;
}

.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--surface-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
  text-align: center;
  z-index: 2000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.success-message {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--success-color);
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 2000;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-100%); }
  to { transform: translateX(-50%) translateY(0); }
}

/* Responsive design */
@media (max-width: 768px) {
  .header-content {
    padding: 0.8rem;
  }
  
  .logo h1 {
    font-size: 1.3rem;
  }
  
  .app-container {
    padding: 0.5rem;
    margin-top: 70px;
  }
  
  .challenge-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .weight-mood-section {
    grid-template-columns: 1fr;
  }
  
  .fasting-options {
    grid-template-columns: 1fr;
  }
  
  .meal-list,
  .recipes-list {
    grid-template-columns: 1fr;
  }
  
  .nav-label {
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  .welcome-content,
  .motivation-content {
    padding: 1rem 0.5rem;
  }
  
  .character {
    font-size: 3rem;
  }
  
  .welcome-content h2 {
    font-size: 1.6rem;
  }
  
  .motivation-quote {
    font-size: 1.1rem;
  }
  
  .quiz-form,
  .diary-entry {
    padding: 1.5rem;
  }
  
  .motivation-card {
    padding: 2rem 1.5rem;
  }
}
