/* Premium Theme and Variables */
:root {
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%);
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --danger-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  
  /* Dark Mode Default Colors */
  --bg-color: #0b0f19;
  --panel-bg: rgba(17, 24, 39, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --input-bg: rgba(31, 41, 55, 0.5);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus: #818cf8;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger-glow: rgba(239, 68, 68, 0.2);
  --accent-color: #6366f1;
}

/* Light Mode Variables Override */
[data-theme="light"] {
  --bg-color: #f8fafc;
  --panel-bg: rgba(255, 255, 255, 0.75);
  --panel-border: rgba(0, 0, 0, 0.08);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: #cbd5e1;
  --input-focus: #4f46e5;
  --shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
  --accent-color: #4f46e5;
}

/* Base resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Dynamic background glows */
.glow-bg {
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}
.glow-1 {
  background: #6366f1;
  top: -10%;
  left: -10%;
}
.glow-2 {
  background: #ec4899;
  bottom: -10%;
  right: -10%;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header & Controls */
header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 40px;
  width: auto;
}

.brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* User Profile Badge */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--input-focus);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-badge i {
  color: #818cf8;
}

/* Theme Toggle Button */
.theme-btn {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Auth Modal Overlay */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}

.auth-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 90%;
  max-width: 420px;
  text-align: center;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.auth-logo {
  height: 70px;
  margin-bottom: 1.5rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.auth-input-group {
  margin-bottom: 1.5rem;
}

.auth-input {
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 2px;
  font-weight: 700;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  color: var(--text-primary);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.auth-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.auth-error {
  color: #ef4444;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
  display: none;
}

/* Exam Card & Layout */
.exam-card {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  margin-top: 1.5rem;
}

.exam-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1.5rem;
}

.exam-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.exam-meta {
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

/* Section Title styling */
.section-card {
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--accent-color);
  border-left: 4px solid var(--accent-color);
  padding-left: 0.75rem;
}

/* Question item wrapping */
.question-item {
  margin-bottom: 1.75rem;
  animation: fadeIn 0.4s ease forwards;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.question-num {
  opacity: 0.6;
}

/* Option List & Grid styling */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  .options-grid.two-cols {
    grid-template-columns: 1fr 1fr;
  }
}

.option-card {
  position: relative;
}

.option-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-label {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  min-height: 48px;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  user-select: none;
  transition: all 0.2s ease;
}

.option-label:hover {
  border-color: var(--input-focus);
  background: rgba(99, 102, 241, 0.05);
}

.option-card input[type="radio"]:checked + .option-label {
  border-color: var(--input-focus);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 0 1px var(--input-focus);
}

.option-card input[type="radio"]:focus-visible + .option-label {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

/* Input Fields for corrections & rewrites */
.input-wrapper {
  position: relative;
}

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  color: var(--text-primary);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.text-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Inline choice style (Set 2 / Set 3 D) */
.sentence-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.8;
}

.inline-selector,
.set-selector {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--input-border);
  border-radius: 8px;
  padding: 0.25rem 1.5rem 0.25rem 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23818cf8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 0.8rem;
  min-height: 36px;
}

.inline-selector:focus,
.set-selector:focus {
  border-color: var(--input-focus);
}

.inline-selector option,
.set-selector option {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

/* Submit Section & Actions */
.submit-area {
  display: flex;
  justify-content: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--panel-border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 2.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 9999px;
  cursor: pointer;
  border: none;
  color: #fff;
  background: var(--primary-gradient);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn:active {
  transform: translateY(0);
}

/* Feedback Styling after submit */
.feedback-box {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideDown 0.3s ease forwards;
}

.feedback-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #10b981;
}

.feedback-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #ef4444;
}

.correct-ans-show {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 500;
}

/* Results Dashboard modal/section */
.results-panel {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  margin-top: 2rem;
  animation: scaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem auto;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
}

.score-num {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.score-max {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  width: 60%;
}

.result-msg {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.result-submsg {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-secondary {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  box-shadow: none;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

/* Admin Results Dashboard Styling */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-table-wrapper {
  overflow-x: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  margin-top: 1rem;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.results-table th, .results-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--panel-border);
}

.results-table th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
  color: var(--accent-color);
}

.results-table tr:last-child td {
  border-bottom: none;
}

.score-badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.score-high {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.score-low {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Detail modal overlay for mistake tracker */
.detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.3s ease;
}

.detail-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 90%;
  max-width: 650px;
  max-height: 80vh;
  overflow-y: auto;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.detail-title-group {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.mistake-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mistake-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
}

.mistake-question {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.ans-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  font-size: 0.9rem;
}

.ans-submitted {
  color: #ef4444;
}

.ans-correct {
  color: #10b981;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}
