/*
  NexusMarket — Layout & Navigation
  Three-column grid, fixed navbar, responsive breakpoints
*/

/* === FIXED NAVIGATION BAR === */
.nav-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  height: var(--nav-height);
  background: rgba(10, 10, 11, 0.88);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
}

/* Brand logo */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.3px;
}

.brand-logo {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
}

/* Nav center tabs — absolutely centered in the navbar regardless of side widths */
.nav-center {
  display: flex;
  gap: 2px;
  align-items: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.nav-tab {
  position: relative;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
}

.nav-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 55%;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
  transition: transform var(--ease), box-shadow var(--ease);
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.nav-tab.active {
  color: var(--text-primary);
}

.nav-tab.active::after {
  transform: translateX(-50%) scaleX(1);
  box-shadow: 0 2px 8px rgba(232, 118, 75, 0.35), 0 1px 3px rgba(232, 118, 75, 0.2);
}

/* Nav end (balance + auth) */
.nav-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-balance {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color var(--ease), color var(--ease);
}

.nav-balance:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* Logged-in: add balance pill (solid orange, compact) */
.nav-addbal {
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  padding: 5px 10px;
  margin-right: 2px;
  white-space: nowrap;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}

.nav-addbal:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(232, 118, 75, 0.3);
  transform: translateY(-1px);
}

/* Logged-in: admin shortcut */
.nav-admin {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  padding: 6px 12px;
  border: 1px solid rgba(232, 118, 75, 0.4);
  border-radius: var(--radius-sm);
  transition: background var(--ease), box-shadow var(--ease);
}

.nav-admin:hover {
  background: rgba(232, 118, 75, 0.12);
  box-shadow: 0 2px 10px rgba(232, 118, 75, 0.2);
}

/* Logged-in: user chip */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color var(--ease);
}

.nav-user:hover { border-color: var(--border-hover); }

.nav-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  overflow: hidden;
  flex-shrink: 0;
}
.nav-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }

/* "N Escrow" pill in the nav when a deal awaits the user's funding. */
.nav-escrow {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
  color: #1c1405;
  background: linear-gradient(135deg, #f5a623, #e8764b);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(232, 118, 75, 0.35);
  transition: transform 0.15s ease;
}
.nav-escrow:hover { transform: translateY(-1px); }

/* Notification bell + unread badge in the nav. */
.nav-bell {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-bell:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-bell-badge {
  position: absolute; top: 1px; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 800; line-height: 1;
  color: #fff; background: #e8584f; border-radius: 999px;
  border: 2px solid var(--bg, #14110d);
}

.nav-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
}

.nav-btn-ghost {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
}

.nav-btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn-fill {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  padding: 8px 18px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}

.nav-btn-fill:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(232, 118, 75, 0.3);
  transform: translateY(-1px);
}

/* Hamburger (mobile) */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-primary);
}

.nav-hamburger svg { display: block; }

/* Mobile menu overlay */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 998;
  padding: 24px;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.mobile-menu.open { display: flex; }

/* CSS-only toggle: the hidden #nav-toggle checkbox drives the menu (no JS) */
#nav-toggle:checked ~ .mobile-menu { display: flex; }

/* Let a tall menu scroll on short screens */
.mobile-menu { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.mobile-menu .nav-tab {
  font-size: 1rem;
  padding: 14px 16px;
  border-radius: var(--radius);
}

.mobile-menu .nav-tab.active { background: var(--surface); }

.mobile-menu .mobile-auth {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* === PAGE SYSTEM === */
.page { display: none; }
.page.active { display: block; }

/* === THREE-COLUMN LAYOUT === */
.layout-three-col {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  gap: 28px;
  max-width: var(--max-width);
  margin: calc(var(--nav-height) + 16px) auto 0;
  padding: 28px 24px;
}

/* === AD SIDEBARS === */
.sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  height: calc(100vh - var(--nav-height) - 32px);
  overflow: hidden;
}

.sidebar-track {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: sidebar-slide 24s linear infinite;
}

.sidebar-track-reverse {
  animation: sidebar-slide-up 24s linear infinite;
}

@keyframes sidebar-slide {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

@keyframes sidebar-slide-up {
  0% { transform: translateY(-50%); }
  100% { transform: translateY(0); }
}

.ad-slot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--ease);
}

.ad-slot:hover { border-color: var(--border-hover); }

.ad-visual {
  width: 100%;
  height: 70px;
  border-radius: var(--radius-sm);
  opacity: 0.7;
}

