/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4a90e2;
  --primary-dark: #357abd;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #e1e8ed;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 20px;
}

h1 {
  color: var(--primary);
  margin-bottom: 20px;
  font-size: 2rem;
  font-weight: 700;
}

h2 {
  color: var(--text);
  margin-bottom: 20px;
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  color: var(--text);
  margin-bottom: 12px;
  font-size: 1.2rem;
  font-weight: 600;
}

/* Navigation */
nav {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

nav a {
  padding: 10px 20px;
  background: var(--card-bg);
  color: var(--primary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 2px solid var(--primary);
}

nav a:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* App Container */
#app {
  max-width: 1200px;
  margin: 0 auto;
}

/* Info Messages */
.info-message {
  background: #e6f7ff;
  border: 1px solid #91d5ff;
  color: #0050b3;
  padding: 15px;
  border-radius: 8px;
  margin: 20px 0;
}

.tip {
  background: #fff7e6;
  border-left: 4px solid var(--warning);
  padding: 12px;
  margin: 20px 0;
  border-radius: 4px;
  color: #874d00;
}

/* Workouts View */
.workouts-view {
  animation: fadeIn 0.3s ease;
}

.exercise-list {
  display: grid;
  gap: 20px;
  margin-bottom: 30px;
}

.exercise-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.exercise-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.recommendation {
  background: #f0f9ff;
  border-left: 4px solid var(--primary);
  padding: 12px;
  margin: 15px 0;
  border-radius: 4px;
  font-size: 0.95rem;
}

.exercise-form {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  flex-wrap: wrap;
}

.exercise-form input {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.exercise-form input:focus {
  outline: none;
  border-color: var(--primary);
}

.log-btn {
  padding: 10px 20px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.log-btn:hover {
  background: #389e0d;
  transform: scale(1.05);
}

.log-btn:active {
  transform: scale(0.98);
}

.exercise-history {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.history-list {
  font-size: 0.9rem;
  color: var(--text-light);
}

.no-history {
  color: var(--text-light);
  font-style: italic;
  font-size: 0.9rem;
}

.all-exercises {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.exercise-item {
  background: var(--card-bg);
  padding: 15px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.exercise-name {
  font-weight: 600;
}

.exercise-category {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
}

/* Calendar View */
.calendar-view {
  animation: fadeIn 0.3s ease;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.day-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: all 0.3s ease;
  position: relative;
}

.day-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
}

.day-card.today {
  border-color: var(--primary);
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.today-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.day-exercises {
  margin-top: 15px;
}

.rest-day {
  color: var(--text-light);
  font-style: italic;
  text-align: center;
  padding: 10px;
}

.scheduled-exercise {
  background: #f0f9ff;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  border-left: 3px solid var(--primary);
}

/* Graphs View */
.graphs-view {
  animation: fadeIn 0.3s ease;
}

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

.stat-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card h3 {
  color: var(--primary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--text-light);
  font-size: 0.9rem;
}

.stat-value {
  font-weight: 700;
  color: var(--text);
  font-size: 1.1rem;
}

.mini-graph {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  margin-top: 15px;
  padding: 10px;
  background: #f5f7fa;
  border-radius: 6px;
}

.mini-graph .bar {
  flex: 1;
  background: linear-gradient(to top, var(--primary), var(--primary-dark));
  border-radius: 3px 3px 0 0;
  min-height: 10px;
  transition: all 0.3s ease;
}

.mini-graph .bar:hover {
  opacity: 0.7;
}

/* Plan View */
.plan-view {
  animation: fadeIn 0.3s ease;
}

.plan-schedule {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.plan-day {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 150px 100px 1fr;
  gap: 20px;
  align-items: center;
}

.exercise-count {
  background: var(--primary);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.exercise-names {
  color: var(--text-light);
  font-size: 0.95rem;
}

/* Drag and Drop Plan View */
.exercise-library {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.exercise-library h3 {
  margin-bottom: 15px;
  color: var(--primary);
}

.exercise-library .exercise-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.exercise-library .exercise-item {
  cursor: move;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
  border: 2px solid var(--primary);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
  user-select: none;
}

.exercise-library .exercise-item:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.exercise-library .exercise-item:active {
  opacity: 0.5;
}

.plan-day {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
}

.plan-day h3 {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.day-exercises {
  min-height: 60px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 2px dashed var(--border);
  transition: all 0.3s ease;
}

.day-exercises.drag-over {
  background: #e6f7ff;
  border-color: var(--primary);
  border-style: solid;
}

.empty-day {
  text-align: center;
  color: var(--text-light);
  font-style: italic;
  padding: 20px 0;
}

.day-exercise-item {
  background: white;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: move;
  transition: all 0.2s ease;
  user-select: none;
}

.day-exercise-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.day-exercise-item:last-child {
  margin-bottom: 0;
}

.drag-handle {
  color: var(--text-light);
  cursor: grab;
  font-size: 1.2rem;
}

.drag-handle:active {
  cursor: grabbing;
}

.day-exercise-item span {
  flex: 1;
  font-weight: 500;
}

.remove-btn {
  background: var(--danger);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: #d9363e;
  transform: scale(1.1);
}

.save-schedule-btn {
  display: block;
  margin: 30px auto 0;
  padding: 15px 40px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.save-schedule-btn:hover {
  background: #389e0d;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.save-schedule-btn:active {
  transform: translateY(0);
}

/* Coach View */
.coach-view {
  animation: fadeIn 0.3s ease;
}

.advice-card {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 30px;
  border-left: 6px solid var(--primary);
}

.advice-card.success {
  border-left-color: var(--success);
  background: linear-gradient(135deg, #ffffff 0%, #f6ffed 100%);
}

.advice-card.rest {
  border-left-color: var(--warning);
  background: linear-gradient(135deg, #ffffff 0%, #fffbe6 100%);
}

.advice-card.workout {
  border-left-color: var(--primary);
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.advice-message {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 15px;
}

.advice-action {
  display: inline-block;
  padding: 12px 24px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.advice-action:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.progress-analysis {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.progress-status {
  font-size: 1.1rem;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.progress-status.excellent {
  background: #f6ffed;
  border: 2px solid var(--success);
  color: #389e0d;
}

.progress-status.on-track {
  background: #f0f9ff;
  border: 2px solid var(--primary);
  color: #0050b3;
}

.progress-status.needs-attention {
  background: #fff7e6;
  border: 2px solid var(--warning);
  color: #874d00;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.stat-item {
  background: var(--bg);
  padding: 15px;
  border-radius: 8px;
  font-size: 0.95rem;
}

.coach-tips {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.coach-tips ul {
  list-style-position: inside;
  margin-top: 15px;
}

.coach-tips li {
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}

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

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  nav {
    flex-direction: column;
  }

  nav a {
    text-align: center;
  }

  .exercise-form {
    flex-direction: column;
  }

  .exercise-form input {
    width: 100%;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .plan-day {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .all-exercises {
    grid-template-columns: 1fr;
  }
}