/* Base & Tokens */
:root {
  --bg-color: #1a0b0b;
  --panel-bg: rgba(127, 29, 29, 0.25);
  --text-main: #ffffff;
  --text-muted: #fecaca;
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --secondary: #7f1d1d;
  --secondary-hover: #991b1b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --info: #fca5a5;

  --palette-answered: #10b981;
  --palette-marked-answered: #3b82f6;
  --palette-marked-unanswered: #f59e0b;
  --palette-unanswered: #ffffff;

  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --radius: 12px;
  --radius-sm: 8px;

  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-color);
  background-image:
    radial-gradient(circle at 15% 50%, rgba(220, 38, 38, 0.18), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(127, 29, 29, 0.25), transparent 25%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1,
h2,
h3 {
  font-weight: 700;
  margin-bottom: 1rem;
}

p {
  line-height: 1.6;
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 1rem;
}

.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.primary {
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-hover);
}

.secondary {
  background: var(--secondary);
}

.secondary:hover {
  background: var(--secondary-hover);
}

.success {
  background: var(--success);
}

.warning {
  background: var(--warning);
  color: #fff;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: var(--danger-hover);
}

/* Glass Panel */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  padding: 2rem;
}

/* Home Layout */
.container {
  max-width: 800px;
  margin: auto;
  padding: 2rem;
  width: 100%;
}

.landing-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.landing-logo {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1.5rem;
}

.landing-title {
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
  font-weight: 700;
}

.landing-subtitle {
  margin-bottom: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.selection-container {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 2rem;
  animation: fadeIn 0.5s ease-out;
}

.button-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.test-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.test-card {
  padding: 1.5rem;
  background: rgba(127, 29, 29, 0.15);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.test-card:hover {
  background: rgba(127, 29, 29, 0.25);
  transform: translateY(-2px);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Test Interface Layout */
.test-body {
  height: 100vh;
  overflow: hidden;
}

.test-header {
  height: 70px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
}

.test-header h1 {
  margin: 0;
  font-size: 1.5rem;
  background: linear-gradient(90deg, #dc2626, #fca5a5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.timer-container {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.test-container {
  display: flex;
  height: calc(100vh - 70px);
}

.question-main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.question-header h2 {
  margin: 0;
  color: var(--info);
}

.subject-badge {
  background: rgba(127, 29, 29, 0.4);
  color: #ffffff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.question-content {
  font-size: 1.25rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  min-height: 100px;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.option-label {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.option-label:hover {
  background: rgba(255, 255, 255, 0.08);
}

.option-label input[type="radio"] {
  margin-right: 1rem;
  transform: scale(1.2);
  cursor: pointer;
}

.option-label.selected {
  background: rgba(220, 38, 38, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.4);
}

.action-buttons {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  justify-content: space-between;
  padding-top: 2rem;
  border-top: 1px solid var(--glass-border);
}

.submit-container {
  margin-top: 1rem;
}

/* Sidebar Palette */
.palette-sidebar {
  width: 320px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
}

.palette-sidebar h3 {
  padding: 1.5rem;
  margin: 0;
  border-bottom: 1px solid var(--glass-border);
}

.legend {
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--glass-border);
  display: grid;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-box.answered {
  background: var(--palette-answered);
}

.legend-box.marked-answered {
  background: var(--palette-marked-answered);
}

.legend-box.marked-unanswered {
  background: var(--palette-marked-unanswered);
}

.legend-box.unanswered {
  background: var(--palette-unanswered);
}

.palette-grid {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  overflow-y: auto;
}

.palette-btn {
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  color: #1a1a1a;
}

.palette-btn:hover {
  transform: scale(1.1);
}

/* Colors for palette buttons */
.pb-default {
  background: var(--palette-unanswered);
}

.pb-answered {
  background: var(--palette-answered);
  color: #fff;
}

.pb-marked-answered {
  background: var(--palette-marked-answered);
  color: #fff;
}

.pb-marked-unanswered {
  background: var(--palette-marked-unanswered);
  color: #fff;
}

.pb-active {
  border: 2px solid white;
  box-shadow: 0 0 8px white;
  transform: scale(1.1);
  z-index: 10;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-color);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Results Page */
.result-body {
  justify-content: center;
  align-items: center;
}

.result-container {
  width: 100%;
  max-width: 600px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 2rem;
  animation: fadeIn 0.5s ease-out;
}

.score-card {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2rem;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--success);
  margin: 1rem 0;
}

.subject-scores {
  display: grid;
  gap: 1rem;
}

.subject-card {
  background: rgba(127, 29, 29, 0.15);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  border-radius: var(--radius-sm);
  text-align: left;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-hover);
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .test-container {
    flex-direction: column;
    height: auto;
  }

  .test-body {
    overflow: auto;
  }

  .palette-sidebar {
    width: 100%;
    height: auto;
    max-height: 400px;
    border-left: none;
    border-top: 1px solid var(--glass-border);
  }

  .action-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}