/*
 * QQ RESPONSIVE PATCH
 * Fixes alle responsiveness-problemen en grote fouten
 * Voeg toe NA qq-bundle.css in index.php
 * Versie: 2026-03
 */

/* ============================================================
   FIX 2: Navbar - mobile zoekbalk
   De zoekform is d-none d-md-inline-block → onzichtbaar op mobile.
   We voegen een uitklapbare zoekbalk toe via JS + CSS.
   ============================================================ */

/* Zoekknop zichtbaar op mobile */
#mobileSearchToggle {
  display: none;
}
@media (max-width: 767.98px) {
  #mobileSearchToggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Uitklapbare zoekbalk onder de topnav, mobile only */
#mobileSearchBar {
  display: none;
  background: #343a40;
  padding: 8px 12px;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 1038;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
#mobileSearchBar.open {
  display: flex;
  gap: 6px;
}
#mobileSearchBar input {
  flex: 1;
  font-size: 1rem;
  padding: .4rem .75rem;
  border-radius: 6px;
  border: none;
}
#mobileSearchBar button {
  padding: .4rem .85rem;
  border-radius: 6px;
  background: #0d6efd;
  color: #fff;
  border: none;
  cursor: pointer;
}

/* Wanneer zoekbalk open is: content iets omlaaag schuiven */
body.mobile-search-open #layoutSidenav_content {
  margin-top: 48px;
}

/* ============================================================
   FIX 3: Topnav - tekst afkappen op kleine schermen
   ============================================================ */
