/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap'); */

:root {
  --primary: #6366f1;
  --primary-hover: #5855eb;
  --secondary: #f59e0b;
  --accent: #ec4899;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  --background: #fafafa;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #f8fafc;
  
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --border-focus: var(--primary);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  font-size: 16px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { 
    transform: translateY(-100%); 
    opacity: 0; 
  }
  to { 
    transform: translateY(0); 
    opacity: 1; 
  }
}

.app-header h1,
.app-header .brand {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.025em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.app-header .brand {
  text-decoration: none;
}

.app-header nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.app-header nav a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-lg);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.app-header nav a:visited {
  color: rgba(255, 255, 255, 0.9);
}

.app-header nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.app-header nav a:active {
  transform: translateY(0);
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
}

.nav-link:hover {
  color: white;
}

.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xl);
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.5;
}

@keyframes fadeInUp {
  from { 
    opacity: 0; 
    transform: translateY(30px) scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

h1, h2 {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 2rem;
  text-align: center;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h1 {
  font-size: 2.25rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.875rem;
}

form {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface-hover);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 400;
  background: var(--surface);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: inherit;
}

input:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  outline: none;
  background: var(--surface-elevated);
}

input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.button,
button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.button:hover,
button:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.button:active,
button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.button:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button.secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.button.secondary:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.question-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transition: var(--transition-slow);
  position: relative;
}

.question-block:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.question-block p {
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  font-size: 1.1rem;
  line-height: 1.5;
}

.question-block label {
  display: flex;
  align-items: center;
  margin: 0.75rem 0;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  color: var(--text-secondary);
  font-weight: 500;
}

.question-block label:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.question-block input[type="radio"] {
  margin-right: 0.75rem;
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
}

.difficulty-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
}

.difficulty-badge.easy {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.difficulty-badge.medium {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.difficulty-badge.hard {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.hint-button {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.hint-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.history-item,
.leaderboard-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transition: var(--transition-slow);
  position: relative;
}

.history-item:hover,
.leaderboard-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.history-item p,
.leaderboard-item p {
  margin: 0.5rem 0;
  color: var(--text-secondary);
  font-weight: 500;
}

.history-item p:first-child,
.leaderboard-item p:first-child {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.1rem;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--surface-hover);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

#global-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

.loading-text {
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 1rem;
}

.spinner {
  border: 3px solid rgba(99, 102, 241, 0.1);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 3000;
  max-width: 400px;
}

.toast {
  background: var(--surface);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  margin-bottom: 0.75rem;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  font-weight: 500;
  line-height: 1.5;
}

.toast.info {
  border-left: 4px solid var(--info);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

@keyframes toastSlideIn {
  from { 
    opacity: 0; 
    transform: translateX(100%) scale(0.9); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0) scale(1); 
  }
}

/* Quiz specific styles */
#quiz-container {
  margin-top: 2rem;
}

#quiz-meta {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface-hover);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.quiz-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* Card component */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition-slow);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

a {
  color: var(--info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    margin: 1rem;
    padding: 1.5rem;
  }

  .app-header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .app-header nav {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .filter-form {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .quiz-actions {
    flex-direction: column;
    align-items: stretch;
  }

  #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}
