:root {
  --primary: #007bff;
  --primary-dark: #0056b3;
  --bg-color: #f4f7f6;
  --sidebar-width: 280px;
  --header-height: 60px;
  --text-color: #333;
}

* {
  box-sizing: border-box;
}
*:selection {
  background: black;
  color: white;
}
input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

body::after {
  content: "shifat100.github.io";
  position: fixed;
  top: 40%;
  left: 35%;
  font-size: 60px;
  color: rgba(0,0,0,0.1);
  transform: rotate(-30deg);
  pointer-events: none;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  /* Full viewport height */
  overflow: hidden;
  /* Prevent body scroll, handle inside containers */
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  /* Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+/Edge */
  user-select: none;
}

/* --- HEADER (Fixed Top) --- */
.top-bar {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  flex-shrink: 0;
  /* Prevent shrinking */
  z-index: 100;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 15px;
}
.brand {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
}

#installBtn {
  display: none;
  /* Shown via JS */
  background: #fff;
  color: #000;
  border: 1px solid #ddd;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

#menuToggle {
  display: none;
  /* Mobile only */
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #555;
}

/* --- APP BODY (Sidebar + Main) --- */
.app-body {
  display: flex;
  flex: 1;
  /* Take remaining height */
  overflow: hidden;
  /* Contain scrolls */
  position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  /* Internal scroll */
  flex-shrink: 0;
  display: block;
  /* Visible on desktop */
}

/* Tree Styles */
.tree-view {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tree-item {
  border-bottom: 1px solid #f0f0f0;
}

.tree-parent {
  padding: 15px 20px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  background: #fff;
  transition: 0.2s;
}
.tree-parent:hover {
  background: #f9f9f9;
}

.tree-children {
  display: none;
  background: #f8f9fa;
  list-style: none;
  padding: 0;
}
.tree-children.open {
  display: block;
}

.tree-child {
  padding: 10px 20px 10px 40px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
  border-left: 3px solid transparent;
}
.tree-child:hover {
  background: #eef;
  color: var(--primary);
}
.tree-child.active {
  background: #e6f2ff;
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: bold;
}
.badge {
  background: #eee;
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 12px;
  color: #666;
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  /* Internal scroll */
  padding: 20px;
  /* Important: Extra bottom padding so buttons aren't cut off */
  padding-bottom: 80px;
  scroll-behavior: smooth;
}

/* Controls */
.controls-area {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  background: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.controls-area input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Cards */
.q-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  border-left: 0px solid var(--primary);
  animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

.q-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.q-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 15px;
  line-height: 1.5;
}

.opt-btn {
  width: 100%;
  text-align: left;
  padding: 12px 15px;
  margin: 5px 0;
  background: #f8f9fa;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
}
.opt-btn:hover:not(:disabled) {
  background: #e2e6ea;
}
.correct {
  background-color: #d4edda !important;
  color: #155724 !important;
  border-color: #c3e6cb !important;
}
.wrong {
  background-color: #f8d7da !important;
  color: #721c24 !important;
  border-color: #f5c6cb !important;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
.page-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.jump-input {
  width: 50px;
  text-align: center;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Skeleton */
.skeleton-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  border-left: 4px solid #e0e0e0;
}
.sk-line {
  height: 12px;
  background: #eee;
  margin-bottom: 10px;
  border-radius: 4px;
  animation: pulse 1.5s infinite;
}
.sk-title {
  height: 20px;
  width: 80%;
  margin-bottom: 20px;
  background: #e0e0e0;
}
.sk-opt {
  height: 40px;
  margin-bottom: 8px;
}
@keyframes pulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.6;
  }
}

/* Footer */
.app-footer {
  text-align: center;
  margin-top: 40px;
  border-top: 1px solid #eee;
  padding-top: 20px;
  color: #777;
  font-size: 0.85rem;
}

