/* ═══════════════════════════════════════════
   LOCAL SEO TOOL — Layout System
   ═══════════════════════════════════════════ */

/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-base);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--lh-normal);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::selection {
  background: var(--primary-muted);
  color: var(--primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ═══════════════════════════════════════════
   App Shell
   ═══════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
  position: relative;
}

/* ─── Background Glow Effect ─── */
.app::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: var(--gradient-glow);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
  height: 100vh;
  overflow: hidden;
  transition: width var(--duration-slow) var(--ease-out);
  position: relative;
}

/* ─── Sidebar Header / Logo ─── */
.sidebar-header {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  height: var(--topbar-height);
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-sm);
}

.sidebar-logo svg {
  width: 22px;
  height: 22px;
  color: white;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.sidebar-subtitle {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
}

/* ─── Sidebar Navigation ─── */
.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.nav-item.active {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: rgba(14, 165, 233, 0.15);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item svg,
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item:hover svg,
.nav-item.active svg {
  opacity: 1;
}

.nav-item .nav-label {
  flex: 1;
  min-width: 0;
}

.nav-badge {
  font-size: var(--fs-2xs);
  background: var(--primary-muted);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: var(--fw-semibold);
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  transition: all var(--duration-fast) ease;
}

.theme-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════
   Main Content Area
   ═══════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
  z-index: var(--z-base);
}

/* ─── Top Bar ─── */
.topbar {
  height: var(--topbar-height);
  background: var(--glass-bg-heavy);
  backdrop-filter: var(--glass-blur-light);
  -webkit-backdrop-filter: var(--glass-blur-light);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  flex-shrink: 0;
  z-index: var(--z-sticky);
}

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

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.mobile-menu-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.topbar-breadcrumb {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar-breadcrumb .breadcrumb-sep {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.topbar-breadcrumb .breadcrumb-current {
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
}

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

/* ─── Content Area ─── */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-8);
  scroll-behavior: smooth;
}

.content-wrapper {
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

/* ═══════════════════════════════════════════
   Module Sections
   ═══════════════════════════════════════════ */
.module-section {
  display: none;
  animation: moduleEnter var(--duration-slow) var(--ease-out);
}

.module-section.active {
  display: block;
}

.module-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.module-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.module-icon-wrap svg {
  width: 28px;
  height: 28px;
  color: white;
}

.module-header-text {
  flex: 1;
  min-width: 0;
}

.module-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
  margin-bottom: var(--space-1-5);
}

.module-description {
  color: var(--text-secondary);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  max-width: 560px;
}

.module-body {
  position: relative;
}

/* ═══════════════════════════════════════════
   Grid Utilities
   ═══════════════════════════════════════════ */
.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-fit { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-auto-fill { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.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-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }

/* ─── Text ─── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-accent { color: var(--accent); }
.text-gradient {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Spacing ─── */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* ═══════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════ */
@keyframes moduleEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes scoreReveal {
  from { stroke-dashoffset: var(--ring-circumference); }
  to { stroke-dashoffset: var(--score-offset, 0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

/* Stagger animation utility */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
.stagger-7 { animation-delay: 350ms; }
.stagger-8 { animation-delay: 400ms; }

/* ═══════════════════════════════════════════
   Sidebar Mobile Overlay
   ═══════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--duration-normal) ease;
}

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

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

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

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-2xl);
  }

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

  .mobile-menu-btn {
    display: flex !important;
  }

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

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

  .grid.grid-2,
  .grid.grid-3,
  .grid.grid-4 {
    grid-template-columns: 1fr;
  }

  .module-header {
    flex-direction: column;
    gap: var(--space-4);
  }

  .module-title {
    font-size: var(--fs-xl);
  }
}

@media (max-width: 480px) {
  .content-area {
    padding: var(--space-4);
  }

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

  .module-icon-wrap {
    width: 44px;
    height: 44px;
  }

  .module-icon-wrap svg {
    width: 22px;
    height: 22px;
  }
}
