function updateTime() {
    const now = new Date();
    const currentTime = now.toLocaleTimeString('de-DE', { 
        hour: '2-digit', 
        minute: '2-digit', 
        hour12: false 
    });
    
    // Update displayed time
    const timeDisplay = document.getElementById('current-time');
    if (timeDisplay) {
        timeDisplay.textContent = currentTime;
    }

    // Check opening status
    fetch('/api/check-open-status')
        .then(response => response.json())
        .then(status => {
            // Update status bar
            const statusBar = document.getElementById('status-bar');
            const statusText = document.getElementById('status-text');
            
            if (statusBar) {
                statusBar.className = status.isOpen 
                    ? 'bg-status-green transition-colors duration-300'
                    : 'bg-status-red transition-colors duration-300';
            }
            
            if (statusText) {
                const textOpen = statusText.dataset.textOpen;
                const textClosed = statusText.dataset.textClosed;
                statusText.textContent = status.isOpen ? textOpen : textClosed;
            }

            // Update opening hours rows
            document.querySelectorAll('.hours-row').forEach(row => {
                const open = row.dataset.open;
                const close = row.dataset.close;
                const isCurrentTimeSlot = currentTime >= open && currentTime <= close;
                
                row.classList.toggle('border-2', isCurrentTimeSlot && status.isOpen);
                row.classList.toggle('border-status-green', isCurrentTimeSlot && status.isOpen);
            });
        });
}

// Update immediately and then every minute
updateTime();
setInterval(updateTime, 60000); 