<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>Advanced Search - Product Finder</title>
    <link rel="stylesheet" href="{{ url_for('products.serve_css', filename='styles.css') }}">
    <style>
        .wip-container {
            text-align: center;
            padding: 60px 40px;
        }
        
        .wip-icon {
            font-size: 80px;
            margin-bottom: 20px;
        }
        
        .wip-title {
            font-size: 32px;
            font-weight: bold;
            color: #333;
            margin-bottom: 15px;
        }
        
        .wip-subtitle {
            font-size: 18px;
            color: #666;
            margin-bottom: 30px;
        }
        
        .wip-details {
            max-width: 600px;
            margin: 0 auto 40px;
            padding: 20px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 8px;
            text-align: left;
        }
        
        .wip-details h3 {
            color: #333;
            margin-bottom: 15px;
        }
        
        .wip-details ul {
            list-style-position: inside;
            color: #666;
            line-height: 1.8;
        }
        
        .wip-details ul li {
            margin-bottom: 8px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>Advanced Search</h1>
        </div>
        
        <div class="user-info-bar" id="userInfoBar">
            <span id="userLocationInfo"></span>
            <a href="{{ url_for('auth.logout') }}" class="logout-btn" title="Logout" 
               onclick="return confirm('Are you sure you want to log out?');" 
               style="background: none; border: none; cursor: pointer; font-size: 16px; text-decoration: none; display: inline-block; padding: 8px 12px;">🚪</a>
        </div>
        
        <div class="breadcrumb">
            Start › Advanced Search
        </div>

        <div id="content">
            <div class="wip-container">
                <div class="wip-icon">🚧</div>
                <div class="wip-title">Work in Progress</div>
                <div class="wip-subtitle">Advanced Search Features Coming Soon</div>
                
                <div class="wip-details">
                    <h3>Planned Features:</h3>
                    <ul>
                        <li>Multi-criteria filtering (type, material, color, size)</li>
                        <li>Price range filters</li>
                        <li>Availability by location</li>
                        <li>Advanced product specifications search</li>
                        <li>Compatibility matching</li>
                        <li>Save and share custom searches</li>
                    </ul>
                </div>
                
                <div class="result-actions">
                    <button class="back-button" onclick="goBack()">← Go Back</button>
                    <button class="back-button" onclick="goToFinder()" style="margin-left: 10px;">🏠 Back to Product Finder</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Load user session info
        async function loadUserInfo() {
            try {
                const response = await fetch('/api/session');
                const data = await response.json();
                
                if (data.status === 'success') {
                    const locationNames = {
                        'LINDS': 'Lindsborg',
                        'IOLA': 'Iola',
                        'KC': 'Kansas City',
                        'BMD': 'BMD'
                    };
                    
                    const currentLoc = locationNames[data.currentLocation] || data.currentLocation;
                    const canChangeLocation = data.accessibleLocations && data.accessibleLocations.length > 1;
                    
                    let locationDisplay;
                    if (canChangeLocation) {
                        locationDisplay = `<a href="{{ url_for('auth.select_location_page') }}" style="color: #6a4c93; text-decoration: none; font-weight: 500; cursor: pointer;" 
                                              onmouseover="this.style.textDecoration='underline'" 
                                              onmouseout="this.style.textDecoration='none'"
                                              title="Click to change location">📍 ${currentLoc}</a>`;
                    } else {
                        locationDisplay = `📍 ${currentLoc}`;
                    }
                    
                    document.getElementById('userLocationInfo').innerHTML = 
                        `👤 ${data.username} | ${locationDisplay}`;
                }
            } catch (error) {
                console.error('Error loading user info:', error);
            }
        }

        // Navigation functions
        function goBack() {
            window.history.back();
        }
        
        function goToFinder() {
            window.location.href = '{{ url_for("products.quiz_index") }}';
        }

        // Load user info when page loads
        loadUserInfo();
    </script>
</body>
</html>
