:root {
  --primary-color: #2b486a;
  /* Dark Blue from Nav */
  --primary-hover: #1e3550;
  --bg-color: #ffffff;
  --card-bg: #e2e8f0;
  /* Grey from card top */
  --text-dark: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --toggle-off: #d1d5db;
  --toggle-on: var(--primary-color);
  --badge-bg: var(--primary-color);

  --nav-text: #e2e8f0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
}

/* Nav Bar */
.navbar {
  background-color: var(--primary-color);
  color: white;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  font-size: 0.9rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 30px;
}

.logo {
  font-size: 1.5rem;
  color: white;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 20px;
}

.nav-links li a,
.login-link {
  color: var(--nav-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-links li a:hover,
.login-link:hover {
  color: white;
}

/* Master Layout container */
.page-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.page-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #111;
}

.header-actions {
  display: flex;
  gap: 15px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  padding: 0 10px;
  width: 100%;
  max-width: 280px;
}

.search-box input {
  border: none;
  outline: none;
  padding: 10px;
  width: 100%;
  font-size: 0.9rem;
}

.search-box .search-icon {
  color: var(--text-muted);
}

.search-box .dropdown-icon {
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Layout: Sidebar & Content */
.content-layout {
  display: flex;
  gap: 40px;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.filter-group {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.filter-group:last-child {
  border-bottom: none;
}

.filter-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #222;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Toggle Switch Styles */
.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-item span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* The actual toggle logic hidden, styling a label */
.toggle-checkbox {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 16px;
  background-color: var(--toggle-off);
  border-radius: 16px;
  transition: all 0.3s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background-color: white;
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle-checkbox:checked+.toggle-switch {
  background-color: var(--toggle-on);
}

.toggle-checkbox:checked+.toggle-switch::after {
  transform: translateX(16px);
}

.toggle-checkbox:checked~span {
  color: var(--text-dark);
}

/* Main Content area */
.main-content {
  flex-grow: 1;
}

/* Grid definition */
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.hidden {
  display: none !important;
}

/* Loader */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Cards */
.card {
  border: 1px solid #ccc;
  border-radius: 5px;
  background: white;
  padding: 10px;
  margin-bottom: 20px;
}

.card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card-image {
  width: 100%;
  height: 200px;
  background: #f4f4f4;
  position: relative;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: blue;
  color: white;
  padding: 5px;
  border-radius: 5px;
  font-size: 12px;
}

.card-title {
  font-size: 18px;
  font-weight: bold;
  margin-top: 10px;
}

.card-equipment {
  font-size: 14px;
  color: #666;
  margin-top: 5px;
}



/* Responsive Breakpoints */
@media (max-width: 992px) {
  .exercise-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .content-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 30px;
  }

  .filter-group {
    flex: 1;
    min-width: 150px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .search-box {
    max-width: 100%;
    flex: 1;
  }
}

@media (max-width: 500px) {
  .exercise-grid {
    grid-template-columns: 1fr;
  }

  .navbar {
    padding: 0 15px;
    flex-wrap: wrap;
    height: auto;
    padding-bottom: 10px;
    padding-top: 10px;
    gap: 10px;
  }

  .nav-left {
    flex-wrap: wrap;
    gap: 15px;
  }

  .nav-links {
    display: none;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* --- Dark Mode Additions --- */
body.dark-mode {
  --bg-color: #1a202c;
  --text-dark: #f7fafc;
  --text-muted: #a0aec0;
  --card-bg: #2d3748;
  --border-color: #4a5568;
}

body.dark-mode .card,
body.dark-mode .search-box {
  background: var(--card-bg);
  border-color: var(--border-color);
}

body.dark-mode .search-box input {
  background: var(--card-bg);
  color: var(--text-dark);
}

body.dark-mode .search-box .search-icon,
body.dark-mode .search-box .dropdown-icon {
  color: var(--text-muted);
}

body.dark-mode .page-title,
body.dark-mode .filter-title,
body.dark-mode .card-title {
  color: var(--text-dark);
}

body.dark-mode #sortSelect {
  background: var(--card-bg);
  color: var(--text-dark);
  border-color: var(--border-color);
}