/* ════════════════════════════════════════════════════════════════
   PUZZLE PAGE STYLES
   Perfect Chess Academy
   ════════════════════════════════════════════════════════════════ */

/* ============================================
   LAYOUT
   ============================================ */
.puzzle-page {
  display: flex;
  min-height: calc(100vh - 60px);
  background: var(--bg-body);
  padding: 20px;
  gap: 20px;
}

.board-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 700px;
}

.info-panel {
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================
   PUZZLE HEADER
   ============================================ */
.puzzle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 16px;
  padding: 0 8px;
}

.puzzle-title .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-primary);
  font-weight: 600;
}

.puzzle-title h1 {
  font-size: 24px;
  color: var(--text-primary);
  margin: 4px 0 0;
  font-weight: 600;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(234, 88, 12, 0.15));
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.streak-badge i {
  color: #f59e0b;
  font-size: 18px;
}

.streak-badge span {
  color: var(--text-primary);
  font-weight: 600;
}

/* ============================================
   BOARD WRAPPER
   ============================================ */
.board-wrapper {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#board {
  width: 100%;
  height: 100%;
}

.turn-indicator {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-sidebar);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.turn-indicator .color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
}

.turn-indicator .color-dot.white {
  background: #fff;
}

.turn-indicator .color-dot.black {
  background: #333;
}

#turnText {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

/* Puzzle Status Overlay */
.puzzle-status {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(16, 185, 129, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}

.puzzle-status.incorrect {
  background: rgba(239, 68, 68, 0.9);
}

.puzzle-status .status-content {
  text-align: center;
  color: white;
}

.puzzle-status .status-content i {
  font-size: 64px;
  margin-bottom: 12px;
}

.puzzle-status .status-content span {
  display: block;
  font-size: 24px;
  font-weight: 700;
}

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

/* ============================================
   PUZZLE CONTROLS
   ============================================ */
.puzzle-controls {
  display: flex;
  gap: 12px;
  margin-top: 60px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.control-btn:hover {
  background: var(--bg-sidebar-alt);
  border-color: var(--accent-primary);
}

.control-btn i {
  font-size: 16px;
}

.control-btn.hint-btn {
  color: #f59e0b;
}

.control-btn.hint-btn:hover {
  background: rgba(245, 158, 11, 0.1);
}

.control-btn.solution-btn {
  color: #60a5fa;
}

.control-btn.solution-btn:hover {
  background: rgba(96, 165, 250, 0.1);
}

/* ============================================
   INFO CARDS
   ============================================ */
.info-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.info-card .card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-sidebar-alt);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.info-card .card-header i {
  color: var(--accent-primary);
}

.info-card .card-content {
  padding: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.info-row:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.info-row .label {
  color: var(--text-muted);
  font-size: 13px;
}

.info-row .value {
  color: var(--text-primary);
  font-weight: 500;
}

.info-row .themes {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 150px;
  text-align: right;
}

.rating-badge {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  border-radius: 4px;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
}

/* Move History */
.move-history {
  padding: 12px 16px;
  max-height: 120px;
  overflow-y: auto;
}

.move-history .placeholder {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 16px;
}

.move-history .move-item {
  display: inline-block;
  padding: 4px 8px;
  margin: 2px;
  background: var(--bg-body);
  border-radius: 4px;
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
}

.move-history .move-item.correct {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.move-history .move-item.incorrect {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.stat-item {
  text-align: center;
  padding: 12px;
  background: var(--bg-body);
  border-radius: 8px;
}

.stat-item .stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'Roboto Mono', monospace;
}

.stat-item .stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ============================================
   ACHIEVEMENTS
   ============================================ */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px;
}

.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--bg-body);
  border-radius: 8px;
  opacity: 0.4;
  transition: all 0.3s;
}

.achievement-badge.unlocked {
  opacity: 1;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(234, 88, 12, 0.1));
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.achievement-badge .icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.achievement-badge .name {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.achievement-badge.unlocked .name {
  color: var(--text-primary);
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}

.action-link:hover {
  background: var(--bg-sidebar-alt);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.action-link i {
  width: 20px;
  text-align: center;
}

/* ============================================
   SUCCESS MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-sidebar);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  border: 1px solid var(--border-color);
}

.success-modal .success-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.success-modal h2 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.success-modal p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.success-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-body);
  border-radius: 8px;
}

.success-stats .stat-item {
  background: none;
  padding: 0;
}

.success-stats .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-primary);
}

.success-stats .label {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-secondary {
  padding: 12px 24px;
  background: var(--bg-sidebar-alt);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
}

/* ============================================
   LOADING
   ============================================ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  text-align: center;
}

.loading-spinner i {
  font-size: 48px;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.loading-spinner p {
  color: var(--text-muted);
}

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
}

.toast {
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.toast.success {
  background: #10b981;
}

.toast.error {
  background: #ef4444;
}

.toast.info {
  background: #3b82f6;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .puzzle-page {
    flex-direction: column;
    align-items: center;
  }

  .board-section {
    max-width: 100%;
  }

  .info-panel {
    width: 100%;
    max-width: 560px;
  }
}

@media (max-width: 600px) {
  .puzzle-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .puzzle-controls {
    margin-top: 50px;
  }

  .control-btn span {
    display: none;
  }

  .control-btn {
    padding: 12px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .achievements-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   DIFFICULTY BADGES
   ============================================ */
.difficulty-easy {
  color: #10b981;
}

.difficulty-medium {
  color: #f59e0b;
}

.difficulty-hard {
  color: #ef4444;
}

.difficulty-expert {
  color: #8b5cf6;
}

/* Highlight for correct/incorrect moves */
.board-square.highlight-correct {
  background-color: rgba(16, 185, 129, 0.5) !important;
}

.board-square.highlight-incorrect {
  background-color: rgba(239, 68, 68, 0.5) !important;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
