/* ========================================
   SAT Practice - Digital SAT Style CSS
   ======================================== */

:root {
  /* Colors - Digital SAT Blue Theme */
  --sat-blue: #006dcc;
  --sat-blue-dark: #0056a3;
  --sat-blue-light: #e8f1fb;
  --sat-blue-lighter: #f0f7ff;
  --sat-green: #1e7e34;
  --sat-green-light: #e8f5e9;
  --sat-red: #c62828;
  --sat-red-light: #fdecea;
  --sat-orange: #ef6c00;
  --sat-orange-light: #fff3e0;
  --sat-gray-50: #f8f9fa;
  --sat-gray-100: #f1f3f4;
  --sat-gray-200: #e8eaed;
  --sat-gray-300: #dadce0;
  --sat-gray-400: #bdc1c6;
  --sat-gray-500: #9aa0a6;
  --sat-gray-600: #80868b;
  --sat-gray-700: #5f6368;
  --sat-gray-800: #3c4043;
  --sat-gray-900: #202124;
  --white: #ffffff;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.16);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --max-width: 1200px;
  --header-height: 64px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--sat-gray-50);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sat-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  transition: all var(--transition);
}

input, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--sat-blue);
  box-shadow: 0 0 0 3px var(--sat-blue-light);
}

.hidden { display: none !important; }

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
}
.btn-primary { background: var(--sat-blue); color: var(--white); }
.btn-primary:hover { background: var(--sat-blue-dark); }
.btn-secondary { background: var(--white); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--sat-gray-100); border-color: var(--sat-gray-300); }
.btn-accent { background: var(--sat-green); color: var(--white); }
.btn-accent:hover { background: #156b2a; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; background: var(--white); border: 1px solid var(--border-color); }
.btn-icon:hover { background: var(--sat-gray-100); }
.btn-large { padding: 14px 28px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========================================
   Loading Overlay
   ======================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--sat-gray-200);
  border-top-color: var(--sat-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   Screens
   ======================================== */
.screen { display: none; }
.screen:not(.hidden) { display: block; }
/* ========================================
   Welcome Screen
   ======================================== */
.welcome-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px;
}
.welcome-header { text-align: center; margin-bottom: 32px; }
.welcome-header h1 { font-size: 2.5rem; font-weight: 700; color: var(--sat-blue); letter-spacing: -0.02em; }
.subtitle { color: var(--text-secondary); font-size: 1.1rem; margin-top: 8px; }
.welcome-main { flex: 1; }
.load-method h2 { font-size: 1.3rem; margin-bottom: 20px; color: var(--text-primary); }
.method-card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.method-card:hover { box-shadow: var(--shadow-md); border-color: var(--sat-gray-300); }
.method-card h3 { font-size: 1.1rem; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.method-card p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 16px; }
.method-card .input-field { width: 100%; margin-bottom: 12px; }
.sample-card { border-color: var(--sat-green); background: var(--sat-green-light); }
.welcome-footer { text-align: center; padding-top: 24px; color: var(--text-secondary); font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: var(--sat-gray-500); margin-top: 8px; }

/* ========================================
   Practice Screen
   ======================================== */
.practice-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-height);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { flex: 1; text-align: center; }
.header-right { flex: 1; max-width: 300px; }
.timer {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: color var(--transition);
}
.timer.warning { color: var(--sat-orange); }
.timer.danger { color: var(--sat-red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.progress-bar-container { height: 6px; background: var(--sat-gray-200); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--sat-blue), #4285f4); border-radius: 3px; transition: width 0.3s ease; }

.practice-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
  min-height: calc(100vh - var(--header-height));
}

.panel {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--sat-gray-50);
}
.panel-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.panel-content { flex: 1; overflow-y: auto; padding: 20px; }

.passage-panel { min-height: 500px; }
.passage-content { font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.8; color: var(--text-primary); white-space: pre-wrap; }
.passage-content p { margin-bottom: 1em; }

.question-panel { min-height: 600px; display: flex; flex-direction: column; }
.question-number { font-size: 1.2rem; font-weight: 600; color: var(--sat-blue); }
.question-text { font-size: 1.15rem; font-weight: 500; margin: 20px 0 24px; line-height: 1.5; }

.options-container { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--sat-gray-50);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}
.option:hover { border-color: var(--sat-blue); background: var(--sat-blue-light); }
.option.selected { border-color: var(--sat-blue); background: var(--sat-blue-light); }
.option-letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 50%;
  font-weight: 600;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}
