/* ==========================================
   STUDY BUDDY ACADEMIC PORTAL - app.css
   Version: 1.0
   ========================================== */

/* ------------------------------------------
   1. VARIABLES & THEME CONFIGURATION
   ------------------------------------------ */
:root {
  /* -- Core Palette (Default: Light Blue Theme) -- */
  --primary-color: #2c5282;       /* Deep Blue */
  --secondary-color: #4299e1;     /* Bright Blue */
  --accent-color: #f6ad55;        /* Orange (for highlights) */
  
  /* -- Feedback Colors -- */
  --success-color: #48bb78;       /* Green */
  --error-color: #f56565;         /* Red */
  
  /* -- Neutrals -- */
  --bg-color: #ebf8ff;            /* Very light blue background */
  --surface-color: #ffffff;       /* White cards */
  --text-color: #2d3748;          /* Dark Grey text */
  --border-color: #e2e8f0;        /* Light Grey borders */
  
  /* -- Typography -- */
  --font-heading: 'Fredoka', sans-serif; /* Friendly, rounded */
  --font-main: 'Nunito', sans-serif;     /* Readable, clean */
  
  /* -- UI Constants -- */
  --border-radius: 20px;
  --container-width: 800px;
}

/* Example: Dark Purple Theme Override (Applied via JS) */
.theme-dark-purple {
  --primary-color: #44337a;
  --secondary-color: #805ad5;
  --bg-color: #f3e5f5;
}

/* ------------------------------------------
   2. GLOBAL RESET & BASE STYLES
   ------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Prevent bounce effect on iOS */
  overscroll-behavior: none; 
}

/* Utility to hide elements (if not already global) */
.hidden {
    display: none !important;
}

/* ------------------------------------------
   3. LAYOUT CONTAINERS
   ------------------------------------------ */
/* Main App Wrapper - Mobile First Strategy */
.app-container {
  width: 100%;
  max-width: var(--container-width);
  height: 100vh; /* Full viewport height */
  background-color: var(--bg-color);
  position: relative;
  overflow: hidden; /* Prevents scrollbars during transitions */
  display: flex;
  flex-direction: column;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  display: none; /* Hidden by default */
  flex-direction: column;
  overflow-y: auto; /* Allow scrolling inside screens */
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.screen.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

/* Header */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 2px solid rgba(0,0,0,0.05);
  text-align: center;
  flex-shrink: 0; /* Prevents header from shrinking on small screens */
}

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--primary-color);
}

/* ------------------------------------------
   4. COMPONENT: BUTTONS
   ------------------------------------------ */
.btn {
  padding: 12px 24px;
  font-size: 1.1rem;
  font-family: var(--font-heading);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none; /* Prevents text highlighting on rapid taps */
}

.btn:active {
  transform: translateY(2px);
  box-shadow: none !important;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Action (Save, Check, Go) */
.btn-primary {
  background-color: var(--secondary-color);
  color: white;
  box-shadow: 0 4px 0 var(--primary-color);
}

/* Secondary Action (Next, Skip) */
.btn-secondary {
  background-color: #cbd5e0;
  color: var(--text-color);
  box-shadow: 0 4px 0 #a0aec0;
}

/* Small Header Buttons (Back, Logout) */
.btn-small {
  background: none;
  border: 2px solid var(--secondary-color);
  color: var(--secondary-color);
  padding: 5px 12px;
  font-size: 0.9rem;
  border-radius: 15px;
  cursor: pointer;
  font-weight: bold;
}

.btn-small:hover {
  background-color: var(--secondary-color);
  color: white;
}

/* Text-only Link Button */
.btn-text {
  background: none;
  border: none;
  color: var(--primary-color);
  text-decoration: underline;
  cursor: pointer;
  margin-top: 20px;
  font-weight: bold;
  font-size: 1rem;
}

/* ------------------------------------------
   5. COMPONENT: INPUTS
   ------------------------------------------ */
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 15px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 10px;
}

input:focus {
  border-color: var(--secondary-color);
}

/* ------------------------------------------
   6. LOADING SPINNER
   ------------------------------------------ */
.loader-layout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  gap: 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #edf2f7;
  border-top: 6px solid var(--secondary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  font-family: var(--font-heading);
  font-weight: bold;
  color: var(--primary-color);
  font-size: 1.2rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ------------------------------------------
   7. AUTH SCREEN
   ------------------------------------------ */
.auth-box {
  background: var(--surface-color);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.error-msg {
  color: var(--error-color);
  font-size: 0.9rem;
  text-align: center;
  min-height: 20px;
}

/* ------------------------------------------
   8. DASHBOARD (ASSIGNMENT GRID)
   ------------------------------------------ */
.assignment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 40px; /* Space for scrolling */
}

.assignment-card {
  background: var(--surface-color);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assignment-card:hover {
  transform: translateY(-5px);
  border-color: var(--secondary-color);
  box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.subject-tag {
  background-color: var(--bg-color);
  color: var(--primary-color);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  align-self: flex-start;
  text-transform: uppercase;
}

.assignment-title {
  font-size: 1.3rem;
  margin: 0;
  line-height: 1.3;
}

.score-badge {
  font-size: 0.9rem;
  color: #718096;
}

.score-badge.completed {
  color: var(--success-color);
  font-weight: bold;
}

/* ------------------------------------------
   9. SETUP SCREEN
   ------------------------------------------ */
/* Configuration Container */
.setup-options {
  background-color: #f7fafc;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  padding: 20px;
  width: 100%;
  max-width: 350px;
  margin: 0 auto 25px auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.option-row label {
  font-size: 1.1rem;
  color: var(--text-color);
  cursor: pointer;
  font-weight: 600;
}

/* Custom Checkbox Size */
.option-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--secondary-color);
}

/* Voice Selector */
.voice-label {
  font-weight: bold; 
  color: var(--primary-color); 
  font-size: 0.9rem;
  margin-bottom: 8px;
  display: block;
}

.voice-select-dropdown {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: white;
  cursor: pointer;
  font-family: var(--font-main);
  outline: none;
}

/* Dynamic Mode Buttons Container */
#mode-buttons-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.mode-btn {
  width: 100%;
  max-width: 320px;
  padding: 18px;
  font-size: 1.2rem;
  font-weight: bold;
  font-family: var(--font-heading);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  box-shadow: 0 5px 0 var(--primary-color);
}

.mode-btn:hover {
  transform: translateY(-2px);
  background-color: var(--primary-color);
  box-shadow: 0 7px 0 #1a365d;
}

.mode-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a365d;
}

