/* ==========================================================================
   QuizPulse Elite - Animations, Modals & Responsive Adaptations
   ========================================================================== */

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

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

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
  100% { transform: translate(-30px, 50px) scale(0.96); }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(99, 102, 241, 0.4); }
  50% { transform: scale(1.04); box-shadow: 0 0 20px rgba(99, 102, 241, 0.7); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ==========================================================================
   Modals (Glassmorphic Dialogs)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--accent-rose);
  color: #fff;
  border-color: var(--accent-rose);
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Leaderboard Modal Details
   ========================================================================== */
.leaderboard-categories {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.leaderboard-cat-tab {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.leaderboard-cat-tab.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.leaderboard-row.rank-1 {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.leaderboard-row.rank-2 {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.08);
}

.leaderboard-row.rank-3 {
  border-color: rgba(217, 119, 6, 0.4);
  background: rgba(217, 119, 6, 0.08);
}

.lb-rank {
  font-size: 1.1rem;
  font-weight: 800;
  width: 55px;
}

.lb-info {
  flex: 1;
}

.lb-player-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.lb-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lb-score {
  text-align: right;
}

.lb-points {
  font-weight: 800;
  color: var(--accent-amber);
  font-size: 0.95rem;
}

.lb-pct {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Certificate Modal Details
   ========================================================================== */
.certificate-modal-card {
  max-width: 900px;
}

.cert-input-wrapper {
  margin-bottom: 1.25rem;
}

.cert-input-wrapper label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.cert-input-wrapper input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.cert-canvas-container {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  background: #000;
  margin-bottom: 1rem;
}

#certificate-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   Custom Quiz Builder Forms
   ========================================================================== */
.builder-modal-card {
  max-width: 800px;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.builder-q-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.builder-q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.btn-remove-q {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.builder-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .builder-options-grid {
    grid-template-columns: 1fr;
  }
}

.builder-option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.builder-option-row input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.builder-actions-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.3rem;
  }
  .configurator-panel {
    padding: 1.25rem;
  }
  .question-card {
    padding: 1.5rem;
  }
  .question-prompt {
    font-size: 1.15rem;
  }
  .main-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .user-profile-badge {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
