/* ============================================
   ModForge Hub — Layout System
   Sidebar · Topbar · Grid · Responsive
   ============================================ */

/* ── Page Wrapper ── */
.page-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  width: 100%;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4) 0;
  z-index: var(--z-sticky);
  transition: width var(--transition-base);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-8);
  font-size: var(--text-xl);
  box-shadow: var(--glow-purple);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  width: 100%;
  padding: 0 var(--space-3);
}

.sidebar-nav-item {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-base);
  position: relative;
  cursor: pointer;
  margin: 0 auto;
}

.sidebar-nav-item:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.08);
}

.sidebar-nav-item.active {
  background: var(--gradient-hero);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: var(--text-white);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.15);
}

.sidebar-nav-item svg,
.sidebar-nav-item i {
  width: 22px;
  height: 22px;
  font-size: 20px;
}

/* Tooltip */
.sidebar-nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tooltip);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border-soft);
  z-index: var(--z-tooltip);
}

.sidebar-nav-item:hover::after {
  opacity: 1;
}

.sidebar-divider {
  width: 32px;
  height: 1px;
  background: var(--border-soft);
  margin: var(--space-3) auto;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  width: 100%;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100%;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(7, 11, 20, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-heading);
}

.topbar-search {
  position: relative;
  width: 320px;
}

.topbar-search input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4) 0 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: all var(--transition-base);
}

.topbar-search input::placeholder {
  color: var(--text-muted);
}

.topbar-search input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.topbar-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-action {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-base);
  position: relative;
}

.topbar-action:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.08);
}

.topbar-action .notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-soft);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-base);
}

.topbar-avatar:hover {
  border-color: var(--purple);
}

.topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Content Area ── */
.content {
  flex: 1;
  padding: var(--space-8);
  overflow-x: hidden;
  max-width: 100%;
}

.content-header {
  margin-bottom: var(--space-8);
}

.content-header h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-2);
}

.content-header p {
  font-size: var(--text-base);
  color: var(--text-secondary);
}

/* ── Grid System ── */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
}

.grid-metrics {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* ── Flex Utilities ── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ── Public Layout (no sidebar) ── */
.public-page {
  position: relative;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

.public-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  z-index: var(--z-sticky);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  margin: 0;
  box-shadow: 0 0 0 rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  /* No CSS transition — GSAP handles everything */
}

/* Logo base transition for GSAP-driven height */
.public-navbar .navbar-brand img {
  /* GSAP handles this */
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.navbar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--glow-purple);
}

.navbar-brand-text {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-white);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Link Hover Spell */
.navbar-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.navbar-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-hero);
  opacity: 0;
  border-radius: var(--radius-full);
  z-index: -1;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(0.8);
}

.navbar-link:hover {
  color: var(--text-white);
  text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.navbar-link:hover::before {
  opacity: 0.15;
  transform: scale(1);
}

.navbar-link.active {
  color: var(--text-white);
}

.navbar-link.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px var(--purple);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Mobile Menu Toggle ── */
.mobile-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 10;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:active {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple-light);
  border-color: rgba(139, 92, 246, 0.3);
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border-soft);
  padding: var(--space-16) 0 var(--space-8);
  background: rgba(7, 11, 20, 0.5);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-12);
  margin-bottom: var(--space-12);
}

.footer-brand p {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  max-width: 320px;
}

.footer-col h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.footer-col a {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-1) 0;
  transition: color var(--transition-fast);
}

.footer-col a:hover {
  color: var(--purple-light);
}

.footer-bottom {
  border-top: 1px solid var(--border-soft);
  padding-top: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-bottom p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Mobile-First App-Like Experience
   Touch targets ≥ 44px · No horizontal scroll
   ══════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 968px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .sidebar {
    transform: translateX(-100%);
    z-index: var(--z-modal);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(139, 92, 246, 0.15);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    padding: 0 var(--space-4);
  }

  .content {
    padding: var(--space-4);
  }

  .navbar-links {
    display: none;
  }

  .navbar-actions {
    display: none;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .topbar-search {
    width: 200px;
  }

  /* Navbar simplificado no mobile */
  .public-navbar {
    padding: 0 var(--space-4);
    height: 64px;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-auto {
    grid-template-columns: 1fr;
  }

  .grid-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  h1 {
    font-size: var(--text-2xl);
  }

  h2 {
    font-size: var(--text-xl);
  }

  h3 {
    font-size: var(--text-lg);
  }

  .topbar-search {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .footer-bottom {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }

  .footer {
    padding: var(--space-8) 0 var(--space-6);
  }

  .public-navbar {
    padding: 0 var(--space-3);
    height: 56px;
  }

  /* Prevent content overflow on all pages */
  .container {
    padding: 0 var(--space-4);
    max-width: 100%;
    overflow-x: hidden;
  }

  .content {
    padding: var(--space-3);
  }

  /* Tighter gap on mobile grids */
  .grid {
    gap: var(--space-4);
  }
}

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

  .public-navbar {
    padding: 0 var(--space-2);
  }

  .container {
    padding: 0 var(--space-3);
  }

  .content {
    padding: var(--space-2);
  }

  h1 {
    font-size: var(--text-xl);
  }

  h2 {
    font-size: var(--text-lg);
  }
}

/* ── Brand Logos Responsiveness ── */
.brand-logo {
  display: block;
  transition: all 0.3s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  max-width: 100%;
}

@media (max-width: 968px) {
  .brand-logo {
    height: 72px !important;
    max-height: 72px !important;
    width: auto !important;
    object-fit: contain !important;
  }
}

@media (max-width: 640px) {
  .brand-logo {
    height: 56px !important;
    max-height: 56px !important;
    width: auto !important;
    object-fit: contain !important;
  }
}

/* ── Mobile Drawer (App-like slide-in) ── */
.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(85vw, 320px);
  background: rgba(7, 11, 20, 0.98);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  box-shadow: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-drawer.open {
  transform: translateX(0);
  box-shadow: -10px 0 50px rgba(0, 0, 0, 0.8), -2px 0 20px rgba(139, 92, 246, 0.15);
}

/* Overlay backdrop when drawer is open */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  flex-shrink: 0;
}

.mobile-drawer-close {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mobile-drawer-close:hover,
.mobile-drawer-close:active {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.mobile-drawer-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.mobile-drawer-link {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-decoration: none;
  padding: 14px var(--space-4);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mobile-drawer-link:hover,
.mobile-drawer-link:active {
  color: var(--text-white);
  background: rgba(139, 92, 246, 0.08);
}

.mobile-drawer-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: var(--space-3) 0;
}
