/* Malta Year 4 Practice Generator - App Styles */

:root {
  --primary: #c4161c;
  --primary-dark: #a0131a;
  --primary-light: #f8e8e8;
  --bg: #f5f5f5;
  --white: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --success: #2e7d32;
  --warning: #f9a825;
  --error: #c62828;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Navbar */
.navbar {
  background: var(--white);
  border-bottom: 3px solid var(--primary);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-icon { font-size: 1.5rem; }
.nav-title { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav-links { display: flex; gap: 0.5rem; }
.nav-link {
  text-decoration: none;
  color: var(--text-light);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background 0.2s;
}
.nav-link:hover, .nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-link-primary {
  background: var(--primary);
  color: var(--white) !important;
}
.nav-link-primary:hover { background: var(--primary-dark); }

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Page Header */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.8rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-light); font-size: 1rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  text-align: center;
}
.btn-primary { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-large { padding: 0.8rem 2rem; font-size: 1.1rem; }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.filter-select {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--white);
  cursor: pointer;
}

/* Practice Cards Grid */
.practices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.practice-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.practice-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.card-icon { font-size: 1.5rem; }
.card-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}
.status-complete { background: #e8f5e9; color: var(--success); }
.status-error { background: #ffebee; color: var(--error); }
.status-generating { background: #fff8e1; color: var(--warning); }
.card-title { font-size: 1rem; margin-bottom: 0.5rem; line-height: 1.3; }
.card-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}
.card-date { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.75rem; }
.card-actions { display: flex; gap: 0.5rem; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h2 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-light); margin-bottom: 1.5rem; }

/* Generate Form */
.generate-form { max-width: 800px; }
.form-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.section-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Subject Cards */
.subject-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.subject-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  font-weight: 600;
}
.subject-card:hover { border-color: var(--primary); }
.subject-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.subject-icon { font-size: 2rem; }
.subject-name { font-size: 0.85rem; }

/* Topics */
.topics-container { margin-bottom: 1rem; }
.topic-section { margin-bottom: 1rem; }
.topic-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary);
}
.topic-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.25rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.checkbox-label input { accent-color: var(--primary); }

/* Options */
.options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.option-group { }
.option-label { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; display: block; }
.radio-group { display: flex; flex-direction: column; gap: 0.3rem; }
.radio-option {
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.radio-option input { accent-color: var(--primary); }
.range-slider {
  width: 100%;
  accent-color: var(--primary);
  margin: 0.5rem 0;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-content { text-align: center; }
.loading-content h2 { margin: 1rem 0 0.5rem; }
.loading-content p { color: var(--text-light); }
.loading-timer { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-top: 1rem; }

/* Spinner */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toolbar */
.toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toolbar-left, .toolbar-right { display: flex; gap: 0.5rem; }

/* Practice Content */
.practice-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.practice-loading {
  text-align: center;
  padding: 4rem;
}
.practice-error {
  text-align: center;
  padding: 4rem;
}

/* Questions Rendering */
.paper-header {
  border-bottom: 2px solid var(--text);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}
.paper-header h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.paper-header h2 { font-size: 1.15rem; font-weight: 400; color: var(--text-light); margin-bottom: 0.75rem; }
.paper-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}
.meta-item { }
.student-info {
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.question {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.question:last-child { border-bottom: none; }
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.q-number { font-weight: 700; font-size: 1rem; }
.q-marks { font-weight: 700; color: var(--primary); font-size: 0.85rem; }
.q-topic { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.5rem; }
.q-content { font-size: 0.95rem; line-height: 1.7; }
.q-content table { border-collapse: collapse; margin: 0.5rem 0; }
.q-content td, .q-content th { border: 1px solid var(--border); padding: 0.4rem 0.8rem; }
.q-content ol, .q-content ul { margin-left: 1.5rem; }
.working-prompt { font-size: 0.85rem; color: var(--text-light); margin-top: 0.75rem; }
.answer-line {
  height: 1.5rem;
  border-bottom: 1px dotted #ccc;
  margin: 0.4rem 0;
}

/* Answer Key */
.answer-key {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 3px solid var(--primary);
}
.answer-key h2 { font-size: 1.3rem; margin-bottom: 1.5rem; color: var(--primary); }
.answer-item {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.answer-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.q-difficulty {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  font-weight: 600;
}
.difficulty-easy { background: #e8f5e9; color: var(--success); }
.difficulty-medium { background: #fff8e1; color: #f57f17; }
.difficulty-hard { background: #ffebee; color: var(--error); }
.answer-content { font-size: 0.95rem; line-height: 1.7; }

.answers-hidden { display: none !important; }

.error-text { color: var(--error); text-align: center; padding: 2rem; }

/* Responsive */
@media (max-width: 768px) {
  .subject-cards { grid-template-columns: repeat(2, 1fr); }
  .options-row { grid-template-columns: 1fr; }
  .topic-checkboxes { grid-template-columns: 1fr; }
  .paper-meta { flex-wrap: wrap; gap: 0.75rem; }
}
