@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  
  --primary-blue: #2563eb;
  --primary-hover: #1d4ed8;
  
  --text-dark: #0f172a;
  --text-muted: #64748b;
  
  --status-answered: #10b981;
  --status-review: #8b5cf6;
  --status-unanswered: #ef4444;
  --status-unvisited: #94a3b8;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* Header Bar */
.app-header {
  height: 56px;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-space {
  background: #dbeafe;
  color: var(--primary-blue);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Login Tabs */
.login-tab {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-family: var(--font-family);
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-tab.active {
  background: #ffffff;
  color: var(--text-dark);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

/* Screens */
.screen {
  display: none;
  min-height: calc(100vh - 56px);
  padding: 1rem 0.75rem;
  width: 100%;
}

.screen.active {
  display: flex;
}

/* Minimal Card */
.clean-card {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  padding: 1.25rem;
  width: 100%;
}

/* Setup Screen */
#welcome-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
}

.hero-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 0.2rem;
  text-align: center;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dark);
}

.input-control {
  background: #f8fafc;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  color: var(--text-dark);
  font-family: var(--font-family);
  font-size: 0.92rem;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.input-control:focus {
  border-color: var(--primary-blue);
  background: #ffffff;
}

.btn-primary {
  background: var(--primary-blue);
  color: #ffffff;
  font-family: var(--font-family);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-dark);
  border: 1px solid var(--card-border);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn-secondary:active {
  background: #e2e8f0;
}

.btn-warning {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Exam Workspace */
#exam-screen {
  flex-direction: column;
  gap: 0.85rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.exam-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  gap: 0.5rem;
}

.student-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--card-border);
}

.timer-display {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-blue);
}

.timer-box.warning {
  border-color: #fca5a5;
  background: #fef2f2;
}

.timer-box.warning .timer-display {
  color: #dc2626;
}

.exam-main-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0.85rem;
  width: 100%;
}

.question-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.section-tag {
  color: var(--primary-blue);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  word-break: break-word;
}

.question-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-dark);
}

.question-text {
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0.85rem 0 1rem 0;
  color: #1e293b;
  font-weight: 500;
  word-break: break-word;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: #f8fafc;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.option-key {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #475569;
  flex-shrink: 0;
}

.option-card.selected .option-key {
  background: var(--primary-blue);
  color: #ffffff;
  border-color: var(--primary-blue);
}

.option-label {
  font-size: 0.92rem;
  color: #1e293b;
  flex: 1;
  line-height: 1.35;
  word-break: break-word;
}

/* Question Action Navigation Buttons */
.nav-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid var(--card-border);
  margin-top: auto;
  gap: 0.5rem;
}

.nav-buttons-left {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Palette */
.palette-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.palette-title {
  font-size: 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.35rem;
}

.palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.dot-answered { background: var(--status-answered); }
.dot-review { background: var(--status-review); }
.dot-unanswered { background: var(--status-unanswered); }
.dot-unvisited { background: var(--status-unvisited); }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.palette-btn {
  height: 35px;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: #f8fafc;
  color: #64748b;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.palette-btn.answered {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}

.palette-btn.review {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

.palette-btn.unanswered {
  background: #ffe4e6;
  color: #9f1239;
  border-color: #fca5a5;
}

.palette-btn.current {
  border: 2px solid var(--primary-blue);
  color: var(--primary-blue);
}

.btn-submit-exam {
  background: #10b981;
  color: white;
  font-weight: 700;
  padding: 0.75rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  width: 100%;
  font-size: 0.88rem;
}

/* Results */
#results-screen {
  flex-direction: column;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.score-display-box {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary-blue);
  margin: 0.3rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}

.stat-card {
  padding: 0.75rem 0.4rem;
  text-align: center;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--card-border);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
}

.stat-card.correct .stat-value { color: #10b981; }
.stat-card.incorrect .stat-value { color: #ef4444; }
.stat-card.unattempted .stat-value { color: #64748b; }
.stat-card.accuracy .stat-value { color: var(--primary-blue); }

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Solutions */
.solution-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.solution-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.7rem;
}

.solution-badge.correct { background: #d1fae5; color: #065f46; }
.solution-badge.incorrect { background: #ffe4e6; color: #9f1239; }
.solution-badge.skipped { background: #f1f5f9; color: #475569; }

.explanation-box {
  background: #f8fafc;
  border-left: 3px solid var(--primary-blue);
  padding: 0.65rem 0.75rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.4;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 0.75rem;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 14px;
  padding: 1.25rem;
  text-align: center;
}

/* ====================================================
   MOBILE SCREEN SPECIFIC RULES (ANDROID & IPHONE)
   ==================================================== */
@media (max-width: 640px) {
  .app-header {
    height: auto;
    padding: 0.5rem 0.75rem;
  }
  
  .brand-title {
    font-size: 0.88rem;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .header-actions button {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.75rem !important;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .screen {
    padding: 0.5rem;
  }

  .clean-card {
    padding: 0.85rem;
  }

  .exam-main-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .palette-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .nav-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .nav-buttons-left {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.35rem;
    width: 100%;
  }

  .nav-buttons-left button {
    padding: 0.55rem 0.2rem !important;
    font-size: 0.78rem !important;
  }

  .btn-save-next {
    width: 100%;
    padding: 0.7rem !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .solution-answers-grid {
    grid-template-columns: 1fr !important;
  }
}
