</div> <!-- page-wrapper end -->

    <!-- Footer -->
    <footer class="footer">
        <div class="container">
            <div class="footer-content">
                <div class="footer-grid">
                    <!-- Logo ja kirjeldus -->
                    <div class="footer-section">
                        <div class="footer-brand">
                            <div class="footer-logo">
                                <i class="icon-trophy"></i>
                                <span class="footer-brand-text"><?php echo getSystemName(); ?></span>
                            </div>
                            <p class="footer-description">
                                Punktiarvestuse süsteem <?php echo getSystemName(); ?> sportlastele. 
                                Jälgi oma tulemusi, vaata hooaja seisu ja arenda end ratsaspordis.
                            </p>
                            <div class="footer-social">
                                <a href="mailto:<?php echo getSystemEmail('contact'); ?>" class="social-link" title="E-mail">
                                    <i class="icon-mail"></i>
                                </a>
                                <a href="tel:+372" class="social-link" title="Telefon">
                                    <i class="icon-phone"></i>
                                </a>
                            </div>
                        </div>
                    </div>

                    <!-- Navigeerimine -->
                    <div class="footer-section">
                        <h3 class="footer-heading">Navigeerimine</h3>
                        <ul class="footer-links">
                            <li><a href="<?php echo url(); ?>">Avaleht</a></li>
                            <li><a href="<?php echo url('public/rankings.php'); ?>">Hooaja tabelid</a></li>
                            <li><a href="<?php echo url('public/results.php'); ?>">Võistluste tulemused</a></li>
                            <li><a href="<?php echo url('public/stats.php'); ?>">Statistika</a></li>
                        </ul>
                    </div>

                    <!-- Sportlastele -->
                    <div class="footer-section">
                        <h3 class="footer-heading">Sportlastele</h3>
                        <ul class="footer-links">
                            <?php if (isLoggedIn()): ?>
                                <?php if (isAthlete()): ?>
                                    <li><a href="<?php echo url('athlete/dashboard.php'); ?>">Minu ala</a></li>
                                    <li><a href="<?php echo url('athlete/results.php'); ?>">Minu tulemused</a></li>
                                    <li><a href="<?php echo url('athlete/training.php'); ?>">Treeningu päevik</a></li>
                                    <li><a href="<?php echo url('athlete/stats.php'); ?>">Minu statistika</a></li>
                                <?php endif; ?>
                                <li><a href="<?php echo url('profile.php'); ?>">Profiil</a></li>
                            <?php else: ?>
                                <li><a href="<?php echo url('login.php'); ?>">Logi sisse</a></li>
                                <li><a href="<?php echo url('register.php'); ?>">Registreeru</a></li>
                            <?php endif; ?>
                        </ul>
                    </div>

                    <!-- Kontakt -->
                    <div class="footer-section">
                        <h3 class="footer-heading">Kontakt</h3>
                        <div class="footer-contact">
                            <div class="contact-item">
                                <i class="icon-mail"></i>
                                <a href="mailto:<?php echo getSystemEmail('contact'); ?>">
                                    <?php echo getSystemEmail('contact'); ?>
                                </a>
                            </div>
                            <div class="contact-item">
                                <i class="icon-map-pin"></i>
                                <div>
                                    <div><?php echo getSystemName(); ?></div>
                                    <div class="contact-subtitle">Eesti</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Footer bottom -->
                <div class="footer-bottom">
                    <div class="footer-bottom-content">
                        <div class="footer-copyright">
                            © <?php echo date('Y'); ?> <?php echo getSystemName(); ?>. Kõik õigused kaitstud.
                        </div>
                        <div class="footer-info">
                            <span>Punktiarvestuse reeglid kehtivad muutumatult</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Punktiarvestuse info -->
        <div class="footer-rules">
            <div class="container">
                <div class="rules-content">
                    <div class="rules-icon">
                        <i class="icon-info"></i>
                    </div>
                    <div class="rules-text">
                        <strong>Punktiarvestus:</strong> 
                        Koolisõit (6 parimat), Takistussõit (10 parimat), Kestvusratsutamine (4 parimat)
                    </div>
                </div>
            </div>
        </div>
    </footer>

    <!-- JavaScript -->
    <script src="<?php echo url('assets/js/main.js'); ?>"></script>
    
    <!-- Additional page scripts -->
    <?php if (isset($extra_js_content)) echo $extra_js_content; ?>
    
    <!-- Development tools (only in development) -->
    <?php if (getenv('ENVIRONMENT') === 'development' || 
              (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] === 'localhost')): ?>
        <script>
            // Console info for developers
            console.log('%c🐴 Estreka Ratsaklubi Debug Info', 'color: #2563eb; font-weight: bold; font-size: 16px;');
            console.log('Page:', window.location.pathname);
            console.log('User logged in:', <?php echo isLoggedIn() ? 'true' : 'false'; ?>);
            <?php if (isLoggedIn()): ?>
                console.log('User role:', '<?php echo $_SESSION['user_role'] ?? 'unknown'; ?>');
            <?php endif; ?>
            console.log('Environment: Development');
        </script>
    <?php endif; ?>

</body>
</html>

<style>
/* Footer Styles */
.footer {
    background-color: var(--gray-900);
    color: white;
    margin-top: auto;
}

.footer-content {
    padding: var(--spacing-12) 0 0;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-8);
    margin-bottom: var(--spacing-8);
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

.footer-section h3.footer-heading {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-4);
    color: white;
}

.footer-brand .footer-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    margin-bottom: var(--spacing-4);
}

.footer-brand .footer-logo i {
    color: var(--primary-light);
    font-size: var(--font-size-2xl);
}

.footer-brand-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: white;
}

.footer-description {
    color: var(--gray-300);
    margin-bottom: var(--spacing-6);
    line-height: 1.6;
    max-width: 400px;
}

.footer-social {
    display: flex;
    gap: var(--spacing-4);
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--gray-800);
    color: var(--gray-300);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.social-link:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: var(--spacing-2);
}

.footer-links a {
    color: var(--gray-300);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--primary-light);
}

.footer-contact .contact-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-3);
    margin-bottom: var(--spacing-3);
    color: var(--gray-300);
}

.footer-contact .contact-item i {
    color: var(--primary-light);
    margin-top: 2px;
}

.footer-contact a {
    color: var(--gray-300);
    transition: color var(--transition-fast);
}

.footer-contact a:hover {
    color: var(--primary-light);
}

.contact-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-400);
}

.footer-bottom {
    border-top: 1px solid var(--gray-800);
    padding: var(--spacing-6) 0;
}

.footer-bottom-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
    text-align: center;
}

@media (min-width: 768px) {
    .footer-bottom-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
}

.footer-copyright {
    color: var(--gray-400);
    font-size: var(--font-size-sm);
}

.footer-info {
    color: var(--gray-400);
    font-size: var(--font-size-sm);
}

.footer-rules {
    background-color: var(--gray-800);
    padding: var(--spacing-4) 0;
}

.rules-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-3);
    text-align: center;
}

.rules-content i {
    color: var(--primary-light);
}

.rules-text {
    color: var(--gray-400);
    font-size: var(--font-size-sm);
}

@media (max-width: 767px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-6);
    }
    
    .footer-content {
        padding: var(--spacing-8) 0 0;
    }
    
    .rules-content {
        flex-direction: column;
        gap: var(--spacing-2);
    }
}
</style>