.v1 { background: linear-gradient(145deg, #2d1b40, #1a0f2a); }
.v2 { background: linear-gradient(145deg, #1a3020, #0f2015); }
.v3 { background: linear-gradient(145deg, #3e2a10, #261a08); }
.v4 { background: linear-gradient(145deg, #3e1020, #260812); }
.v5 { background: linear-gradient(145deg, #102a3e, #081826); }

.ad-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 500;
}

.ad-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* === CONTENT AREA === */
.content { min-width: 0; }

/* === LISTINGS PAGE LAYOUT === */
.listings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  max-width: 1200px;
  margin: calc(var(--nav-height) + 16px) auto 0;
  padding: 28px 24px;
}

.listings-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  height: fit-content;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.listings-main { min-width: 0; }

.listings-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.listings-head h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.listings-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* === FOOTER === */
.foot {
  margin-top: 56px;
  padding: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 60; /* sit above the fixed ad rails so they never overlap footer text */
}

.foot-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 34px 24px 24px;
}

.foot-top {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 30px;
}

.foot-brand-col .brand-logo {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.foot-brand-col p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 260px;
}

.foot-col h4 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.foot-col a {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: color var(--ease), padding-left var(--ease);
}

.foot-col a:hover {
  color: var(--text-primary);
  padding-left: 4px;
}

.foot-newsletter {
  margin-top: 16px;
}

.foot-newsletter p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.foot-newsletter-form {
  display: flex;
  gap: 8px;
}

.foot-newsletter-form input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: border-color var(--ease);
}

.foot-newsletter-form input::placeholder {
  color: var(--text-muted);
}

.foot-newsletter-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 118, 75, 0.1);
}

.foot-newsletter-form button {
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background var(--ease);
}

.foot-newsletter-form button:hover {
  background: var(--primary-hover);
}

.foot-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.foot-copy {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.foot-bottom-links {
  display: flex;
  gap: 18px;
}

.foot-bottom-links a {
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: color var(--ease);
}

.foot-bottom-links a:hover {
  color: var(--text-secondary);
}

/* Legacy footer compat */
.foot-links { display: flex; gap: 20px; }
.foot-links a {
  font-size: 0.76rem;
  color: var(--text-muted);
  transition: color var(--ease);
}
.foot-links a:hover { color: var(--text-primary); }

/* === RESPONSIVE: Sidebars collapse below 1100px === */
@media (max-width: 1100px) {
  .layout-three-col {
    grid-template-columns: 1fr;
  }
  .sidebar { display: none; }

  .foot-top {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

/* === RESPONSIVE: collapse nav to hamburger on tablets/phones (≤900px) === */
@media (max-width: 900px) {
  .nav-center { display: none; }
  .nav-balance { display: none; }
  .nav-hamburger { display: block; }
  /* On mobile the top bar is just brand + hamburger; everything else lives
     inside the slide-down menu. */
  .nav-end a { display: none; }
}

/* === RESPONSIVE: Tablet — 768px === */
@media (max-width: 768px) {
  .listings-layout { grid-template-columns: 1fr; }
  .listings-sidebar { position: static; }

  .foot-top {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  .foot-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* === RESPONSIVE: Mobile — 480px === */
@media (max-width: 480px) {
  .nav-inner { padding: 0 16px; }
  .nav-end .nav-btn-ghost,
  .nav-end .nav-btn-fill { display: none; }

  .layout-three-col { padding: 16px; }
}

/* === FLOATING SUPPORT WIDGET (every page) ============================= */
.support-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  text-decoration: none;
}

/* The round launcher bubble. */
.support-widget-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-on-accent, #0f0f0f);
  background: linear-gradient(135deg, var(--accent-primary, #e8764b), var(--secondary, #f5a623));
  box-shadow: 0 8px 24px rgba(232, 118, 75, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  flex-shrink: 0;
}
.support-widget:hover .support-widget-bubble,
.support-widget:focus-visible .support-widget-bubble {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 30px rgba(232, 118, 75, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* The popover card — hidden until hover / keyboard focus. */
.support-widget-card {
  width: 250px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-raised, #1c1c22);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.support-widget:hover .support-widget-card,
.support-widget:focus-within .support-widget-card {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.support-widget-card strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}
.support-widget-card p {
  margin: 6px 0 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.support-widget-cta {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-hover, #f09050);
}

@media (max-width: 600px) {
  .support-widget { right: 16px; bottom: 16px; }
  .support-widget-bubble { width: 50px; height: 50px; }
  .support-widget-card { width: 210px; }
}
