/* Base Styles */
:root {
  --primary-color: #6c5ce7;
  --secondary-color: #a29bfe;
  --accent-color: #fd79a8;
  --background-color: #f9f9f9;
  --card-color: #ffffff;
  --text-color: #333333;
  --text-light: #666666;
  --success-color: #00b894;
  --error-color: #d63031;
  --neutral-color: #636e72;
  --border-color: #e0e0e0;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* Button Styles */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Vazirmatn', sans-serif;
}

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

.btn-primary:hover {
  background-color: #5b4dc7;
  transform: translateY(-2px);
}

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

.btn-secondary:hover {
  background-color: #8f89e2;
  transform: translateY(-2px);
}

.btn-back {
  background-color: transparent;
  color: var(--text-color);
  padding: 8px 16px;
}

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

.btn-block {
  width: 100%;
  margin: 10px 0;
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background-color: rgba(108, 92, 231, 0.1);
}

.btn-guest {
  background-color: transparent;
  border: 2px solid var(--neutral-color);
  color: var(--neutral-color);
}

.btn-guest:hover {
  background-color: rgba(99, 110, 114, 0.1);
}

/* Header Styles */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}

.user-name {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-color);
}

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

.page-title {
  text-align: center;
  margin-bottom: 40px;
  color: var(--primary-color);
  font-size: 2.5rem;
  position: relative;
  animation: fadeInDown 0.8s ease-out;
}

.page-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 50%;
  transform: translateX(50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(to left, var(--primary-color), var(--secondary-color));
  border-radius: 2px;
}

/* Page Transitions */
.page {
  opacity: 1;
  transition: opacity 0.5s ease;
  animation: fadeIn 0.5s ease-out;
}

.hidden {
  display: none;
  opacity: 0;
}

/* Login and Signup Pages */
.auth-container {
  max-width: 450px;
  margin: 0 auto;
  padding: 30px;
  background-color: var(--card-color);
  border-radius: 15px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.6s ease-out;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-title {
  color: var(--primary-color);
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.auth-subtitle {
  color: var(--text-light);
  font-size: 1rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

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

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

.form-group input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  font-family: 'Vazirmatn', sans-serif;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.password-input-container {
  position: relative;
}

.toggle-password {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 5px;
}

.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.remember-me, .terms-agreement {
  display: flex;
  align-items: center;
  gap: 5px;
}

.forgot-password {
  color: var(--primary-color);
  text-decoration: none;
}

.forgot-password:hover {
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: var(--text-light);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-color);
}

.auth-divider span {
  padding: 0 10px;
}

/* Puzzle List Page */
.puzzles-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.puzzle-card {
  background-color: var(--card-color);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  animation: fadeInUp 0.6s ease-out;
}

.puzzle-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.puzzle-card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.puzzle-card-content {
  padding: 20px;
}

.puzzle-card-title {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: var(--text-color);
}

.puzzle-card-points {
  font-size: 0.9rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 5px;
}

.puzzle-status {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

.status-correct {
  background-color: var(--success-color);
}

.status-incorrect {
  background-color: var(--error-color);
}

.status-default {
  background-color: var(--neutral-color);
}

/* Puzzle Page */
.puzzle-content {
  background-color: var(--card-color);
  border-radius: 15px;
  padding: 30px;
  box-shadow: var(--shadow);
  max-width: 800px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease-out;
}

#puzzle-title {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: var(--primary-color);
}

.puzzle-text {
  margin-bottom: 25px;
  font-size: 1.1rem;
  line-height: 1.7;
}

.puzzle-image-container {
  margin-bottom: 25px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#puzzle-image {
  width: 100%;
  display: block;
}

.answer-container {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

#answer-input {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  font-size: 1rem;
  transition: var(--transition);
  font-family: 'Vazirmatn', sans-serif;
  text-align: right;
}

#answer-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.puzzle-points {
  background-color: var(--accent-color);
  color: white;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Leaderboard Page */
.leaderboard-container {
  background-color: var(--card-color);
  border-radius: 15px;
  padding: 30px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.6s ease-out;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 15px;
  text-align: right;
  border-bottom: 1px solid #eee;
}

.leaderboard-table th {
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.leaderboard-table tbody tr {
  transition: var(--transition);
}

.leaderboard-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.rank {
  font-weight: 700;
  width: 60px;
}

.rank-1, .rank-2, .rank-3 {
  font-size: 1.2rem;
}

.rank-1 {
  color: gold;
}

.rank-2 {
  color: silver;
}

.rank-3 {
  color: #cd7f32; /* bronze */
}

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

.player-score {
  font-weight: 700;
  color: var(--primary-color);
}

/* Logout Button */
.logout-container {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

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

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

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

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .puzzles-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
  
  .puzzle-content {
    padding: 20px;
  }
  
  .answer-container {
    flex-direction: column;
  }
  
  #answer-input {
    width: 100%;
  }
  
  .btn-primary {
    width: 100%;
  }
  
  .auth-container {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .leaderboard-link {
    align-self: flex-end;
  }
  
  .puzzles-container {
    grid-template-columns: 1fr;
  }
  
  .form-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}