/* ===== General Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #0a0a0a;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== Background Gradients ===== */
.gradient-top-right {
  position: fixed;
  top: 0;
  right: 0;
  width: 45rem;
  height: 45rem;
  background: radial-gradient(
    circle,
    rgba(139, 92, 246, 0.3) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 1;
}

.gradient-bottom-left {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 45rem;
  height: 45rem;
  background: radial-gradient(
    circle,
    rgba(49, 46, 129, 0.4) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 1;
}

.blur-circle-1,
.blur-circle-2 {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 1;
}

.blur-circle-1 {
  top: -10rem;
  left: -10rem;
  width: 38rem;
  height: 38rem;
  background-color: rgba(139, 92, 246, 0.15);
}

.blur-circle-2 {
  bottom: -12rem;
  right: -12rem;
  width: 32rem;
  height: 32rem;
  background-color: rgba(49, 46, 129, 0.15);
}

.noise-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.35"/></svg>');
  z-index: 1;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
  background: linear-gradient(
    90deg,
    rgba(10, 10, 10, 0.95),
    rgba(25, 25, 25, 0.95)
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.brand {
  font-weight: 700;
  font-size: 1.3rem;
  color: white;
}

.page-title {
  margin-left: 0.8rem;
  font-size: 1rem;
  font-weight: 500;
  color: #bbb;
}

.header-container {
  max-width: 1280px;
  margin: auto;
  padding: 0 1rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
}

.menu-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.logo {
  width: 2.5rem;
  height: 2.5rem;
}

.header-buttons {
  display: flex;
  gap: 0.5rem;
}

.header-buttons a {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.btn-secondary {
  background-color: #171717;
  color: white;
  border: 1px solid #232b3b;
}

.btn-secondary:hover {
  background-color: #232b3b;
}

.btn-primary {
  background-color: #2feaaa;
  color: black;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ===== Layout ===== */
.main-wrapper {
  display: flex;
  flex: 1;
  position: relative;
  z-index: 10;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 20rem;
  background: linear-gradient(
    180deg,
    rgba(23, 23, 23, 0.95),
    rgba(28, 26, 46, 0.95)
  );
  padding: 1.5rem;
  border-right: 1px solid #232b3b;
  backdrop-filter: blur(10px);
  height: calc(100vh - 4rem);
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar.mobile-hidden {
  transform: translateX(-100%);
}

.dropdown,
.search-input {
  width: 100%;
  padding: 0.75rem;
  background-color: #0a0a0a;
  border: 1px solid #232b3b;
  color: white;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: #666;
}

.section-title {
  margin-top: 1.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.topics-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.topic-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
  text-align: left;
}

.topic-btn:hover {
  background-color: rgba(47, 234, 170, 0.08);
}

.topic-btn.active {
  background-color: #232b3b;
  color: #2feaaa;
  box-shadow: 0 0 8px rgba(47, 234, 170, 0.5);
}

.patterns-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.pattern-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid #2a2a2a;
  background-color: #171717;
  color: white;
  cursor: pointer;
  transition: all 0.25s ease;
}

.pattern-btn:hover {
  background-color: #232b3b;
  transform: scale(1.02);
  box-shadow: 0 0 10px rgba(47, 234, 170, 0.6);
}

.pattern-btn.active {
  background-color: #2feaaa;
  color: black;
  font-weight: 600;
  border: none;
  transform: scale(1.02);
  box-shadow: 0 0 12px rgba(47, 234, 170, 0.8);
}

/* ===== Questions ===== */
.questions-container {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  height: calc(100vh - 4rem);
}

.difficulty-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.difficulty-btn {
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  background-color: #171717;
  border: 1px solid #232b3b;
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.difficulty-btn:hover {
  background-color: #232b3b;
}

.difficulty-btn.active {
  background-color: #2feaaa;
  color: black;
  border: none;
}



.questions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.question-card {
  background-color: #1a1a1a;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  min-height: 240px;
  position: relative;
  transition: all 0.3s ease;
}

.question-card:hover {
  border: 1px solid transparent;
  background-image: linear-gradient(#1a1a1a, #1a1a1a),
    linear-gradient(90deg, #2feaaa, #7a5fff);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0px 8px 25px rgba(0, 0, 0, 0.5);
  transform: translateY(-4px);
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.tag {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  border-radius: 0.4rem;
  font-weight: 500;
}

.tag.easy {
  background-color: #14532d;
  color: #bbf7d0;
}

.tag.medium {
  background-color: #78350f;
  color: #fde68a;
}

.tag.hard {
  background-color: #7f1d1d;
  color: #fecaca;
}

.tag.important {
  background-color: #4c1d95;
  color: #ddd6fe;
  border: 1px solid #8b5cf6;
  font-weight: 600;
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.3);
  }
  to {
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.7);
  }
}

.done-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #ccc;
  white-space: nowrap;
}

.done-checkbox {
  width: 1rem;
  height: 1rem;
}

.title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #fff;
  line-height: 1.3;
}

.desc {
  font-size: 0.9rem;
  color: #b0b0b0;
  line-height: 1.4;
  flex-grow: 1;
  margin-bottom: 1rem;
}

.actions {
  margin-top: auto;
  margin-bottom: 0.5rem;
}

.link-btn {
  color: #2feaaa;
  font-size: 0.9rem;
  text-decoration: none;
  font-weight: 600;
}

.link-btn:hover {
  color: white;
}

.pattern-bottom {
  align-self: flex-end;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ccc;
  background-color: #232b3b;
  border-radius: 0.4rem;
  margin-top: auto;
}

.important-label {
  color: #a78bfa;
  font-weight: 600;
  animation: glow-text 1.5s ease-in-out infinite alternate;
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  background-color: rgba(139, 92, 246, 0.2);
  border: 1px solid #6d28d9;
}

@keyframes glow-text {
  from {
    text-shadow: 0 0 2px rgba(139, 92, 246, 0.3);
  }
  to {
    text-shadow: 0 0 5px rgba(139, 92, 246, 0.8);
  }
}

/* Background Canvas */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: #0a0a0a;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* When sidebar is open, prevent body scrolling but allow sidebar to scroll */
body.sidebar-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet Styles */
@media (max-width: 1024px) {
  .sidebar {
    width: 18rem;
  }

  .questions-container {
    padding: 1.5rem;
  }

  .questions-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
  }

  .header-buttons a {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }

  /* Adjust background elements for smaller screens */
  .gradient-top-right,
  .gradient-bottom-left {
    width: 35rem;
    height: 35rem;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .page-title {
    display: none;
  }

  .header-buttons {
    gap: 0.25rem;
  }

  .header-buttons a {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .main-wrapper {
    position: relative;
  }

  /* Mobile sidebar positioning */
  .sidebar {
    position: fixed;
    top: 4rem;
    left: 0;
    width: 80%;
    max-width: 300px;
    z-index: 101;
    bottom: 0; /* Explicitly set bottom position */
    height: calc(100vh - 4rem); /* Full viewport height minus header */
    transform: translateX(-100%);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide overflow at container level */
    padding: 0; /* Remove padding */
  }

  /* Sidebar header that stays fixed */
  .sidebar-header {
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
    flex-shrink: 0;
  }

  /* Scrollable content area */
  .sidebar-scrollable-content {
    flex: 1;
    overflow-y: auto; /* This is the scrollable part */
    -webkit-overflow-scrolling: touch;
    padding: 0 1.5rem 3rem 1.5rem;
  }

  .sidebar.mobile-visible {
    transform: translateX(0);
    overflow-y: scroll !important; /* Force scroll again for specificity */
  }

  /* Only show overlay on mobile when active */
  .sidebar-overlay {
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .questions-container {
    width: 100%;
    padding: 1rem;
  }

  .questions-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .difficulty-filters {
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
  }

  .difficulty-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    min-width: max-content;
  }

  .question-card {
    padding: 1.25rem;
    min-height: 200px;
  }

  .top-row {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .done-container {
    align-self: flex-end;
    margin-top: -0.5rem;
  }

  .tags {
    gap: 0.4rem;
  }

  .tag {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }

  .title {
    font-size: 1rem;
  }

  .desc {
    font-size: 0.85rem;
  }

  /* Adjust background elements for mobile */
  .gradient-top-right,
  .gradient-bottom-left {
    width: 30rem;
    height: 30rem;
  }

  .blur-circle-1,
  .blur-circle-2 {
    width: 25rem;
    height: 25rem;
  }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
  .header-container {
    padding: 0 0.75rem;
  }

  .logo {
    width: 2rem;
    height: 2rem;
  }

  .brand {
    font-size: 1.1rem;
  }

  .header-buttons a {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  .sidebar {
    padding: 1rem;
    max-width: 18rem;
  }

  .questions-container {
    padding: 0.75rem;
  }

  .question-card {
    padding: 1rem;
    min-height: 180px;
  }

  .title {
    font-size: 0.95rem;
  }

  .desc {
    font-size: 0.8rem;
  }

  .difficulty-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .pattern-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .dropdown,
  .search-input {
    padding: 0.6rem;
    font-size: 0.85rem;
  }

  .section-title {
    font-size: 1rem;
  }
}

/* Extra Small Mobile */
@media (max-width: 360px) {
  .header-container {
    padding: 0 0.5rem;
  }

  .sidebar {
    max-width: 16rem;
  }

  .questions-container {
    padding: 0.5rem;
  }

  .question-card {
    padding: 0.75rem;
  }

  .difficulty-filters {
    gap: 0.25rem;
  }

  .difficulty-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
  }
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Focus styles for accessibility */
button:focus,
input:focus,
select:focus {
  outline: 2px solid #2feaaa;
  outline-offset: 2px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}
