var Q = require('q')
var getCss = require('get-css');
var cssStatistics = require('css-statistics');
var hasPseudoClass = require('has-pseudo-class');
var hasPseudoElement = require('has-pseudo-element');
var isVendorPrefixed = require('is-vendor-prefixed');
var chalk = require('chalk');

module.exports = function cssStats(options, scrutinyData, callback) {
  var deferred = Q.defer();
  scrutinyData = scrutinyData || {};

  getCss(options.url.normalizedUrl)
    .then(function(css) {
      var stats = cssStatistics(css.css);
      var aggregates = stats.aggregates;

      scrutinyData.css = {
        vendorPrefixes: 0,
        pseudoElements: 0,
        pseudoClasses: 0,
        selectorCount: aggregates.selectors,
        mediaQueriesCount: aggregates.mediaQueries.length,
        colors: aggregates.colors.total,
        widths: aggregates.widths.total,
        fontSizes: aggregates.fontSizes.total,
        backgroundColors: aggregates.backgroundColors.total
      };

      stats.declarations.all.forEach(function(declaration) {
        if (declaration.type === 'declaration') {
          if (isVendorPrefixed(declaration.property)) {
            scrutinyData.css.vendorPrefixes++;
          }
        }
      });

      stats.selectors.forEach(function(selector) {
        if (hasPseudoClass(selector.selector)) {
          scrutinyData.css.pseudoClasses++;
        }

        if (hasPseudoElement(selector.selector)) {
          scrutinyData.css.pseudoElements++;
        }
      });

      if (options.verbose) {
        generateReport(scrutinyData);
      }

      deferred.resolve(scrutinyData);
    });

  return deferred.promise;
}

function generateReport(scrutinyData) {
  var reportStringLines = [
    chalk.bgGreen.underline.white('\n\nCSS Stats\n'),
    chalk.green('Total Selectors') + ' ' + scrutinyData.css.selectorCount,
    chalk.green('Vendor Prefixes') + ' ' + scrutinyData.css.vendorPrefixes,
    chalk.green('Pseudo Elements') + ' ' + scrutinyData.css.pseudoElements,
    chalk.green('Pseudo Classes') + ' ' + scrutinyData.css.pseudoClasses,
    chalk.green('Media Queries') + ' ' + scrutinyData.css.mediaQueriesCount,
    chalk.green('Background Colors') + ' ' + scrutinyData.css.backgroundColors,
    chalk.green('Colors') + ' ' + scrutinyData.css.colors,
    chalk.green('Widths') + ' ' + scrutinyData.css.widths,
    chalk.green('Font Sizes') + ' ' + scrutinyData.css.fontSizes
  ];

  console.log(reportStringLines.join('\n') + '\n');
}

@@ -668,24 +668,53 @@
 Classes: 0,%0A
+        longestSelector: '',%0A
         sele
@@ -742,24 +742,24 @@
 .selectors,%0A
-
         medi
@@ -1503,32 +1503,189 @@
 nts++;%0A        %7D
+%0A%0A        if (selector.selector.length %3E scrutinyData.css.longestSelector.length) %7B%0A          scrutinyData.css.longestSelector = selector.selector;%0A        %7D
 %0A      %7D);%0A%0A    
@@ -2182,16 +2182,16 @@
 ements,%0A
-
     chal
@@ -2252,24 +2252,102 @@
 udoClasses,%0A
+    chalk.green('Longest Selector') + ' ' + scrutinyData.css.longestSelector,%0A
     chalk.gr

Add longest selector, related to #13