/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #e3f2fd 0%, #f1f8e9 100%);
  min-height: 100vh;
  position: relative;
}

/* Ensure overlay is positioned relative to viewport, not body */
html, body {
  overflow-x: hidden;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  padding: 50px 40px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.container h1 {
  color: #333;
  font-size: 32px;
  margin-bottom: 10px;
  text-align: center;
}

/* Student Sign-in Form */
.name-input {
  width: 100%;
  padding: 15px;
  font-size: 18px;
  border: 2px solid #ddd;
  border-radius: 4px;
  margin-bottom: 20px;
}

.submit-button {
  width: 100%;
  padding: 15px;
  font-size: 18px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.submit-button:hover {
  background-color: #0056b3;
}

/* Form Labels */
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
  text-align: left;
}

/* Alert Messages */
.alert {
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 4px;
  font-size: 16px;
}

.alert-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-notice {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Links */
a {
  color: #007bff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Test Container */
.test-container,
.learning-container {
  max-width: fit-content;
  margin: 0 auto;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.test-actions,
.learning-actions {
  text-align: center;
  margin-top: 40px;
  max-width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.cancel-button {
  padding: 12px 24px;
  font-size: 16px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s ease-in-out;
}

.cancel-button:hover {
  background-color: #c82333;
}

.cancel-button:active {
  background-color: #bd2130;
}

.test-content-wrapper {
  width: fit-content;
  margin: 0 auto;
}

.test-header-wrapper {
  width: 100%;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  box-sizing: border-box;
}

.test-header,
.learning-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px 0;
}

.remaining-count-large {
  text-align: center;
}

.remaining-number {
  font-size: 48px;
  font-weight: bold;
  color: #007bff;
  display: block;
  line-height: 1;
}

.remaining-label {
  font-size: 18px;
  color: #666;
  display: block;
  margin-top: 8px;
}

/* Stars Display */
.stars-display {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.stars-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.stars-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.star {
  font-size: 32px;
  line-height: 1;
  display: inline-block;
  position: relative;
}

.star-unanswered {
  color: #999;
  opacity: 0.5;
}

.star-correct {
  color: #ffd700; /* Gold */
}

.star-wrong {
  color: #888; /* Grey */
}

.star-current {
  position: relative;
}

.star-marker {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background-color: #007bff;
  border-radius: 2px;
  display: block;
}

.question-counter {
  font-size: 16px;
  color: #666;
  font-weight: 500;
}

.timer {
  font-size: 20px;
  font-weight: bold;
  color: #007bff;
  padding: 8px 16px;
  background-color: #e7f3ff;
  border-radius: 8px;
}

/* Main Content Wrapper - Grid Layout */
.main-content-wrapper {
  display: grid;
  grid-template-columns: auto 256px;
  grid-template-rows: 60px auto;
  gap: 16px;
  width: fit-content;
  margin: 0;
}

.question-cell {
  display: flex;
  align-items: center;
  white-space: nowrap;
  height: 60px;
  box-sizing: border-box;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  padding: 0 12px;
  border-radius: 8px;
  grid-row: 1;
  grid-column: 1;
}

/* Question Transition Screen */
.question-transition {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: white;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  margin: 0;
  padding: 0;
}

.transition-content {
  text-align: center;
}

.transition-content h1 {
  font-size: 48px;
  font-weight: bold;
  color: #333;
  margin: 0;
}

.answer-cell {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: center;
}

.blank-cell {
  grid-row: 2;
  grid-column: 1;
}

.number-pad-cell {
  grid-row: 2;
  grid-column: 2;
}

.question-sum {
  font-size: 36px;
  font-weight: bold;
  color: #333;
  margin: 0;
  line-height: 1.2;
  display: inline-block;
}

/* Answer Input Box */
.answer-input-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 256px; /* Match number pad width: 3 buttons (80px each) + 2 gaps (8px each) = 256px */
  min-height: 60px;
  padding: 8px 16px;
  background-color: #f0f8e8; /* Light yellow-green */
  border: 2px solid #8b4513; /* Brown border */
  border-radius: 8px;
  text-align: right;
  box-sizing: border-box;
}

.answer-text {
  font-size: 36px;
  font-weight: bold;
  color: #333;
  min-height: 36px;
  display: inline-block;
}

/* Feedback */
#question-feedback {
  text-align: center;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  display: none;
  min-height: 0;
}

#question-feedback .feedback {
  padding: 15px;
  border-radius: 8px;
}

.feedback.correct {
  background-color: #d4edda;
  color: #155724;
  border: 2px solid #c3e6cb;
}

.feedback.incorrect {
  background-color: #f8d7da;
  color: #721c24;
  border: 2px solid #f5c6cb;
}

.feedback-message {
  font-size: 20px;
  font-weight: bold;
  margin: 0 0 10px 0;
}

.correct-answer {
  font-size: 18px;
  margin: 0;
}

/* Number Pad */
.number-pad {
  flex-shrink: 0;
  width: 256px; /* 3 buttons (80px each) + 2 gaps (8px each) = 240 + 16 = 256px */
}

.number-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  justify-content: center;
}

.number-button,
.action-button {
  width: 80px;
  height: 80px;
  padding: 0;
  font-size: 22px;
  font-weight: bold;
  border: 2px solid #ddd;
  border-radius: 8px;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.number-button:hover,
.action-button:hover {
  background-color: #f0f0f0;
  border-color: #007bff;
}

.number-button:active,
.action-button:active {
  background-color: #e0e0e0;
  transform: scale(0.95);
}

.clear-button {
  background-color: #ffc107;
  color: #333;
  border-color: #ffc107;
}

.clear-button:hover {
  background-color: #e0a800;
}

.enter-button {
  background-color: #28a745;
  color: white;
  border-color: #28a745;
}

.enter-button:hover {
  background-color: #218838;
}

/* Test Complete Screen */
.test-complete-container {
  max-width: 600px;
  margin: 40px auto;
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.test-complete-container h1 {
  font-size: 32px;
  color: #333;
  margin-bottom: 40px;
}

.score-display {
  margin: 40px 0;
}

.score-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.score-number {
  font-size: 64px;
  font-weight: bold;
  color: white;
  line-height: 1;
}

.score-total {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 5px;
}

.score-percentage {
  font-size: 36px;
  font-weight: bold;
  color: #333;
  margin-bottom: 30px;
}

.score-details {
  margin: 30px 0;
}

.score-message {
  font-size: 24px;
  color: #666;
  margin: 20px 0;
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 40px;
}

.complete-actions .action-button {
  width: 100%;
  padding: 15px;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  border: none;
  transition: background-color 0.2s ease-in-out;
}

.complete-actions .primary-button {
  background-color: #007bff;
  color: white;
}

.complete-actions .primary-button:hover {
  background-color: #0056b3;
}

.complete-actions .secondary-button {
  background-color: #28a745;
  color: white;
}

.complete-actions .secondary-button:hover {
  background-color: #218838;
}

/* Complete Message */
.complete-message {
  text-align: center;
  padding: 60px 20px;
}

.complete-message h1 {
  font-size: 36px;
  color: #28a745;
  margin-bottom: 20px;
}

.complete-message p {
  font-size: 20px;
  color: #666;
  margin-bottom: 30px;
}

/* Feedback Overlay */
.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transform: none;
  inset: 0;
}

.feedback-overlay.show {
  display: flex;
}

.feedback-overlay-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  margin: auto;
  position: relative;
}

.overlay-question-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
}

