/* ──────────────────────────────────────────────
   DEDICATED QUESTION BANK STYLE SHEET
   Matches Portfolio theme styling with a modern twist
   ────────────────────────────────────────────── */

:root {
  --bg: #fafafa;
  --bg-alt: #f0f0f0;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
  --primary: #101010;

  /* Category specific highlights */
  --sql-color: #3b82f6;
  --sql-bg: rgba(59, 130, 246, 0.08);
  --html-color: #f97316;
  --html-bg: rgba(249, 115, 22, 0.08);
  --java-color: #ec4899;
  --java-bg: rgba(236, 72, 153, 0.08);

  --transition: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #121212;
  --surface: #161616;
  --border: #262626;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --primary: #ffffff;

  --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  --sql-bg: rgba(59, 130, 246, 0.15);
  --html-bg: rgba(249, 115, 22, 0.15);
  --java-bg: rgba(236, 72, 153, 0.15);
}

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

body {
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* ──────────── LAYOUT ──────────── */
.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ──────────── TOP BAR (GO BACK + THEME) ──────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

[data-theme="dark"] .top-bar {
  background: rgba(10, 10, 10, 0.88);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.back-link svg {
  width: 18px;
  height: 18px;
}

.back-link:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.theme-btn-header {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.theme-btn-header:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.theme-btn-header svg {
  width: 18px;
  height: 18px;
  transition: transform 0.5s var(--ease-out);
}

.theme-btn-header:hover svg {
  transform: rotate(20deg);
}

.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* ──────────── HERO SECTION ──────────── */
.hero {
  padding: 52px 0 36px;
  text-align: left;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3rem;
  line-height: 1.15;
  margin-bottom: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 0 32px;
}

/* Only run CSS animations automatically on load for the first hero section */
.hero:first-of-type .section-label {
  animation: slideUp 0.55s var(--ease-out) 0.05s forwards;
}

.hero:first-of-type .hero-title {
  animation: slideUp 0.6s var(--ease-out) 0.15s forwards;
}

.hero:first-of-type .hero-subtitle {
  animation: slideUp 0.6s var(--ease-out) 0.25s forwards;
}

/* ──────────── SEARCH & FILTER BAR ──────────── */
.controls-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
  flex-wrap: wrap;
  opacity: 0;
  transform: translateY(16px);
  animation: slideUp 0.55s var(--ease-out) 0.35s forwards;
}


.search-box {
  position: relative;
  width: 100%;
  max-width: 220px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  font-family: inherit;
  transition: all 0.3s var(--ease-out);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 14px;
  height: 14px;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stagger each tab button with nth-child delays */
.tab-btn {
  padding: 8px 20px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.3s var(--ease-out),
    border-color 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out),
    background 0.3s var(--ease-out);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(14px);
  animation: slideUp 0.5s var(--ease-out) forwards;
}

.tab-btn:nth-child(1) {
  animation-delay: 0.30s;
}

.tab-btn:nth-child(2) {
  animation-delay: 0.38s;
}

.tab-btn:nth-child(3) {
  animation-delay: 0.46s;
}

.tab-btn:nth-child(4) {
  animation-delay: 0.54s;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px) scale(1.03);
}

.tab-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: scale(1.05);
}



/* ──────────── PRACTICE GRID ──────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ──────────── TEST CARD ──────────── */
.test-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(0);
  will-change: transform, box-shadow;
}

.test-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .test-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-category-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent, var(--text-muted));
  background: color-mix(in srgb, var(--accent, currentColor) 12%, transparent);
  padding: 2px 8px;
  border-radius: 20px;
}

.lang-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform var(--transition);
}

.test-card:hover .lang-logo {
  transform: scale(1.1);
}

.test-card[data-category="sql"] {
  --accent: var(--sql-color);
}

.test-card[data-category="html"] {
  --accent: var(--html-color);
}

.test-card[data-category="java"] {
  --accent: var(--java-color);
}

.test-number {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.test-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.35;
  color: var(--text);
}

.test-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: auto;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: gap 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

.test-card:hover .card-footer {
  gap: 8px;
  color: var(--text);
}

.card-footer svg {
  width: 11px;
  height: 11px;
  transition: transform 0.3s var(--ease-out);
}

.test-card:hover .card-footer svg {
  transform: translateX(3px);
}

/* ──────────── EMPTY STATE ──────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ──────────── SCROLL REVEAL ANIMATIONS ──────────── */
/* Hero items use CSS animation directly (section-label, hero-title, hero-subtitle) */
/* Cards use .reveal + .visible toggled by JS */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

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

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* ──────────── FOOTER ──────────── */
.footer {
  margin-top: 96px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

/* ──────────── AI SQL EXAM STYLES ──────────── */
.ai-test-section {
  padding: 40px 0;
}

#ai-exams-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.ai-test-card {
  padding: 28px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.ai-test-card .test-title {
  font-size: 1rem;
  margin-top: 8px;
  margin-bottom: 12px;
}

.ai-test-card .test-desc {
  line-height: 1.6;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.hidden {
  display: none !important;
}

.ai-test-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-test-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ai-test-header h3 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.ai-test-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.question-item {
  margin-bottom: 24px;
}

.question-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.question-input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
  font-size: 0.9rem;
  min-height: 80px;
  resize: vertical;
  transition: border-color var(--transition);
}

.question-input:focus {
  outline: none;
  border-color: var(--text);
}

.form-actions {
  margin-top: 32px;
  text-align: right;
}

#ai-loading-state {
  text-align: center;
  padding: 40px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#ai-results-container {
  margin-top: 32px;
}

#ai-results-container h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  font-family: 'Playfair Display', Georgia, serif;
}

.result-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.result-header h4 {
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.4;
}

.status-text {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-text.status-correct {
  color: #16a34a;
}

.status-text.status-partial {
  color: #ca8a04;
}

.status-text.status-wrong {
  color: #dc2626;
}

[data-theme="dark"] .status-text.status-correct { color: #4ade80; }
[data-theme="dark"] .status-text.status-partial { color: #facc15; }
[data-theme="dark"] .status-text.status-wrong { color: #f87171; }

.result-item .user-answer,
.result-item .correct-answer,
.result-item .feedback {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.result-item strong {
  color: var(--text);
  font-weight: 600;
}

.result-item pre {
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-top: 4px;
}

.footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ──────────── RESPONSIVE ──────────── */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.3rem;
  }

  .container {
    padding: 0 20px;
  }

  .top-bar {
    padding: 12px 16px;
  }

  .controls-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

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

  #ai-exams-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

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