/**
 * GoToolstack — Layout & Grid Architecture
 * Core Web Vitals (Zero CLS), Responsive Flex & Grid Systems.
 */

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-w);
  min-width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--line);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 45;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  cursor: pointer;
  position: sticky;
  top: -20px;
  background: var(--panel);
  z-index: 10;
  margin-top: -20px;
  padding-top: 24px;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-foot {
  margin-top: 16px;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  font-size: 0.73rem;
  color: var(--muted-2);
  line-height: 1.5;
}

/* Main Workspace */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 36px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.menu-btn {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  transition: background 0.15s ease;
}

.menu-btn:hover {
  background: var(--panel-2);
}

.top-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Container Structure */
.main-inner {
  display: flex;
  gap: 32px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 36px;
  align-items: flex-start;
}

.content-col {
  flex: 1;
  min-width: 0;
}

.content {
  padding: 24px 0 40px;
  width: 100%;
}

/* Sticky Right Rail (300x600 Half-Page Ad) */
.right-rail {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
  height: fit-content;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* IAB Standardized Zero-CLS Ad Containers & Revenue Optimization */
.ad-slot-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 18px 0;
  clear: both;
}

.ad-slot-resultUnder {
  margin: 24px 0 16px; /* 24px safety buffer below action buttons for AdSense compliance */
}

.ad-slot-inArticle {
  margin: 28px 0;
}

.ad-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
  margin-bottom: 5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ad-container {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease;
}

.ad-container-topLeaderboard, .ad-container-top {
  width: 100%;
  max-width: 970px;
  min-height: 90px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.ad-container-sidebarSticky, .ad-container-sidebar {
  width: 300px;
  min-height: 600px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.ad-container-resultUnder {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.ad-container-inArticle, .ad-container-infeed {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.ad-container-square {
  width: 100%;
  min-height: 250px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

/* Ad Placeholder Styling (High Aesthetic, Non-Distracting) */
.ad-placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  text-align: center;
}

.ad-badge-sp {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 4px;
  background: var(--brand-dim);
  color: var(--brand);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ad-dim-text {
  font-size: 0.72rem;
  color: var(--muted-2);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.03em;
}

/* In-Feed Grid Card Ad */
.tool-card.ad-card-infeed {
  background: var(--panel-2) !important;
  border: 1px dashed var(--brand) !important;
  cursor: pointer;
}

.tool-card.ad-card-infeed:hover {
  border-style: solid !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--brand-glow) !important;
}

.ad-infeed-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ad-infeed-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--brand-dim);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

/* Mobile Sticky Anchor Ad (320x50 / 320x100) */
.ad-anchor-mobile {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 64px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ad-anchor-mobile.closed {
  transform: translateY(100%) !important;
  pointer-events: none !important;
}

.ad-anchor-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 50px;
}

.ad-anchor-close {
  position: absolute;
  top: -12px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 95;
  transition: all 0.15s ease;
}

.ad-anchor-close:hover {
  background: var(--text);
  color: var(--bg);
  transform: scale(1.08);
}

/* Related Tools Section */
.related-tools-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.related-tools-head {
  margin-bottom: 20px;
}

.related-tools-head h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.related-tools-head p {
  color: var(--muted);
  font-size: 0.85rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

/* Hero Section */
.hero-minimal {
  padding: 32px 20px 24px;
  max-width: 840px;
  margin: 0 auto 36px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-dim);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.hero-minimal h1 {
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1.12;
  margin: 0 0 16px;
  background: linear-gradient(135deg, var(--text) 0%, var(--brand) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-minimal p {
  font-size: 1.12rem;
  color: var(--muted);
  max-width: 660px;
  margin: 0 auto;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* Category Filter Bar */
.category-filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 28px;
  flex-wrap: wrap;
}

.cat-filter-btn {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-filter-btn:hover {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--brand);
}

.cat-filter-btn.active {
  background: var(--brand);
  color: #FFFFFF;
  border-color: var(--brand);
  box-shadow: 0 4px 14px var(--brand-glow);
}

/* Home Section & Grid */
.home-section {
  margin-bottom: 40px;
}

.home-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.home-section-head .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.home-section-head h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}

/* Footer */
footer.app-footer {
  border-top: 1px solid var(--line);
  margin-top: auto;
  background: var(--panel);
}

.footer-inner {
  max-width: 1440px;
  padding: 32px 36px 40px;
  margin: 0 auto;
}

.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.footer-links a {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--brand);
}

.footer-disclaimer {
  color: var(--muted-2);
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: 800px;
}

.footer-author {
  margin-top: 14px;
  color: var(--muted-2);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .right-rail {
    display: none !important;
  }
  .main-inner {
    padding: 0 24px;
  }
}

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  [dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 10px;
  }

  .top-right {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-left: auto;
  }

  .main-inner {
    padding: 0 16px;
  }

  .hero-minimal h1 {
    font-size: 2.1rem;
  }

  .hero-minimal p {
    font-size: 0.98rem;
  }

  .top-search {
    order: 3;
    max-width: none;
    width: 100%;
    margin-top: 2px;
  }

  .ad-anchor-mobile {
    display: flex;
  }

  body {
    padding-bottom: 60px; /* offset for mobile anchor ad */
  }
}