.option.selected .option-letter { background: var(--sat-blue); color: var(--white); border-color: var(--sat-blue); }
.option-text { flex: 1; font-size: 1rem; line-height: 1.5; }

.question-nav-header { padding: 12px 0 8px; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.question-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
}
.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--white);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.nav-btn:hover { border-color: var(--sat-blue); color: var(--sat-blue); }
.nav-btn.current { background: var(--sat-blue); color: var(--white); border-color: var(--sat-blue); }
.nav-btn.answered:not(.current) { background: var(--sat-green-light); border-color: var(--sat-green); color: var(--sat-green); }

.question-footer {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
.question-footer .btn { flex: 1; }
/* AI API Card Styles */
.ai-card { border-color: var(--sat-orange); background: var(--sat-orange-light); }
.ai-config { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--sat-orange); }
.ai-config.visible { display: flex; flex-direction: column; gap: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
/* ========================================
   Results Screen
   ======================================== */
.results-container { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.results-header h1 { font-size: 2rem; margin-bottom: 32px; }
.score-card { background: var(--white); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 40px; margin-bottom: 32px; min-width: 300px; }
.score-display { font-size: 5rem; font-weight: 700; font-family: 'SF Mono', monospace; line-height: 1; margin-bottom: 16px; }
.score-display.pass { color: var(--sat-green); }
.score-display.fail { color: var(--sat-red); }
.score-details { color: var(--text-secondary); font-size: 1.1rem; }
.score-details p { margin: 8px 0; }
.results-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ========================================
   Review Screen
   ======================================== */
.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}
.review-header h1 { font-size: 1.5rem; }
.review-main { max-width: 900px; margin: 0 auto; padding: 24px; }
.review-toolbar { display: flex; justify-content: flex-end; margin-bottom: 24px; }
.review-list { display: flex; flex-direction: column; gap: 24px; }
.review-item { background: var(--white); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.review-item.correct { border-left: 4px solid var(--sat-green); }
.review-item.incorrect { border-left: 4px solid var(--sat-red); }
.review-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: var(--sat-gray-50); border-bottom: 1px solid var(--border-color); }
.review-question-num { font-weight: 600; color: var(--text-primary); }
.review-status { font-weight: 600; }
.review-item.correct .review-status { color: var(--sat-green); }
.review-item.incorrect .review-status { color: var(--sat-red); }
.review-passage { padding: 20px; border-bottom: 1px solid var(--border-color); background: var(--sat-gray-50); }
.review-passage strong { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 0.9rem; text-transform: uppercase; }
.passage-text { font-family: var(--font-serif); font-size: 1rem; line-height: 1.8; }
.review-question { padding: 20px; border-bottom: 1px solid var(--border-color); font-size: 1.05rem; }
.review-question strong { color: var(--text-secondary); margin-right: 8px; }
.review-options { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.review-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--sat-gray-50);
}
.review-option.correct-answer { background: var(--sat-green-light); border-color: var(--sat-green); }
.review-option.your-wrong-answer { background: var(--sat-red-light); border-color: var(--sat-red); }
.review-option .option-letter { width: 28px; height: 28px; font-size: 0.9rem; }
.review-option .option-text { flex: 1; }
.answer-badge { font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; }
.answer-badge.correct { background: var(--sat-green); color: var(--white); }
.answer-badge.your-choice { background: var(--sat-red); color: var(--white); }
.review-explanation { padding: 16px 20px; background: var(--sat-blue-light); border-top: 1px solid var(--border-color); }
.review-explanation strong { color: var(--sat-blue); display: block; margin-bottom: 8px; }

/* ========================================
   Toast
   ======================================== */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 14px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 1000; animation: slideIn 0.3s ease; }
.toast.error { background: var(--sat-red); color: var(--white); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
  .practice-main { grid-template-columns: 1fr; }
  .passage-panel { order: -1; max-height: 40vh; }
}
@media (max-width: 640px) {
  .welcome-container { padding: 24px 16px; }
  .welcome-header h1 { font-size: 2rem; }
  .practice-header { padding: 10px 16px; flex-wrap: wrap; height: auto; gap: 12px; }
  .header-right { order: 3; width: 100%; max-width: none; }
  .timer { font-size: 1.25rem; }
  .practice-main { padding: 16px; gap: 16px; }
  .panel-content { padding: 16px; }
  .question-footer { flex-direction: column; }
  .score-display { font-size: 3.5rem; }
  .review-header { flex-direction: column; gap: 12px; text-align: center; }
}
.question-footer .btn-accent { flex: 1; }