/* =============================================================
   SAFpedia — Marketplace (self-contained stylesheet)
   ============================================================= */
:root {
  --color-blue: #2563EB;
  --color-blue-deep: #12305C;
  --color-blue-light: #E8EFFD;
  --color-red: #D82F1E;
  --color-red-deep: #B02416;
  --color-red-light: #FCEAE8;
  --color-gold: #E8A93A;
  --color-gold-light: #FCF2E1;
  --color-white: #FFFFFF;
  --color-bg: #FFFFFF;
  --color-bg-alt: #F7F8FB;
  --color-text: #0B1220;
  --color-text-muted: #4A5568;
  --color-border: #E3E7F0;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --r-sm: 8px; --r-md: 14px; --r-lg: 22px;
  --shadow-card: 0 4px 24px rgba(11, 46, 89, 0.08);
  --shadow-pop: 0 12px 40px rgba(11, 46, 89, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body); color: var(--color-text); background: var(--color-bg);
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
:focus-visible { outline: 2px solid var(--color-blue); outline-offset: 3px; }

.section-container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* =============================================================
   Navbar (same structure/IDs as the rest of the site)
   ============================================================= */
.navbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.nav-container {
  max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 72px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand-logo {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  color: var(--color-blue); display: flex; align-items: baseline; gap: 2px;
}
.brand-logo::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-red); margin-left: 4px; align-self: flex-end; margin-bottom: 6px;
}
.nav-links { display: flex; align-items: center; gap: 34px; }
.nav-link {
  font-size: 15px; font-weight: 500; color: var(--color-text-muted);
  position: relative; padding: 6px 0; transition: color 0.2s ease;
}
.nav-link:hover, .nav-link.active { color: var(--color-blue); }
.nav-link.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--color-red); border-radius: 2px;
}
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { display: flex; align-items: center; gap: 4px; }
.nav-dropdown-menu {
  position: absolute; top: calc(100% + 14px); left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  min-width: 210px; padding: 10px;
  opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.nav-dropdown-menu a { display: block; padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; color: var(--color-text-muted); }
.nav-dropdown-menu a:hover, .nav-dropdown-menu a.active { background: var(--color-blue-light); color: var(--color-blue); }

.nav-right { display: flex; align-items: center; gap: 18px; }
.auth-status-container { display: flex; align-items: center; gap: 18px; }
.nav-signin { font-size: 15px; font-weight: 600; color: var(--color-blue); display: flex; align-items: center; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; padding: 12px 24px; border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--color-red); color: var(--color-white); box-shadow: 0 6px 18px rgba(216,47,30,0.28); }
.btn-primary:hover { background: var(--color-red-deep); transform: translateY(-1px); }
.btn-secondary { background: transparent; color: var(--color-blue); border: 1.5px solid var(--color-border); }
.btn-secondary:hover { border-color: var(--color-blue); color: var(--color-blue); }
.btn-sm { padding: 8px 16px; font-size: 13.5px; }

/* Avatar injected by course.js when a user is signed in */
.student-profile-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--color-blue); color: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}

.mobile-menu-btn { display: none; font-size: 26px; color: var(--color-blue); }
@media (max-width: 960px) {
  .nav-links, .nav-signin, .auth-status-container .nav-signin { display: none; }
  .mobile-menu-btn { display: block; }
}
.mobile-menu {
  position: fixed; top: 72px; left: 0; right: 0; bottom: 0;
  background: var(--color-white); z-index: 999; padding: 24px;
  transform: translateX(100%); transition: transform 0.3s ease; overflow-y: auto;
}
.mobile-menu.open { transform: translateX(0); }
.mobile-nav-link {
  display: block; padding: 16px 4px; font-size: 18px; font-weight: 600;
  color: var(--color-text); border-bottom: 1px solid var(--color-border);
}
.mobile-nav-link.active { color: var(--color-blue); }

/* =============================================================
   Filter hero
   ============================================================= */
.catalog-wrapper { background: var(--color-bg); }
.filter-hero {
  max-width: 820px; margin: 0 auto; padding: 64px 24px 40px; text-align: center;
}
.section-badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-red); background: var(--color-red-light); padding: 6px 14px; border-radius: 999px; margin-bottom: 16px;
}
.filter-hero h1 {
  font-family: var(--font-display); font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 600;
  color: var(--color-text); line-height: 1.2; margin-bottom: 14px;
}
.accent-highlight { color: var(--color-blue); font-style: italic; }
.filter-hero > p { font-size: 16px; color: var(--color-text-muted); max-width: 620px; margin: 0 auto 36px; }

