/**
 * Cookie Consent Banner Styles & Script
 * Add this to any page that needs cookie consent
 */

/* Cookie Consent Banner CSS */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    z-index: 99999;
    transform: translateY(100%);
    transition: transform 0.4s ease;
    display: none;
}

.cookie-consent.show {
    display: block;
    transform: translateY(0);
}

.cookie-consent-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-consent-text {
    flex: 1;
    min-width: 300px;
}

.cookie-consent-text h4 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cookie-consent-text p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cookie-consent-text a {
    color: #60a5fa;
    text-decoration: underline;
}

.cookie-consent-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cookie-consent-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.cookie-consent-accept {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.cookie-consent-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.cookie-consent-decline {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cookie-consent-decline:hover {
    background: rgba(255, 255, 255, 0.15);
}

.cookie-consent-settings {
    background: transparent;
    color: #60a5fa;
    padding: 12px 16px;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .cookie-consent-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-consent-actions {
        justify-content: stretch;
    }
    
    .cookie-consent-btn {
        flex: 1;
    }
}

/* Cookie Consent Script */
<script>
// Cookie Consent Management
class CookieConsent {
    constructor() {
        this.cookieName = 'cookie_consent';
        this.init();
    }
    
    init() {
        // Check if consent already given
        if (!this.hasConsent()) {
            this.showBanner();
        }
    }
    
    hasConsent() {
        return localStorage.getItem(this.cookieName) === 'accepted';
    }
    
    showBanner() {
        const banner = document.getElementById('cookieConsent');
        if (banner) {
            setTimeout(() => {
                banner.classList.add('show');
            }, 1000); // Show after 1 second
        }
    }
    
    hideBanner() {
        const banner = document.getElementById('cookieConsent');
        if (banner) {
            banner.classList.remove('show');
            setTimeout(() => {
                banner.style.display = 'none';
            }, 400);
        }
    }
    
    accept() {
        localStorage.setItem(this.cookieName, 'accepted');
        this.hideBanner();
        
        // Enable analytics and other tracking
        if (typeof gtag !== 'undefined') {
            gtag('consent', 'update', {
                'analytics_storage': 'granted'
            });
        }
        
        console.log('✅ Cookies accepted');
    }
    
    decline() {
        localStorage.setItem(this.cookieName, 'declined');
        this.hideBanner();
        
        // Disable analytics
        if (typeof gtag !== 'undefined') {
            gtag('consent', 'update', {
                'analytics_storage': 'denied'
            });
        }
        
        console.log('❌ Cookies declined');
    }
}

// Initialize on page load
document.addEventListener('DOMContentLoaded', () => {
    window.cookieConsent = new CookieConsent();
});
</script>
