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

:root {
  --primary-color: #2196F3;
  --success-color: #4CAF50;
  --danger-color: #f44336;
  --secondary-color: #757575;
  --bg-color: #f5f5f5;
  --card-bg: #ffffff;
  --text-color: #212121;
  --border-color: #e0e0e0;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

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

/* Screen Management */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  z-index: 10;
  position: relative;
  height: auto;
}

/* Login Screen */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color) 0%, #1976D2 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-card h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: var(--primary-color);
}

.login-card .subtitle {
  color: var(--secondary-color);
  margin-bottom: 30px;
  font-size: 1.1rem;
}

/* Training Screen */
#trainingScreen {
  min-height: 100vh;
  padding-bottom: 40px;
}

.header {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.session-info {
  display: flex;
  gap: 15px;
  align-items: center;
}

.code-badge {
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9rem;
}

/* Exercises List */
.exercises-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
  min-height: 100px;
}

.exercise-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.exercise-info {
  flex: 1;
}

.exercise-name {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-color);
}

.exercise-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

.exercise-detail {
  display: flex;
  flex-direction: column;
}

.exercise-detail-label {
  font-weight: bold;
  color: var(--text-color);
}

.exercise-actions {
  display: flex;
  gap: 10px;
  margin-left: 20px;
}

.btn-play {
  background: var(--success-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
  font-size: 1rem;
}

.btn-play:hover {
  background: #45a049;
}

.btn-edit {
  background: #FF9800;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
  font-size: 1rem;
}

.btn-edit:hover {
  background: #F57C00;
}

.btn-delete {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-delete:hover {
  background: #da190b;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--secondary-color);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

/* Add Exercise Button */
.btn-add-exercise {
  width: 100%;
  padding: 15px;
  font-size: 1.1rem;
  display: block;
}

/* Buttons */
.btn {
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  font-size: 1rem;
  background: var(--secondary-color);
  color: white;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: #1565C0;
}

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

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  background: #45a049;
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #616161;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* Input Fields */
.input-field {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 15px;
  transition: border-color 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  margin-top: -10px;
}

.checkbox-input {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.checkbox-label {
  cursor: pointer;
  user-select: none;
  color: var(--text-color);
  font-size: 0.95rem;
}

.checkbox-label:hover {
  color: var(--primary-color);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--card-bg);
  padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  animation: slideUp 0.3s;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--secondary-color);
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: var(--text-color);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
  flex-shrink: 0;
}

.form-actions .btn {
  flex: 1;
}

/* Weights Container */
.weights-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 15px;
}

.weight-reps-pair {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.weight-reps-pair:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.weight-input,
.reps-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.weight-input:focus,
.reps-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.weight-input:disabled,
.reps-input:disabled {
  background-color: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Weights List in Exercise Card */
.weights-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.weight-reps-item {
  padding: 4px 0;
  line-height: 1.4;
}

/* Timer Modal */
.timer-modal {
  max-width: 300px;
  padding: 40px 20px;
  text-align: center;
}

.timer-display {
  margin-bottom: 30px;
}

#timerValue {
  font-size: 4rem;
  font-weight: bold;
  color: var(--primary-color);
  display: block;
  line-height: 1.2;
}

#timerExerciseName {
  font-size: 1.1rem;
  color: var(--secondary-color);
  margin-top: 10px;
  margin-bottom: 0;
}

/* Error Message */
.error-message {
  color: var(--danger-color);
  margin-top: 15px;
  font-size: 0.9rem;
  min-height: 20px;
}

/* Loading State */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    gap: 15px;
  }

  .session-info {
    width: 100%;
    justify-content: space-between;
  }

  .exercise-details {
    grid-template-columns: 1fr;
  }

  .exercise-actions {
    flex-direction: column;
    margin-left: 0;
    margin-top: 15px;
  }

  .exercise-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-card {
    padding: 25px;
  }

  .modal-content {
    width: 95%;
  }
}
