#!/bin/bash

echo "==========================================="
echo "   BLOG PAGE DRAWER FIX VERIFICATION"
echo "==========================================="
echo ""

# Test the blog page specifically
echo "✓ Testing Blog Page Drawer Fix..."
echo ""

# Check HTML structure
echo "1. Blog HTML Structure:"
BLOG_CART=$(curl -s http://localhost:5000/blog | grep 'class="cart-drawer"')
BLOG_WISHLIST=$(curl -s http://localhost:5000/blog | grep 'class="wishlist-drawer"')

if [ ! -z "$BLOG_CART" ] && [ ! -z "$BLOG_WISHLIST" ]; then
    echo "   ✓ Cart drawer: Found (no .open class)"
    echo "   ✓ Wishlist drawer: Found (no .open class)"
else
    echo "   ✗ Drawer elements not found"
fi

echo ""
echo "2. CSS Version:"
CSS_VERSION=$(curl -s http://localhost:5000/blog | grep -o 'modern-theme.css?v=[^"]*')
echo "   ✓ $CSS_VERSION"

echo ""
echo "3. Cart Drawer CSS:"
CART_RIGHT=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 3 "\.cart-drawer {" | grep "right:")
CART_VIS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.cart-drawer {" | grep "visibility:")
CART_OPACITY=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.cart-drawer {" | grep "opacity:")

echo "$CART_RIGHT" | sed 's/^/   /'
echo "$CART_VIS" | sed 's/^/   /'
echo "$CART_OPACITY" | sed 's/^/   /'

echo ""
echo "4. Wishlist Drawer CSS:"
WISH_RIGHT=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 3 "\.wishlist-drawer {" | grep "right:")
WISH_VIS=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.wishlist-drawer {" | grep "visibility:")
WISH_OPACITY=$(curl -s http://localhost:5000/assets/css/modern-theme.css | grep -A 10 "\.wishlist-drawer {" | grep "opacity:")

echo "$WISH_RIGHT" | sed 's/^/   /'
echo "$WISH_VIS" | sed 's/^/   /'
echo "$WISH_OPACITY" | sed 's/^/   /'

echo ""
echo "==========================================="
echo "   VERIFICATION RESULT"
echo "==========================================="

if echo "$CART_RIGHT" | grep -q "right: -400px" && \
   echo "$CART_VIS" | grep -q "visibility: hidden" && \
   echo "$WISH_RIGHT" | grep -q "right: -400px" && \
   echo "$WISH_VIS" | grep -q "visibility: hidden"; then
    echo "✓ SUCCESS: Blog page drawer fix is properly applied!"
    echo ""
    echo "The cart and wishlist drawers on the blog page:"
    echo "  • Are positioned off-screen (right: -400px)"
    echo "  • Are hidden by default (visibility: hidden)"
    echo "  • Will slide in smoothly when clicked"
    echo "  • Have the same fix as all other pages"
else
    echo "✗ ISSUE DETECTED: Some CSS properties are missing"
fi

echo ""
echo "==========================================="
echo "   MANUAL VERIFICATION STEPS"
echo "==========================================="
echo "1. Open http://localhost:5000/blog in browser"
echo "2. Hard refresh: Ctrl+F5 (Windows/Linux) or Cmd+Shift+R (Mac)"
echo "3. Verify drawers are NOT visible on page load"
echo "4. Click cart icon → drawer slides in from right"
echo "5. Click wishlist icon → drawer slides in from right"
echo "6. Click outside or X button → drawers slide out"
echo "==========================================="
