/* ================================
   Math Stuff Pro - Full Stylesheet (Fixed Version)
   ================================ */

/* -------- Base -------- */
:root {
  --bg: #f4f4f6;
  --text: #1a1a1a;
  --card: #ffffff;
  --border: #dcdcdc;
  --accent: #3c78d8;
  --muted: #666;
  --menu-btn-bg: #eaeaea;
  --menu-btn-color: #000;
}

body.dark {
  --bg: #1e1f22;
  --text: #f2f2f2;
  --card: #2a2b2f;
  --border: #3d3e42;
  --accent: #5b8cff;
  --muted: #aaa;
  --menu-btn-bg: #333;
  --menu-btn-color: #fff;
}

/* -------- Reset & Base Layout -------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Roboto", sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* -------- Sidebar -------- */
#sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  width: 240px;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
  padding-top: 60px;
}

#sidebar.collapsed {
  width: 70px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s;
  position: relative;
}

.nav-link img {
  width: 24px;
  height: 24px;
}

.nav-link span {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

#sidebar.collapsed .nav-link span {
  opacity: 0;
}

/* highlight bar / active tab */
.nav-link.active {
  background: var(--accent);
  color: #fff;
  border-radius: 0 25px 25px 0;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 5px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.nav-link:hover {
  background: var(--border);
}

/* -------- Topbar -------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  z-index: 10;
}

#menu-btn {
  background: var(--menu-btn-bg);
  color: var(--menu-btn-color);
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s;
}

#menu-btn:hover {
  background: var(--accent);
  color: #fff;
}

.logo {
  height: 32px;
  cursor: pointer;
}

.title {
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

/* -------- Main Content -------- */
.main {
  flex: 1;
  padding: 80px 24px 24px 24px;
  overflow-y: auto;
}

/* -------- Cards -------- */
.welcome,
.suggest,
.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

h2,
h3 {
  margin-bottom: 12px;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s;
}

.button:hover {
  background: #2c66cc;
}

/* -------- Search Bar & Game Cards -------- */
#search {
  width: 100%;
  max-width: 400px;
  padding: 10px;
  margin-bottom: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

#game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.game-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.game-card img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 8px;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.muted {
  color: var(--muted);
  text-align: center;
}

/* -------- Settings Switch (Styled Checkbox) -------- */
.settings-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 16px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  border-radius: 34px;
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* -------- Game Player Page -------- */
.game-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#game-frame {
  width: 100%;
  height: calc(100vh - 200px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
}

.game-header h2 {
  margin: 0;
  font-weight: 500;
  font-size: 20px;
}

.game-controls {
  display: flex;
  gap: 10px;
}

.game-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  background: var(--menu-btn-bg);
  color: var(--menu-btn-color);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.game-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* -------- Scrollbar -------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent);
}

/* -------- Responsive -------- */
@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    z-index: 9;
    left: -240px;
  }

  #sidebar.collapsed {
    left: 0;
  }

  .main {
    padding: 80px 16px 16px 16px;
  }
}
