/* =======================
   General Layout
======================= */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f7f8fc;
  color: #333;
}

/* =======================
   Main Layout
======================= */
main {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  gap: 2rem;
}

/* ============ HEADER & NAV ONLY ============ */

.site-header {
  background: #d8143c;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Logo */
.logo-link {
  display: inline-block;
  text-decoration: none;
}

.site-logo {
  height: 48px;
  width: auto;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

.site-logo:hover {
  transform: scale(1.05);
}

.hidden-random-quiz {
  display: none !important;
}

/* Nav layout (desktop baseline) */
.main-nav {
  display: flex;
  align-items: center;
}

/* Hamburger button */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
}

/* Desktop nav links */
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.nav-link {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.98rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Random quiz button */
.nav-btn {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: #d8143c;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background 0.2s ease, transform 0.2s ease;
}

.nav-btn:hover {
  background: #b10e32;
  transform: translateY(-1px);
}

/* Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.dropdown-menu {
  position: absolute;
  top: 120%;
  right: 0;
  min-width: 190px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 0.4rem 0;
  display: none;
  z-index: 50;
}

/* JS toggles .dropdown-open directly on this element */
.dropdown-menu.dropdown-open {
  display: block;
}

.dropdown-link {
  display: block;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  color: #333;
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.dropdown-link:hover {
  background: #ffe5ea;
  color: #b10e32;
}

/* ---------- HEADER NAV — WHITE TEXT + GREY HOVER/ACTIVE ---------- */

/* Top-level header items (white text) */
.site-header .nav-link,
.site-header .nav-btn,
.site-header .nav-dropdown-toggle,
.site-header .nav-toggle {
  color: #fff !important;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Hover state (soft grey pill, text stays white) */
.site-header .nav-link:hover,
.site-header .nav-btn:hover,
.site-header .nav-dropdown-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
}

/* Active/current page state */
.site-header .nav-link.active,
.site-header .nav-btn.active,
.site-header .nav-dropdown-toggle.active,
.site-header .nav-link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.22);
  color: #fff !important;
}

.site-header .nav-link.active:hover,
.site-header .nav-btn.active:hover,
.site-header .nav-dropdown-toggle.active:hover,
.site-header .nav-link[aria-current="page"]:hover {
  background: rgba(255, 255, 255, 0.30);
}

/* Dropdown menu links (keep dark on white dropdown) */
.site-header .dropdown-menu .dropdown-link {
  color: #111;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  display: block;
  transition: background 0.2s ease, color 0.2s ease;
}

.site-header .dropdown-menu .dropdown-link:hover {
  background: #f2f2f2;
  color: #111;
}

.site-header .dropdown-menu .dropdown-link.active,
.site-header .dropdown-menu .dropdown-link[aria-current="page"] {
  background: #e6e6e6;
  color: #111;
}

/* ---------- Mobile nav behaviour (matches JS: .main-nav.nav-open) ---------- */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.6rem 0.75rem;
  }

  /* Hamburger shown on mobile */
  .nav-toggle {
    display: block;
  }

  /* Hide nav by default, show when .nav-open is on .main-nav */
  .main-nav {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    display: none;
  }

  .main-nav.nav-open {
    display: block;
  }

  .nav-links {
    background: #d8143c;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 0.75rem 0.9rem;
    flex-direction: column;
    align-items: flex-start;
    min-width: 220px;
  }

  .nav-dropdown {
    width: 100%;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    padding-left: 0.25rem;
    margin-top: 0.25rem;
  }
}

/* =======================
   Sidebar styling
======================= */
aside {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

aside h3 {
  text-align: center;
  margin-bottom: 1rem;
}

aside ul {
  list-style: none;
  padding: 0;
}

aside ul li {
  margin: 0.5rem 0;
}

aside ul li a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
}

aside ul li a:hover {
  color: #c62828;
}

.sidebar-category-select {
  padding: 0.6rem;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
}

.sidebar-category-select:focus {
  border-color: #d8143c;
  box-shadow: 0 0 4px rgba(216, 20, 60, 0.3);
}