.seo-text {
  background: #fff;
  padding: 15px;
  margin: 10px 0;
  border-radius: 8px;
  font-size: 0.9em;
  color: #555;
  line-height: 1.6;
  border-left: 0px solid var(--primary, #007bff);
}
.seo-text h2 {
  font-size: 1.1em;
  margin-bottom: 5px;
  color: #333;
}

/* Brand as H1 for SEO */
h1.brand {
  font-size: 1.2rem;
  margin: 0;
  color: inherit;
  font-weight: bold;
  display: inline-block;
}

footer {
  text-align: center;
  padding: 20px;
  margin-top: 30px;
  background-color: #f4f4f4;
  color: #666;
  font-size: 0.9rem;
  border-top: 1px solid #ddd;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
  body::after {
    content: "shifat100.github.io";
    position: fixed;
    top: 40%;
    left: 7%;
    font-size: 40px;
    color: rgba(0,0,0,0.1);
    transform: rotate(-30deg);
    pointer-events: none;
  }
  #menuToggle {
    display: block;
  }

  .sidebar {
    position: absolute;
    /* Take out of flow */
    top: 0;
    bottom: 0;
    left: -100%;
    /* Hide */
    width: 80%;
    max-width: 300px;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
  }
  .sidebar.show {
    left: 0;
  }

  #sidebarOverlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
  #sidebarOverlay.show {
    display: block;
  }
}
/* =========================================
   PRINT STYLES (@media print)
   ========================================= */
@media print {
  /* 1. Reset Layout for Document Flow */
  body, .app-body, .main-content {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
    position: static !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* 2. Hide Non-Printable Elements */
  .top-bar, /* Header */
  .sidebar, /* Sidebar */
  .controls-area, /* Search/Filter/Buttons */
  #menuToggle, /* Mobile Menu */
  #installBtn, /* Install Button */
  #sidebarOverlay, /* Mobile Overlay */
  #paginationControls, /* Pagination Buttons */
  .app-footer, /* Footer Links */
  .jump-input, /* Jump Input */
  button.page-btn,
  .seo-text {
    /* Extra Buttons */
    display: none !important;
  }

  /* 3. Style the Question List */
  #questionList {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* 4. Style Individual Cards for Paper */
  .q-card {
    break-inside: avoid;
    /* Prevent cutting question in half */
    page-break-inside: avoid;
    /* For older browsers */
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    margin-bottom: 20px !important;
    padding: 15px !important;
    background-color: #fff !important;
  }

  /* 5. Style Options (Remove button look) */
  .opt-btn {
    width: auto;
    background: none !important;
    border: 0px solid #eee !important;
    color: #000 !important;
    padding: 5px 10px !important;
    margin: 5px !important;
    text-align: left !important;
  }
  /* Styles for elements with the class .opt-btn */
  .opt-btn:has(.correct)::before {
    content: none;
  }

  /* Styles for elements that have .opt-btn but NOT .correct */
  /* This selector targets an element that has both classes mentioned, but the :not() negates the second one effectively */
  .opt-btn:not(.correct)::before {
    content: '◯ ';
    /* Add the bullet point */
    font-weight: bold;

  }

  /* 6. Keep Highlights (If you print a solved quiz) */
  .correct {
    border: 0px solid #000 !important;
    font-weight: bold !important;
  }

  .wrong {
    text-decoration: line-through;
    opacity: 0.6;
  }

  /* 7. Add a Header for the Printout */
  #questionList::before {
    content: "Daily GK - Question Sheet";
    display: block;
    font-size: 18pt;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
  }

  /* 8. Show current topic if available */
  #topicHeader {
    display: block !important;
    text-align: center;
    color: #000 !important;
    font-size: 12pt;
    margin-bottom: 10px;
  }
}

/* --- BACK TO TOP BUTTON --- */
#backToTop {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background-color: var(--primary);
  /* Uses your blue color */
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

#backToTop.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#backToTop:hover {
  background-color: var(--primary-dark);
  transform: translateY(-5px);
}

/* Hide on Print */
@media print {
  #backToTop {
    display: none !important;
  }
}

/* Adjust for Mobile so it doesn't cover content */
@media (max-width: 768px) {
  #backToTop {
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
}

/* Cart Badge */
.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: red;
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 50%;
  font-weight: bold;
}

/* Question Card Cart Button */
.cart-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: green;
  border: 0px solid rgba(255, 255, 255, 0.3);
  padding: 10px;
  border-radius: 50%; /* Circular button */
  width: 24px;
  height: 24px;
  margin: 4px;
  font-size: 32px;
  color: #fff;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: bold;
}

.cart-toggle-btn.added {
  background: #ff4757;
  color: white;
  transform: rotate(360deg);
  border: none;
}

/* Incremental Loading Status */
#loadStatus {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-bottom: 10px;
}

@media print {
  #cartViewBtn, #cartActions #exitCart, .cart-toggle-btn, .controls-area, .pagination {
    display: none !important;
  }
}