/* Search + filter bar — the part that must never overflow */
.search-filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: stretch; justify-content: center;
}
.search-input-group {
  flex: 1 1 260px; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--color-white); border: 1.5px solid var(--color-border);
  border-radius: var(--r-md); padding: 0 16px;
}
.search-input-group ion-icon { color: var(--color-text-muted); font-size: 18px; flex-shrink: 0; }
.search-input-group input {
  flex: 1; min-width: 0; border: none; outline: none;
  padding: 13px 0; font-size: 15px; background: transparent; color: var(--color-text);
}
.select-group {
  flex: 1 1 180px; min-width: 0; max-width: 220px;
}
.select-group select {
  width: 100%; max-width: 100%; box-sizing: border-box;
  border: 1.5px solid var(--color-border); border-radius: var(--r-md);
  padding: 13px 14px; font-size: 15px; background: var(--color-white); color: var(--color-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234A5568' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 34px;
}
.select-group select:focus { border-color: var(--color-blue); }

@media (max-width: 720px) {
  .search-filter-bar { flex-direction: column; }
  .search-input-group, .select-group { flex: 1 1 auto; max-width: 100%; width: 100%; }
}

/* =============================================================
   Products grid
   ============================================================= */
.products-grid-container { max-width: 1240px; margin: 0 auto; padding: 16px 24px 96px; }
.products-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 24px;
}
.loading-placeholder, .empty-state, .error-state {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px;
  color: var(--color-text-muted); font-size: 15px;
}
.error-state { color: var(--color-red); }

.product-card {
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-pop); }

.card-banner { position: relative; aspect-ratio: 16 / 10; background: var(--color-bg-alt); overflow: hidden; }
.card-banner img { width: 100%; height: 100%; object-fit: cover; }

.badge-f {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.badge-f.video { background: rgba(37,99,235,0.9); color: var(--color-white); }
.badge-f.audio { background: rgba(232,169,58,0.92); color: var(--color-text); }
.badge-f.pdf { background: rgba(216,47,30,0.9); color: var(--color-white); }
.badge-f.live { background: rgba(18,48,92,0.92); color: var(--color-white); }
.badge-f ion-icon { font-size: 14px; }

.card-details { padding: 20px; display: flex; flex-direction: column; flex: 1; }
.category-meta {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--color-blue); margin-bottom: 8px;
}
.product-title {
  font-size: 17px; font-weight: 700; color: var(--color-text);
  margin-bottom: 6px; line-height: 1.35;
}
.product-vendor-link {
  display: inline-block; font-size: 13px; font-weight: 600;
  color: var(--color-blue); margin-bottom: 10px;
}
.product-vendor-link:hover { text-decoration: underline; }
.product-snippet {
  font-size: 14px; color: var(--color-text-muted);
  margin-bottom: 18px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-footer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 14px; border-top: 1px solid var(--color-border);
}
.product-cost { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--color-text); }

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

/* =============================================================
   Footer
   ============================================================= */
.footer { background: var(--color-text); color: rgba(255,255,255,0.7); padding: 72px 0 24px; }
.footer-container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 40px; padding-bottom: 48px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.footer-brand h3 { font-family: var(--font-display); color: var(--color-white); font-size: 22px; margin-bottom: 12px; }
.footer-brand p { font-size: 14px; margin-bottom: 20px; }
.social-links { display: flex; gap: 12px; }
.social-links a {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center; font-size: 17px; transition: background 0.2s ease;
}
.social-links a:hover { background: var(--color-red); }
.footer-links h4, .footer-contact h4 { color: var(--color-white); font-size: 14.5px; margin-bottom: 18px; }
.footer-links ul { display: flex; flex-direction: column; gap: 12px; }
.footer-links a { font-size: 14px; }
.footer-links a:hover { color: var(--color-white); }
.contact-item { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 12px; }
.contact-item ion-icon { color: var(--color-gold); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; padding-top: 24px; font-size: 13px; flex-wrap: wrap; gap: 12px; }
.footer-bottom-links { display: flex; gap: 20px; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }