:root {
  --primary: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Vazirmatn", sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

.app-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 2rem;
}

/* Header */
.header {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

.header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}
.date-display {
  font-size: 0.9rem;
  opacity: 0.9;
}
.week-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: none;
  border-radius: 0.75rem;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tab.active {
  background: var(--primary);
  color: white;
}

/* Tab Content */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards */
.card,
.today-summary,
.next-meal-section,
.section-header {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.section-header h2 {
  font-size: 1.1rem;
}

/* Quick Stats */
.day-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.day-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.stat-card {
  background: var(--bg-dark);
  padding: 0.75rem;
  border-radius: 0.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-icon {
  font-size: 1.25rem;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--primary);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Skip Section */
.skip-section {
  margin-bottom: 1rem;
}

/* Next Meal */
.next-meal-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}
.next-meal-card {
  background: var(--bg-dark);
  border-radius: 0.75rem;
  padding: 1rem;
  border-right: 4px solid var(--warning);
}

/* Progress */
.progress-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
  min-width: 100px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #16a34a);
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

.calories-badge {
  background: var(--bg-dark);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

/* Rest Day */
.rest-day-card {
  background: linear-gradient(135deg, #1e3a5f, #1e293b);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
}
.rest-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}
.rest-day-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}
.rest-day-card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.rest-day-card ul {
  list-style: none;
  text-align: right;
}
.rest-day-card li {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-dark);
  border-radius: 0.5rem;
  font-size: 0.9rem;
}

/* Exercise List */
.exercises-list,
.meals-list,
.supplements-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.exercise-card,
.meal-card,
.supplement-card {
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1rem;
  border-right: 4px solid var(--primary);
  transition: all 0.2s;
}

.exercise-card.completed,
.meal-card.completed {
  border-right-color: var(--success);
  opacity: 0.6;
}
.exercise-card.current,
.meal-card.current {
  border-right-color: var(--warning);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

.exercise-name,
.meal-name,
.supplement-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.exercise-muscle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.exercise-details,
.meal-items,
.supplement-times {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.exercise-detail {
  background: var(--bg-dark);
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  display: inline-block;
  margin-left: 0.5rem;
}

.exercise-tips {
  color: var(--text-secondary);
  font-size: 0.85rem;
  background: var(--bg-dark);
  padding: 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

/* Meal Items */
.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.meal-time {
  background: var(--bg-dark);
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
}
.meal-calories {
  color: var(--success);
  font-size: 0.8rem;
}

.meal-item,
.supplement-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg-dark);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}
.meal-item:active,
.supplement-slot:active {
  transform: scale(0.98);
}

.meal-item.checked {
  opacity: 0.5;
}
.meal-item.checked .item-name {
  text-decoration: line-through;
}
.meal-item.skipped {
  opacity: 0.4;
  border: 1px solid var(--danger);
}

.supplement-slot.taken {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--success);
}

.item-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.item-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Supplements */
.supplement-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.supplement-icon {
  font-size: 1.5rem;
}
.supplement-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.weight-form {
  display: flex;
  gap: 0.5rem;
}
.weight-form input {
  flex: 1;
}

/* Rating Buttons */
.rating-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.rating-buttons button {
  width: 50px;
  height: 50px;
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg-dark);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}
.rating-buttons button.selected {
  border-color: var(--primary);
  background: var(--primary);
  transform: scale(1.1);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.stat-box {
  background: var(--bg-dark);
  padding: 1rem;
  border-radius: 0.75rem;
  text-align: center;
}
.stat-box-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}
.stat-box-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.weight-history {
  margin-bottom: 1rem;
}
.weight-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}
.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}
.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
}
.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}
.btn-full {
  width: 100%;
}
.btn-group {
  display: flex;
  gap: 0.5rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 1rem;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-large {
  max-width: 500px;
}
.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.modal-header h2 {
  font-size: 1.25rem;
}
.modal-body {
  padding: 1.25rem;
}
.modal-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Score */
.score-display {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-dark);
  border-radius: 1rem;
  margin-bottom: 1rem;
}
.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
}
.score-value {
  font-size: 2rem;
  font-weight: bold;
}

.recommendations-list {
  list-style: none;
}
.recommendations-list li {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-dark);
  border-radius: 0.5rem;
  border-right: 3px solid var(--warning);
  font-size: 0.9rem;
}

/* Skipped */
.today-summary.skipped {
  background: linear-gradient(135deg, #7f1d1d, #1e293b);
}
.skipped-badge {
  background: var(--danger);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  text-align: center;
  margin-top: 1rem;
}

/* Canvas */
#weightChart {
  width: 100%;
  border-radius: 0.5rem;
  background: var(--bg-dark);
}

/* Text */
.text-muted {
  color: var(--text-muted);
}
.text-success {
  color: var(--success);
}