/* ------------------------------------------
   10. STUDY ENGINE (SHARED STYLES)
   ------------------------------------------ */
.study-layout {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 25px;
  width: 100%;
  padding-top: 20px;  
}

.study-card {
  background-color: white;
  border: 4px solid var(--secondary-color);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 550px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
  position: relative;
}

.study-card-divider {
  width: 60%;
  height: 2px;
  background-color: var(--secondary-color);
  opacity: 0.3;
  margin: 15px 0;
  border-radius: 2px;
}

.study-content-main {
  font-family: var(--font-heading);
  font-size: 2.8rem;
  color: var(--primary-color);
  margin-bottom: 10px;
  word-break: break-word; /* Prevents long words from overflowing */
}

.study-content-detail {
  font-size: 1.4rem;
  color: var(--text-color);
  font-style: italic;
  line-height: 1.5;
}

.study-controls {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
}

.progress-label {
  font-weight: bold;
  color: #718096;
  font-size: 1rem;
}

/* ------------------------------------------
   12. FLASH CARD ENGINE SPECIFIC
   ------------------------------------------ */
/* Typography inside the card */
.flashcard-face h2 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--text-primary, #2c3e50);
    line-height: 1.4;
}

/* Ensure the prompt text looks distinct if desired */
.flashcard-face.prompt h2 {
    font-weight: 600;
}

.flashcard-face.response h2 {
    font-weight: 400;
    color: var(--text-secondary, #555);
}

/* ------------------------------------------
   11. SPELLING ENGINE SPECIFIC
   ------------------------------------------ */
.voice-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  font-size: 3rem;
  cursor: pointer;
  box-shadow: 0 8px 0 #dd6b20; /* Darker orange shadow */
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.voice-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 0 #dd6b20;
}

.study-input {
  width: 100%;
  padding: 15px;
  font-size: 2rem;
  text-align: center;
  border: 4px solid var(--border-color);
  border-radius: 20px;
  outline: none;
  font-family: var(--font-heading);
  letter-spacing: 1px;
}

.study-input:focus {
  border-color: var(--accent-color);
}

.feedback-msg {
    min-height: 80px; 
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Specific styling for the encouragement line */
.feedback-subtext {
    font-size: 1.1rem;
    font-weight: normal;
    color: var(--text-color);
    opacity: 0.8;
}

/* The correction line: Optimized for mobile width */
.spaced-correction {
    display: block;
    font-size: 1.6rem; /* Slightly smaller for mobile safety */
    letter-spacing: 6px; /* Still spaced, but tighter for small screens */
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.5); /* Soft background */
    padding: 2px 10px;
    border-radius: 8px;
    font-family: monospace; /* Fixed width helps letters line up */
}

.feedback-correct { 
  color: var(--success-color); 
}

.feedback-wrong { 
  color: var(--error-color); 
}

/* ------------------------------------------
   12. FLASH CARD ENGINE SPECIFIC
   ------------------------------------------ */
.mc-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 25px;
}

.choice-btn {
    padding: 15px;
    font-size: 1.1rem;
    background: var(--surface-light, #f9f9f9);
    border: 2px solid var(--border-color, #ddd);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.choice-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

/* Feedback States */
.choice-btn.correct {
    background-color: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724;
}

.choice-btn.incorrect {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24;
}

.mc-feedback-area {
    margin-top: 20px;
    padding: 10px;
    font-weight: bold;
    border-radius: 4px;
}

/* ------------------------------------------
   12. RESULTS SCREEN
   ------------------------------------------ */
.results-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  flex-grow: 1;
  justify-content: flex-start;
  padding-top: 20px;
}

.score-container {
  text-align: center;
  margin-bottom: 20px;
}

.final-score {
  font-size: 4.5rem;
  font-weight: bold;
  color: var(--primary-color);
  font-family: var(--font-heading);
  margin: 0;
  line-height: 1;
}

.summary-list {
  width: 100%;
  max-height: 300px; /* Scrollable if list is long */
  overflow-y: auto;
  border: 2px solid var(--border-color);
  border-radius: 15px;
  background: white;
  padding: 0 10px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 10px;
  border-bottom: 1px solid #f0f4f8;
  font-size: 1.2rem;
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-icon { 
  font-size: 1.2rem; 
}