.navbar-brand {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
@media (max-width: 400px) {
  .navbar-brand {
    max-width: 120px;
    font-size: .95rem;
  }
}

/* ============================================================
   FIX 4: Content padding verbetering - mobile compacter
   ============================================================ */
@media (max-width: 575.98px) {
  .container-fluid {
    padding: .5rem !important;
  }
  /* Kaartjes: minder padding op mobile */
  .card-body {
    padding: .75rem;
  }
}

/* ============================================================
   FIX 5: Tables - horizontaal scrollbaar op mobile
   ============================================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* Voorkom dat tabellen de viewport breken */
table {
  min-width: 0;
}
@media (max-width: 767.98px) {
  /* Wrap alle tabellen in responsive container als dat nog niet zo is */
  .card-body > table:not(.table-no-wrap) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   FIX 6: Sidebar overlay sluitknop op mobile
   ============================================================ */
/* Klik op overlay sluit de sidebar */
@media (max-width: 991.98px) {
  .sb-sidenav-toggled #layoutSidenav #layoutSidenav_content::before {
    cursor: pointer;
  }
}

/* ============================================================
   FIX 7: Buttons - touch targets minimaal 44px
   ============================================================ */
@media (max-width: 767.98px) {
  .btn {
    min-height: 38px;
  }
  /* Nav links in sidebar: groter touch target */
  .sb-sidenav-menu .nav-link {
    padding-top: .6rem;
    padding-bottom: .6rem;
  }
}

/* ============================================================
   FIX 8: Images - nooit breder dan container
   ============================================================ */
img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   FIX 9: Formulieren - mobile-friendly
   ============================================================ */
@media (max-width: 575.98px) {
  /* Input groups: stapelen op mobile */
  .input-group-stacked-mobile {
    flex-direction: column;
  }
  .input-group-stacked-mobile .form-control,
  .input-group-stacked-mobile .btn {
    border-radius: .375rem !important;
    width: 100%;
    margin-bottom: .25rem;
  }

  /* Select vakjes: volle breedte */
  select.form-select {
    width: 100%;
    max-width: 100% !important;
  }
}

/* ============================================================
   FIX 10: Pagina-specifiek - quiz / herhaal pagina's
   Inline max-width containers die te smal zijn op breed scherm
   en te breed op small scherm worden hier gecorrigeerd.
   ============================================================ */
/* Responsieve wrapper die altijd goed past */
.qq-page-wrap {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   FIX 11: Kaart-grid op categorieën-pagina - betere breakpoints
   ============================================================ */
@media (max-width: 575.98px) {
  .cat-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}
@media (min-width: 576px) and (max-width: 991.98px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================================
   FIX 12: Badges in nav - kleinere tekst op mobile
   ============================================================ */
@media (max-width: 767.98px) {
  .sb-sidenav-menu .badge {
    font-size: .7rem;
    padding: .2em .45em;
  }
}

/* ============================================================
   FIX 13: Zoekpagina filterbar - stapelen op mobile
   ============================================================ */
@media (max-width: 575.98px) {
  .search-filter-row {
    flex-direction: column;
    gap: .5rem;
  }
  .search-filter-row > * {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ============================================================
   FIX 14: Tags pagina alpha-bar - horizontaal scrollen
   (al gedeeltelijk in bundle, maar explicieter)
   ============================================================ */
@media (max-width: 575.98px) {
  .tags-alpha {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .5rem;
    scrollbar-width: thin;
  }
  .tags-alpha a {
    flex-shrink: 0;
  }
}

/* ============================================================
   FIX 15: Footer sidenav - altijd leesbaar
   ============================================================ */
.sb-sidenav-footer {
  padding: .75rem 1rem;
  font-size: .85rem;
}
@media (max-width: 991.98px) {
  .sb-sidenav-footer .btn-xs {
    font-size: .85rem;
    padding: .35rem .7rem;
  }
}

/* ============================================================
   FIX 16: Print-stijlen (bonus)
   ============================================================ */
@media print {
  #layoutSidenav_nav,
  .sb-topnav,
  #mobileSearchBar,
  #mobileSearchToggle {
    display: none !important;
  }
  #layoutSidenav_content {
    padding-left: 0 !important;
    margin-left: 0 !important;
    top: 0 !important;
  }
}

/* ============================================================
   FIX 17: Eternal quiz selectors wrappen op mobile
   ============================================================ */
@media (max-width: 575.98px) {
  #qtypeSelect,
  #categorySelect {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
}

/* ============================================================
   FIX 18: Afbeeldingen nooit breder dan container
   ============================================================ */
img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   QUIZ SHELL - gedeelde layout voor alle playground pagina's
   ============================================================ */
.quiz-shell {
  max-width: 1100px;
}
.quiz-card-header {
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  padding: 1rem 1.25rem !important;
  margin-bottom: 1.25rem;
}
.quiz-card-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.quiz-card-header .subtle,
.quiz-card-header .text-muted,
.quiz-card-header .small-muted {
  font-size: .85rem;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .75rem;
}

/* Quiz card tiles */
.quiz-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  transition: box-shadow .15s ease;
}
.quiz-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }

/* Header met button: mooi uitgelijnde stijl voor tags, categories etc. */
.qq-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.qq-page-header h3,
.qq-page-header h4 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.qq-page-header .btn {
  font-size: .8rem;
  padding: .25rem .65rem;
  border-radius: 20px;
}

/* Category/subcat pills in vragenlijst */
.badge.rounded-pill.text-bg-secondary {
  background-color: #6c757d !important;
  color: #fff !important;
}
.badge.rounded-pill.text-bg-light {
  background-color: #f1f3f5 !important;
  color: #495057 !important;
}

/* Answer + rating row */
.footer-left {
  flex-wrap: wrap;
}
.footer-left .question-rating {
  margin-top: 0;
}


/* ============================================================
   ACCORDION BADGE UITLIJNING (categorielijst op mobile)
   Bootstrap's accordion-button is flex maar de badge floort niet
   rechts tenzij we dit expliciet instellen
   ============================================================ */
.accordion-button {
  display: flex !important;
  align-items: center !important;
}
.accordion-button .flex-grow-1 {
  flex-grow: 1;
  min-width: 0;
  word-break: break-word;
}
.accordion-button .badge {
  flex-shrink: 0;
  margin-right: .5rem; /* ruimte voor chevron */
}

/* ============================================================
   SUB-BADGES MOBIEL — uniformiseer stijl
   ============================================================ */
.sub-badges-mobile {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .5rem;
}
.sub-badges-mobile a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .6rem;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: #f1f3f5;
  color: #333;
  text-decoration: none;
  font-size: .82rem;
  line-height: 1.2;
  transition: background .12s;
}
.sub-badges-mobile a:hover { background: #e9ecef; }
.sub-badges-mobile .count { color: #888; font-size: .78rem; }

/* ============================================================
   GAME PLAY PAGES — consistente layout
   ============================================================ */
.quiz-shell .quiz-card,
.home-wrap .quiz-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
}
.quiz-shell .quiz-card + .quiz-card,
.home-wrap .quiz-card + .quiz-card {
  margin-top: .75rem;
}
.question-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .88rem;
  color: #555;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  padding: .3rem .75rem;
}

