* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Nunito", sans-serif;
  /* border: 1px solid; */
}

:root {
  --sidebar-width: 250px;
  --header-height: 60px;
}

/* Apply background color to body */
body {
  background-color: var(--bg-color);
  min-height: 100vh;
  transition: background-color 0.3s ease;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
  padding: 0 2rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem;
}

.theme-select {
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--card-bg-color);
  color: var(--text-color);
  font-size: 0.9rem;
  cursor: pointer;
}

.theme-select:hover {
  border-color: var(--primary-color);
}

.bgm-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  padding: 5px;
  transition: transform 0.2s;
}

.bgm-toggle:hover {
  transform: scale(1.1);
}

.main-header {
  background: var(--header-bg);
  color: var(--text-color);
  padding: 0 2rem;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.page-title {
  text-align: center;
  margin: 0;
  flex: 1;
}

.page-title a {
  text-decoration: none;
  color: var(--header-text);
  font-size: 1.5rem;
}

.theme-toggle {
  background-color: var(--secondary-color);
  border: none;
  padding: 10px;
  cursor: pointer;
  border-radius: 5px;
  color: var(--text-color);
  font-weight: bold;
  transition: background-color 0.3s;
}

.theme-toggle:hover {
  background-color: var(--tertiary-color);
}

/* Layout Container */
.container {
  margin-top: var(--header-height); /* Use the header height variable */
  display: flex;
  min-height: calc(100vh - var(--header-height));
  position: relative;
  padding-top: 20px;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--primary-color);
  overflow: hidden;
  transition: width 0.3s ease;
  padding: 20px;
}

.sidebar.collapsed {
  width: 0;
  padding: 0;
}

/* Sidebar Toggle Button (Outside the Sidebar) */
.sidebar-toggle {
  position: absolute;
  top: 20px; /* Changed from 40px to align better with sidebar content */
  left: 0;
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  border: none;
  cursor: pointer;
  border-radius: 0 5px 5px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: left 0.3s, background-color 0.3s;
  z-index: 10;
}

.sidebar-toggle:hover {
  background-color: var(--secondary-color);
}

.sidebar h2 {
  text-align: center;
  margin-top: 0;
  color: var(--text-color);
}

/* Dropdown Menu in Sidebar */
.dropdown {
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--sidebar-bg, rgba(255, 255, 255, 0.05));
  border: none;
  width: 100%;
  color: var(--text-color);
}

.dropdown:hover {
  background-color: var(--hover-color, rgba(255, 255, 255, 0.1));
}

.dropdown .icon {
  transition: transform 0.3s ease;
}

.dropdown.active .icon {
  transform: rotate(180deg);
}

.dropdown-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background-color: var(--dropdown-bg, rgba(255, 255, 255, 0.05));
}

.dropdown-content div {
  padding: 10px 20px;
  cursor: pointer;
}

.dropdown-content div:hover {
  background-color: var(--hover-color, rgba(255, 255, 255, 0.1));
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 20px;
  transition: margin 0.3s;
  background-color: var(--bg-color);
}

/* Card Grid: Utilize all available space */
.card-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-5px);
}

.card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.card h3 {
  margin-top: 10px;
  font-size: 1.2rem;
  text-align: center;
}

/* Button Group inside Cards: arranged in 2 rows */
.button-group {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row button {
  flex: 1;
  background-color: var(--tertiary-color);
  color: var(--text-color);
  border: none;
  border-radius: 4px;
  padding: 10px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.button-row button:hover {
  background-color: var(--secondary-color);
}

/* Responsive Adjustments for Smaller Devices */
@media (max-width: 768px) {
  .container {
    display: block;
    margin-top: var(--header-height);
  }

  /* Sidebar becomes an overlay */
  .sidebar {
    position: fixed;
    top: var(--header-height); /* Use the header height variable */
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
  }

  .sidebar.collapsed {
    width: 0;
    padding: 0;
  }

  /* Sidebar toggle button becomes fixed near top left */
  .sidebar-toggle {
    position: fixed;
    top: 70px; /* Positioned below the header */
    left: 10px;
    width: 40px;
    height: 40px;
    z-index: 1100;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.2rem;
  }

  .theme-toggle {
    padding: 8px;
    font-size: 0.9rem;
  }
}

/* SVG Icons */
.sidebar-toggle svg path,
.sidebar .dropdown svg path {
  stroke: var(--text-color);
}

.sidebar-toggle:hover svg path {
  stroke: white;
}
