/* Base Styles and Design System */
:root {
  --primary-color: #7C3AED; /* Violet color */
  --primary-hover: #6D28D9; /* Slightly darker violet for hover effect */
  --success-color: #22c55e;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --background-color: #f8fafc;
  --card-background: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --border-radius: 12px;
  --box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --transition: all 0.2s ease-in-out;
  --container-max-width: 800px;
  --container-padding: 1.5rem;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Layout */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--container-padding);
}

/* Header Styles */
.header {
  background-color: var(--primary-color);
  color: white;
  padding: 2rem 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.header p {
  align-items: center;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.logo i {
  font-size: 2.75rem;
}

.header-text {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .header {
    padding: 1.5rem 1rem;
  }

  .logo i {
    font-size: 2.25rem;
  }

  .header-text {
    font-size: 1.1rem;
  }
}

/* Controls Card */
.controls-card {
  background: var(--card-background);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .controls-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: white;
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.button-group {
  display: flex;
  gap: 0.75rem;
}

.footer {
   margin-top: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

#startQuiz {
  background-color: var(--primary-color);
  color: white;
}

#startQuiz:hover {
  background-color: var(--primary-hover);
}

/* Quiz Container */
.quiz-container {
  background: var(--card-background);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  overflow: hidden;
}

.questions-wrapper {
  padding: 1.5rem;
}

.question {
  background: #f8fafc;
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question:last-child {
  margin-bottom: 0;
}

.question h3 {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Aligns content to the left */
  font-size: 1.225rem;
  color: var(--primary-color);
  gap: 0.5rem; /* Adds space between the heading and the button */
}

[id^="check-answer-"] {
  background-color: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  margin-left: auto;
}

[id^="check-answer-"]:hover {
  color: white;
  background-color: var(--primary-hover);
}

.question p {
  color: var(--text-primary);
}

/* Options */
.options {
  display: grid;
  gap: 0.75rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.option:hover {
  border-color: var(--primary-color);
  background: #f0f7ff;
}

.option.selected {
  border-color: var(--primary-color);
  background: #f0f7ff;
}

.option.correct {
  border-color: var(--success-color);
  background: #f0fdf4;
}

.option.incorrect {
  border-color: var(--danger-color);
  background: #fef2f2;
}

/* Submit Container */
.submit-container {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: white;
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.submit-button {
  background-color: var(--primary-color);
  color: white;
  padding: 0.875rem 2rem;
  font-weight: 600;
  width: 100%;
  max-width: 300px;
}

.submit-button:hover {
  background-color: var(--primary-hover);
}

/* Loading Message */
.loading-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-secondary);
  font-size: 1rem;
}

.loading-message::before {
  content: '';
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Timer */
.timer {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border-radius: var(--border-radius);
  font-weight: 500;
  color: var(--text-primary);
}

.timer.warning {
  color: var(--warning-color);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Results */
.result-card {
  background: var(--card-background);
  padding: 2rem;
  margin-top: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  text-align: center;
}

.score-display {
  margin-bottom: 1.5rem;
}

.score-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.score-percentage {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.score-fraction {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.score-breakdown {
  display: grid;
  gap: 0.75rem;
  max-width: 300px;
  margin: 0 auto;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--border-radius);
  background: #f8fafc;
}

.breakdown-item.correct {
  color: var(--success-color);
}

.breakdown-item.incorrect {
  color: var(--danger-color);
}

.breakdown-item.unanswered {
  color: var(--warning-color);
}

.time-taken {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Notifications */
.notification {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  animation: slideIn 0.3s ease-out;
  z-index: 50;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.error {
  border-left: 4px solid var(--danger-color);
}

.notification.success {
  border-left: 4px solid var(--success-color);
}

.notification.info {
  border-left: 4px solid var(--primary-color);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
  .button-group {
    flex-direction: column;
  }
  
  .button {
    width: 100%;
  }

  .question {
    padding: 1rem;
  }

  .question h3 {
  font-size: 1.07rem;
  gap: 0.3rem;
}

  .questions-wrapper {
    padding: 1rem;
  }

  .controls-card {
    padding: 1rem;
  }

  .header {
    margin-bottom: 1rem;
  }
  .container {
    padding: 1rem;
  }

  .header h1 {
  font-size: 28px;
}

[id^="check-answer-"]:hover {
  color: white;
  background-color: var(--primary-hover);
}

  [id^="check-answer-"] {
    width: auto;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.footer {
  position: relative;
  bottom: 0;
  width: 100%;
  text-align: center;
  padding: 1rem;
  border-radius: var(--border-radius);
  background-color: var(--card-background);
  color: var(--text-secondary);
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

/* Floating Timer */
.timer-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  z-index: 100;
  cursor: grab;
  max-width: 200px; /* Set a maximum width */
  width: auto; /* Ensure it doesn’t stretch to fill the space */
  white-space: nowrap; /* Prevent content from wrapping */
}

.timer-container .timer {
  font-weight: 600;
}

.timer-container .stop-button {
  background-color: var(--danger-color);
  color: white;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
}

/* Add these styles to your existing styles.css */
.date-input {
    width: 100%;
    margin-top: 5px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
    color: #6495ED;
    cursor: pointer;
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Style for unavailable dates */
.date-input:invalid {
    color: var(--text-secondary);
}

/* Hide default date picker arrows */
.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.5) sepia(1) saturate(5) hue-rotate(175deg);
    cursor: pointer;
}

.date-selector h3 {
  color: var(--primary-color);
  font-size: 1.075rem;      /* Change this to your desired font size */
}

/* Add these styles to your existing CSS */

.practice-selector {
  width: 100%;
}

.practice-selector h3 {
  color: var(--primary-color);
  font-size: 1.075rem;
  margin-bottom: 0.5rem;
}

.number-input-container {
  display: flex;
  gap: 1rem;
  align-items: center;
}

#questionCount {
  width: 100px;
  text-align: center;
  font-size: 1rem;
  padding: 0.75rem;
}

#startPractice {
  background-color: var(--primary-color);
  color: white;
  white-space: nowrap;
}

#startPractice:hover {
  background-color: var(--primary-hover);
}

@media (max-width: 640px) {
  .number-input-container {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  #questionCount {
    width: 100%;
  }
  
  #startPractice {
    width: 100%;
  }
}

.scroll-buttons-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.scroll-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  opacity: 0.8;
}

.scroll-button:hover {
  transform: scale(1.1);
  opacity: 1;
  background-color: var(--primary-hover);
}

.scroll-button.hidden {
  display: none;
}

@media (max-width: 768px) {
  .scroll-buttons-container {
    right: 10px;
    bottom: 10px;
  }
  
  .scroll-button {
    width: 35px;
    height: 35px;
  }
}

/* AI Explanation Styles */
.ai-explanation {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  max-height: 400px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  z-index: 1000;
  padding: 1rem;
  overflow-y: auto;
  border: 2px solid var(--primary-color);
  transition: transform 0.3s ease;
}

.ai-explanation.hidden {
  transform: translateY(100%);
  opacity: 0;
}

.explanation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.explanation-content {
  font-size: 0.9rem;
  line-height: 1.6;
}

.explanation-content p {
  margin-bottom: 0.5rem;
}

.explanation-content strong {
  color: var(--primary-color);
}

.explain-button {
  margin-top: 1rem;
  background-color: #4f46e5;
  color: white;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  width: auto;
}

.explain-button:hover {
  background-color: #4338ca;
}

.explanation-loading {
  text-align: center;
  padding: 1rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.small-button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  width: auto;
}

/* Responsive adjustments for AI explanation */
@media (max-width: 768px) {
  .ai-explanation {
    width: 90%;
    max-width: 350px;
    right: 50%;
    transform: translateX(50%);
    bottom: 10px;
  }
  
  .ai-explanation.hidden {
    transform: translateX(50%) translateY(100%);
  }
}

/* Explanation Content Styling */