.overlay-question {
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

.correct-answer-display {
  font-size: 22px;
  font-weight: bold;
  color: #007bff;
}

.feedback-emoji {
  font-size: 60px;
  margin-bottom: 15px;
  line-height: 1;
}

.feedback-title {
  font-size: 24px;
  margin: 0 0 12px 0;
  color: #333;
}

.correct-answer-text {
  font-size: 24px;
  color: #666;
  margin: 15px 0;
  font-weight: bold;
}

.remaining-text {
  font-size: 18px;
  color: #666;
  margin: 20px 0;
}

.completion-message {
  font-size: 20px;
  color: #28a745;
  margin: 20px 0;
  font-weight: bold;
}

.next-button {
  width: 100%;
  padding: 12px;
  font-size: 18px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 15px;
}

.next-button:hover {
  background-color: #0056b3;
}

/* Home Page */
.home-options {
  display: flex;
  gap: 30px;
  margin: 40px 0;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
}

.option-card {
  flex: 1;
  min-width: 300px;
  max-width: 400px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 35px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.option-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.option-card:first-child {
  border-top: 4px solid #4CAF50;
}

.option-card:last-child {
  border-top: 4px solid #FF9800;
}

.option-card h2 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 15px;
  flex-shrink: 0;
}

.option-card p {
  color: #555;
  margin-bottom: 0;
  line-height: 1.7;
  font-size: 16px;
  flex-grow: 1;
}

.option-card form {
  margin-top: auto;
  width: 100%;
}

.option-card .no-questions {
  margin-top: auto;
  margin-bottom: 20px;
}

.option-button {
  width: 100%;
  padding: 16px 24px;
  font-size: 18px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.option-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.option-button:active {
  transform: translateY(0);
}

.option-button[disabled] {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.no-questions {
  color: #888;
  font-style: italic;
  margin: 20px 0;
  font-size: 14px;
}

.logout-section {
  margin-top: 50px;
  text-align: center;
  padding-top: 30px;
  border-top: 2px solid #e0e0e0;
}

.logout-button {
  padding: 10px 20px;
  font-size: 16px;
  background-color: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.logout-button:hover {
  background-color: #5a6268;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container,
  .test-container,
  .learning-container {
    padding: 20px;
  }

  .main-content-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 20px;
  }

  .question-cell {
    grid-row: 1;
    grid-column: 1;
  }

  .answer-cell {
    grid-row: 2;
    grid-column: 1;
  }

  .blank-cell {
    display: none;
  }

  .number-pad-cell {
    grid-row: 3;
    grid-column: 1;
  }

  .remaining-number {
    font-size: 40px;
  }

  .remaining-label {
    font-size: 16px;
  }

  .question-sum,
  .equals-sign {
    font-size: 28px;
  }

  .answer-input-box {
    min-width: 120px;
    min-height: 48px;
  }

  .answer-text {
    font-size: 28px;
  }

  .number-button,
  .action-button {
    width: 70px;
    height: 70px;
    padding: 0;
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .remaining-number {
    font-size: 36px;
  }

  .remaining-label {
    font-size: 14px;
  }

  .question-sum,
  .equals-sign {
    font-size: 22px;
  }

  .answer-input-box {
    min-width: 100px;
    min-height: 40px;
    padding: 6px 12px;
  }

  .answer-text {
    font-size: 22px;
  }

  .number-button,
  .action-button {
    width: 60px;
    height: 60px;
    padding: 0;
    font-size: 18px;
  }

  .timer {
    font-size: 20px;
    padding: 8px 15px;
  }

  .test-complete-container {
    padding: 30px 20px;
  }

  .test-complete-container h1 {
    font-size: 28px;
  }

  .score-circle {
    width: 150px;
    height: 150px;
  }

  .score-number {
    font-size: 48px;
  }

  .score-total {
    font-size: 16px;
  }

  .score-percentage {
    font-size: 28px;
  }

  .score-message {
    font-size: 20px;
  }
}