/* ============================================================
   QUIZ-CARD-HEADER — normalize padding overal
   ============================================================ */
.quiz-card-header {
  background: #f8f9fa !important;
  border: 1px solid #e9ecef !important;
  border-radius: 12px !important;
  padding: 1rem 1.25rem !important;
  margin-bottom: 1.25rem !important;
}
.quiz-card-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .15rem;
}
.quiz-card-header .text-muted,
.quiz-card-header .subtle {
  font-size: .85rem;
}

/* ============================================================
   COLOR ACCENTS — subtiele kleur in de layout
   Minimaal: alleen sidebar headings, page headers, hover states
   Logo, badges, buttons blijven standaard Bootstrap
   ============================================================ */
:root {
  --qq-accent: #6366f1;          /* indigo — only for subtle details */
  --qq-accent-light: #eef2ff;    /* indigo-50 */
  --qq-accent-mid: #a5b4fc;      /* indigo-300 */
  --qq-accent-warm: #f59e0b;     /* amber for highlights */
  --qq-accent-warm-light: #fef3c7;
  --qq-page-bg: #f8f9fb;         /* barely visible warm gray */
}

/* -- Topnav: thin accent line only -- */
.sb-topnav {
  border-top: 3px solid var(--qq-accent);
}

/* -- Page background: warm tint -- */
#layoutSidenav_content {
  background: var(--qq-page-bg);
}

/* -- Sidebar section headings: indigo accent -- */
.sb-sidenav .sb-sidenav-menu .nav .sb-sidenav-menu-heading {
  color: var(--qq-accent);
  letter-spacing: .6px;
  font-size: .7rem;
}

/* -- Sidebar links: hover accent -- */
#layoutSidenav_nav .sb-sidenav-menu .nav-link:hover {
  background: var(--qq-accent-light);
  color: var(--qq-accent) !important;
  border-radius: 6px;
  margin: 0 6px;
  padding-left: calc(1rem - 6px);
}

/* -- Sidebar footer: subtle tint -- */
.sb-sidenav-dark .sb-sidenav-footer {
  background: var(--qq-accent-light) !important;
  border-top: 1px solid rgba(99,102,241,.1);
}

/* -- Page header h3: left accent border -- */
.home-wrap > div:first-child h3.mb-1,
.home-wrap > .d-flex:first-child h3 {
  border-left: 3px solid var(--qq-accent);
  padding-left: 10px;
}

/* -- Cards: subtle left accent on hover -- */
.quiz-card:hover,
.home-wrap .quiz-card:hover {
  border-left: 3px solid var(--qq-accent-mid);
}

/* -- Accordion active: subtle tint -- */
.accordion-button:not(.collapsed) {
  background-color: var(--qq-accent-light);
  color: var(--qq-accent);
  box-shadow: inset 0 -1px 0 rgba(99,102,241,.12);
}

/* -- Tag chips: hover accent (subcats keep their existing style) -- */
.tag-chip:hover {
  border-color: var(--qq-accent-mid) !important;
  background: var(--qq-accent-light) !important;
  color: var(--qq-accent) !important;
}

/* -- Star ratings: warm amber -- */
.star.active { color: var(--qq-accent-warm); }

/* -- Question chip in play page -- */
.question-chip {
  background: var(--qq-accent-light);
  color: var(--qq-accent);
  border: 1px solid rgba(99,102,241,.2);
}

/* -- Score pill: warm accent -- */
.score-pill {
  background: var(--qq-accent-warm-light) !important;
  color: #92400e !important;
}

/* -- Form focus: subtle indigo ring -- */
.form-control:focus, .form-select:focus {
  border-color: var(--qq-accent-mid);
  box-shadow: 0 0 0 .2rem rgba(99,102,241,.15);
}

/* -- Pagination active: indigo -- */
.page-item.active .page-link {
  background-color: var(--qq-accent);
  border-color: var(--qq-accent);
}
.page-link { color: var(--qq-accent); }
.page-link:hover { color: #4f46e5; }