/* =======================
   Quiz Content
======================= */
section.content {
  flex: 1;
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#quiz {
  margin-top: 1.5rem;
}

#quiz h3 {
  color: #c62828;
}

#quiz button {
  display: block;
  width: 100%;
  background: #c62828;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  margin: 0.5rem 0;
  cursor: pointer;
  transition: background 0.3s ease;
}

/* Adjust search bar width now that category moved */
.filter-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
  width: 100%;
  max-width: 500px;
  padding: 0.6rem 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: #d8143c;
  box-shadow: 0 0 4px rgba(216, 20, 60, 0.3);
}

/* =======================
   Quiz Cards
======================= */
.quiz-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.2rem;
}

/* Base quiz card */
.quiz-card {
  position: relative;
  display: block;
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  border: 1px solid transparent;
  cursor: pointer;
}

.quiz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  border-color: #d8143c;
  background: #fff9f9;
}

/* Question count badge */
.question-count-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  background: #d8143c;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 0.25rem 0.6rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

/* Category badge */
.quiz-category-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 20px;
  padding: 0.25rem 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.quiz-card:hover .quiz-category-badge {
  background: #d8143c;
  color: #fff;
  border-color: #d8143c;
}

.quiz-card:hover .question-count-badge {
  background: #b10e32;
  transform: scale(1.1);
}

.quiz-btn {
  display: inline-block;
  background: #d8143c;
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  margin-top: 0.75rem;
  transition: background 0.3s ease, transform 0.2s ease;
}

.quiz-card:hover .quiz-btn {
  background: #b10e32;
  transform: scale(1.05);
}

/* Quiz meta */
.quiz-meta {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #444;
  font-weight: 500;
}

.quiz-meta .question-count {
  display: inline-block;
  background: #fff8f8;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.quiz-card:hover .question-count {
  background: #ffe6eb;
  border-color: #d8143c;
  color: #d8143c;
}

/* Extra quiz category label */
.quiz-category {
  display: block;
  color: #666;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* =======================
   Share section
======================= */
.share-section {
  text-align: center;
  margin-top: 1.5rem;
  background: #fff9f9;
  border: 1px solid #ffe3e7;
  border-radius: 10px;
  padding: 1rem;
}

.share-section h3 {
  color: #d8143c;
  margin-bottom: 0.8rem;
}

.share-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.share-btn {
  background: #d8143c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s ease, transform 0.2s ease;
}

.share-btn:hover {
  background: #b10e32;
  transform: scale(1.05);
}

/* =======================
   Latest Result Card
======================= */
.latest-result {
  background: #f9f9f9;
  border-radius: 10px;
  padding: 0.8rem;
  margin-top: 1rem;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.05);
}

.latest-result h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  color: #d8143c;
}

#latestResultDisplay p {
  font-size: 0.9rem;
  color: #444;
  text-align: center;
}

.latest-result-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8f0;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: transform 0.2s ease;
}

.latest-result-card:hover {
  transform: translateY(-2px);
}

.latest-result-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #ddd;
}

.no-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.latest-result-info {
  flex: 1;
  font-size: 14px;
}

.latest-result-info strong {
  font-size: 15px;
  color: #d8143c;
}

.latest-result-time {
  font-size: 12px;
  color: #888;
}

/* =======================
   Ads styling
======================= */
.adsbygoogle {
  border-radius: 8px;
  overflow: hidden;
  margin: 10px auto;
}

/* =======================
   Spinner
======================= */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #d8143c;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.9s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =======================
   AI Result Box
======================= */
.ai-result {
  background: #fff8f8;
  border: 2px solid #d8143c;
  border-radius: 10px;
  padding: 16px;
  margin: 20px 0;
  font-size: 1.1rem;
  line-height: 1.5;
}

/* =======================
   Footer
======================= */
footer {
  background: #c62828;
  color: white;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

/* =======================
   Responsive layout
======================= */
@media (max-width: 768px) {
  main {
    flex-direction: column;
  }
}
