<?php 
header('Content-Type: text/html; charset=utf-8');

// Загрузка документов из JSON-файла
$metaFile = 'documents.json';
$docs = file_exists($metaFile) ? json_decode(file_get_contents($metaFile), true) : [];

// Собираем доступные годы для фильтра
$years = [];
foreach ($docs as $doc) {
    if (isset($doc['year'])) {
        $years[$doc['year']] = $doc['year'];
    }
}
krsort($years); // Сортируем по убыванию года

// Получаем параметры фильтрации
$startDate = $_GET['start_date'] ?? null;
$endDate = $_GET['end_date'] ?? null;
$searchQuery = $_GET['search'] ?? null;

// Фильтрация документов
$filteredDocs = $docs;
if ($startDate || $endDate || $searchQuery) {
    $filteredDocs = array_filter($docs, function($doc) use ($startDate, $endDate, $searchQuery) {
        $published = strtotime($doc['published']);
        $match = true;
        
        // Фильтр по дате начала
        if ($startDate && $published < strtotime($startDate)) {
            $match = false;
        }
        
        // Фильтр по дате окончания
        if ($endDate && $published > strtotime($endDate . ' 23:59:59')) {
            $match = false;
        }
        
        // Поиск по заголовку
        if ($searchQuery && stripos($doc['title'], $searchQuery) === false) {
            $match = false;
        }
        
        return $match;
    });
}

// Группируем документы по годам и кварталам
$groupedDocs = [];
foreach ($filteredDocs as $doc) {
    if (isset($doc['year']) && isset($doc['quarter'])) {
        $year = $doc['year'];
        $quarter = $doc['quarter'];
        
        if (!isset($groupedDocs[$year])) {
            $groupedDocs[$year] = [];
        }
        
        if (!isset($groupedDocs[$year][$quarter])) {
            $groupedDocs[$year][$quarter] = [];
        }
        
        $groupedDocs[$year][$quarter][] = $doc;
    }
}

// Сортируем годы по убыванию
krsort($groupedDocs);
?>
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Раскрытие информации согласно Указанию Банка России №5609-У</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="icon" href="images/ТрастЮнионЛого.png" type="image/x-icon">
    <style>
        /* Оптимизированные стили */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
            color: #333;
            line-height: 1.6;
            padding-bottom: 40px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }

        header {
            background: linear-gradient(to right, #1a3a6c, #2c5282);
            color: white;
            padding: 25px 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            position: relative;
            overflow: hidden;
        }

        .header-content {
            position: relative;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .logo-text {
            font-size: 1.8rem;
            font-weight: 700;
        }

        .logo-subtext {
            font-size: 1rem;
            opacity: 0.8;
            margin-top: 5px;
        }

        .contact-info p {
            margin: 3px 0;
            font-size: 0.9rem;
        }

        .main-content {
            padding: 40px 0;
        }

        .info-section {
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            padding: 30px;
            margin-bottom: 30px;
        }

        .section-title {
            color: #2c5282;
            border-bottom: 2px solid #e2e8f0;
            padding-bottom: 15px;
            margin-bottom: 25px;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .links-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin-top: 20px;
        }

        .link-card {
            background: #f8fafc;
            border-radius: 8px;
            padding: 25px;
            transition: all 0.3s ease;
            border: 1px solid #e2e8f0;
            position: relative;
            overflow: hidden;
        }

        .link-card::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 5px;
            height: 100%;
            background: #2c5282;
        }

        .link-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        }

        .link-card h3 {
            color: #2c5282;
            margin-bottom: 15px;
            font-size: 1.3rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .link-list li {
            margin: 12px 0;
            display: flex;
            align-items: center;
        }

        .link-list a {
            color: #4a5568;
            text-decoration: none;
            transition: color 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .link-list a:hover {
            color: #2b6cb0;
            text-decoration: underline;
        }

        .filters {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 25px;
            background: #edf2f7;
            padding: 20px;
            border-radius: 8px;
        }

        .filter-group {
            flex: 1;
            min-width: 200px;
        }

        .filter-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #4a5568;
        }

        .filter-group input,
        .filter-group select {
            width: 100%;
            padding: 12px;
            border: 1px solid #cbd5e0;
            border-radius: 6px;
            font-size: 1rem;
            transition: all 0.3s;
        }

        .filter-group input:focus,
        .filter-group select:focus {
            outline: none;
            border-color: #2c5282;
            box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
        }

        .document-item {
            padding: 25px;
            border-bottom: 1px solid #edf2f7;
            transition: background 0.2s;
        }

        .document-item:hover {
            background: #f8fafc;
        }

        .doc-header {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
            margin-bottom: 15px;
        }

        .doc-date {
            color: #4a5568;
            font-size: 0.95rem;
            font-weight: 500;
        }

        .doc-title {
            font-size: 1.2rem;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 10px;
        }

        .download-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: #2c5282;
            color: white;
            padding: 10px 20px;
            border-radius: 6px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s;
        }

        .download-btn:hover {
            background: #1a3a6c;
            transform: translateY(-2px);
        }

        .disclaimer {
            background: #fff8dd;
            border-left: 4px solid #ffc107;
            padding: 20px;
            border-radius: 0 8px 8px 0;
            margin-top: 30px;
            font-size: 0.95rem;
        }

        footer {
            margin-top: 50px;
            background: #2d3748;
            color: #cbd5e0;
            padding: 30px 0;
            border-radius: 10px;
        }

        .footer-content {
            display: flex;
            flex-wrap: wrap;
            gap: 30px;
            justify-content: space-between;
        }

        .footer-section {
            flex: 1;
            min-width: 300px;
        }

        .copyright {
            text-align: center;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #4a5568;
            color: #a0aec0;
            font-size: 0.9rem;
        }

        /* Стили для аккордеонов */
        .year-section {
            margin-bottom: 20px;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            overflow: hidden;
        }
        
        .year-header {
            background: linear-gradient(to right, #2c5282, #1a3a6c);
            color: white;
            padding: 15px 25px;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .year-title {
            font-size: 1.5rem;
            font-weight: 600;
        }
        
        .year-content {
            padding: 20px;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }
        
        .year-section.active .year-content {
            max-height: 5000px;
        }
        
        .quarter-card {
            background: #f8fafc;
            border-radius: 8px;
            padding: 20px;
            border: 1px solid #e2e8f0;
            margin-bottom: 15px;
        }
        
        .quarter-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
        }
        
        .quarter-title {
            color: #2c5282;
            margin-bottom: 15px;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .documents-container {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }
        
        .quarter-card.active .documents-container {
            max-height: 5000px;
        }
        
        .document-meta {
            display: flex;
            justify-content: space-between;
            margin-top: 8px;
            font-size: 0.9rem;
            color: #718096;
            flex-wrap: wrap;
        }
        
        .document-type {
            background: #e2e8f0;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 0.85rem;
            margin-right: 5px;
        }
        
        /* Адаптивные стили */
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                align-items: flex-start;
            }

            .contact-info {
                text-align: left;
                margin-top: 20px;
            }

            .filters {
                flex-direction: column;
            }

            .doc-header {
                flex-direction: column;
            }
            
            .year-title {
                font-size: 1.3rem;
            }
            
            .quarter-title {
                font-size: 1.1rem;
            }
            
            .document-item {
                padding: 15px;
            }
            
            .doc-title {
                font-size: 1.1rem;
            }
            
            .download-btn {
                width: 100%;
                text-align: center;
                justify-content: center;
            }
            
            .year-filters {
                flex-wrap: nowrap;
                overflow-x: auto;
                padding-bottom: 10px;
                margin: 0 -20px 20px;
                padding: 0 20px;
            }
            
            .year-filter-btn {
                flex-shrink: 0;
                white-space: nowrap;
            }
            
            .info-section {
                padding: 20px;
            }
            
            .section-title {
                font-size: 1.4rem;
            }
            
            .links-grid {
                grid-template-columns: 1fr;
            }
            
            .footer-section {
                min-width: 100%;
            }
        }
        
        /* Элементы управления */
        .year-filters {
            display: flex;
            gap: 15px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        
        .year-filter-btn {
            padding: 8px 16px;
            background: #edf2f7;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.2s;
        }
        
        .year-filter-btn:hover {
            background: #e2e8f0;
        }
        
        .year-filter-btn.active {
            background: #2c5282;
            color: white;
        }
        
        .no-results {
            text-align: center;
            padding: 40px 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
        }
        
        .no-results i {
            font-size: 3rem;
            color: #2c5282;
            margin-bottom: 20px;
        }
        
        .chevron {
            transition: transform 0.3s ease;
        }
        
        .active .chevron {
            transform: rotate(180deg);
        }
        
        .filter-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        
        .filter-buttons .download-btn {
            flex: 1;
            min-width: 120px;
        }
                * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
            color: #333;
            line-height: 1.6;
            padding-bottom: 40px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }

        header {
            background: linear-gradient(to right, #1a3a6c, #2c5282);
            color: white;
            padding: 25px 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            position: relative;
            overflow: hidden;
        }

        header::before {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
            transform: rotate(30deg);
        }

        .header-content {
            position: relative;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .logo-icon {
            font-size: 2.5rem;
            color: #fff;
        }

        .logo-text {
            font-size: 1.8rem;
            font-weight: 700;
        }

        .logo-subtext {
            font-size: 1rem;
            opacity: 0.8;
            margin-top: 5px;
        }

        .contact-info {
            text-align: right;
            margin-top: 10px;
        }

        .contact-info p {
            margin: 3px 0;
            font-size: 0.9rem;
        }

        .main-content {
            padding: 40px 0;
        }

        .info-section {
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            padding: 30px;
            margin-bottom: 30px;
        }

        .section-title {
            color: #2c5282;
            border-bottom: 2px solid #e2e8f0;
            padding-bottom: 15px;
            margin-bottom: 25px;
            font-size: 1.8rem;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .section-title i {
            font-size: 1.5rem;
        }

        .links-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin-top: 20px;
        }

        .link-card {
            background: #f8fafc;
            border-radius: 8px;
            padding: 25px;
            transition: all 0.3s ease;
            border: 1px solid #e2e8f0;
            position: relative;
            overflow: hidden;
        }

        .link-card::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 5px;
            height: 100%;
            background: #2c5282;
        }

        .link-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
            border-color: #cbd5e0;
        }

        .link-card h3 {
            color: #2c5282;
            margin-bottom: 15px;
            font-size: 1.3rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .link-card h3 i {
            font-size: 1.2rem;
        }

        .link-list {
            list-style: none;
        }

        .link-list li {
            margin: 12px 0;
            display: flex;
            align-items: center;
        }

        .link-list a {
            color: #4a5568;
            text-decoration: none;
            transition: color 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .link-list a:hover {
            color: #2b6cb0;
            text-decoration: underline;
        }

        .link-list i {
            color: #2c5282;
            font-size: 0.9rem;
        }

        .filters {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            margin-bottom: 25px;
            background: #edf2f7;
            padding: 20px;
            border-radius: 8px;
        }

        .filter-group {
            flex: 1;
            min-width: 200px;
        }

        .filter-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #4a5568;
        }

        .filter-group input,
        .filter-group select {
            width: 100%;
            padding: 12px;
            border: 1px solid #cbd5e0;
            border-radius: 6px;
            font-size: 1rem;
            transition: border-color 0.3s;
        }

        .filter-group input:focus,
        .filter-group select:focus {
            outline: none;
            border-color: #2c5282;
            box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
        }

        .documents-list {
            background: white;
            border-radius: 10px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            overflow: hidden;
        }

        .document-item {
            padding: 25px;
            border-bottom: 1px solid #edf2f7;
            transition: background 0.2s;
        }

        .document-item:last-child {
            border-bottom: none;
        }

        .document-item:hover {
            background: #f8fafc;
        }

        .doc-header {
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
            margin-bottom: 15px;
        }

        .doc-date {
            color: #4a5568;
            font-size: 0.95rem;
            font-weight: 500;
        }

        .doc-title {
            font-size: 1.2rem;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 10px;
        }

        .doc-details {
            color: #718096;
            font-size: 0.95rem;
            margin-bottom: 15px;
        }

        .download-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: #2c5282;
            color: white;
            padding: 10px 20px;
            border-radius: 6px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s;
        }

        .download-btn:hover {
            background: #1a3a6c;
            transform: translateY(-2px);
        }

        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 30px;
            flex-wrap: wrap;
        }

        .pagination a {
            display: inline-block;
            padding: 8px 16px;
            margin: 0 4px;
            border-radius: 6px;
            background: #edf2f7;
            color: #4a5568;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.2s;
        }

        .pagination a:hover {
            background: #e2e8f0;
        }

        .pagination a.active {
            background: #2c5282;
            color: white;
        }

        .disclaimer {
            background: #fff8dd;
            border-left: 4px solid #ffc107;
            padding: 20px;
            border-radius: 0 8px 8px 0;
            margin-top: 30px;
            font-size: 0.95rem;
        }

        .disclaimer h3 {
            margin-bottom: 10px;
            color: #d97706;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        footer {
            margin-top: 50px;
            background: #2d3748;
            color: #cbd5e0;
            padding: 30px 0;
            border-radius: 10px;
        }

        .footer-content {
            display: flex;
            flex-wrap: wrap;
            gap: 30px;
            justify-content: space-between;
        }

        .footer-section {
            flex: 1;
            min-width: 300px;
        }

        .footer-section h3 {
            color: white;
            margin-bottom: 20px;
            font-size: 1.3rem;
            border-bottom: 1px solid #4a5568;
            padding-bottom: 10px;
        }

        .footer-links {
            list-style: none;
        }

        .footer-links li {
            margin: 12px 0;
        }

        .footer-links a {
            color: #cbd5e0;
            text-decoration: none;
            transition: color 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .footer-links a:hover {
            color: white;
        }

        .copyright {
            text-align: center;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #4a5568;
            color: #a0aec0;
            font-size: 0.9rem;
        }

        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                align-items: flex-start;
            }

            .contact-info {
                text-align: left;
                margin-top: 20px;
            }

            .filters {
                flex-direction: column;
            }

            .doc-header {
                flex-direction: column;
            }
        }
        
        .admin-link {
            position: absolute;
            top: 20px;
            right: 20px;
            background: #38a169;
            color: white;
            padding: 10px 15px;
            border-radius: 4px;
            text-decoration: none;
            font-weight: 500;
            z-index: 100;
        }
    </style>
</head>
<body>
    <header>
        <div class="container">
            <div class="header-content">
                <div class="logo">
                    <a href="index.html">
                        <img src="images/ТрастЮнионЛого.png" alt="Логотип ТрастЮнион" width="80">
                    </a>
                    <div>
                        <div class="logo-text">ТрастЮнион АйЭм</div>
                        <div class="logo-subtext">Раскрытие информации согласно Указанию Банка России №5609-У</div>
                    </div>
                </div>
                <div class="contact-info">
                    <p><i class="fas fa-map-marker-alt"></i> г. Москва, шоссе Хорошёвское, дом 32А</p>
                    <p><i class="fas fa-phone"></i> (499) 701-99-19</p>
                    <p><i class="fas fa-envelope"></i> info@trustunionam.ru</p>
                    <p><i class="fas fa-globe"></i> www.trustunionam.ru</p>
                </div>
            </div>
        </div>
    </header>

    <div class="container">
        <main class="main-content">
            <section class="info-section">
                <h2 class="section-title"><i class="fas fa-info-circle"></i> Общая информация</h2>
                <p>На этой странице раскрывается информация, подлежащая раскрытию согласно Указанию Банка России №5609-У.</p>
                <p>С данной информацией, а также иной информацией Вы можете ознакомиться, перейдя по ссылкам:</p>

                <div class="links-grid">
                    <div class="link-card">
                        <h3><i class="fas fa-building"></i> Управляющая компания</h3>
                        <ul class="link-list">
                            <li><a href="open_information_company_uk.html"><i class="fas fa-file-alt"></i> Раскрытие информации</a></li>
                            <li><a href="open_information_company_rekvesit.html"><i class="fas fa-file-invoice"></i> Реквизиты</a></li>
                            <li><a href="open_information_company_intelligence.html"><i class="fas fa-users"></i> Сведения об участниках</a></li>
                        </ul>
                    </div>

                    <div class="link-card">
                        <h3><i class="fas fa-tractor"></i> Рентный ЗПИФ «Земельные ресурсы»</h3>
                        <ul class="link-list">
                            <li><a href="#"><i class="fas fa-chart-line"></i> Отчетность и раскрытие информации фонда</a></li>
                            <li><a href="#"><i class="fas fa-file-contract"></i> Документы фонда</a></li>
                        </ul>
                    </div>

                    <div class="link-card">
                        <h3><i class="fas fa-city"></i> Рентный ЗПИФ «Региональная недвижимость»</h3>
                        <ul class="link-list">
                            <li><a href="#"><i class="fas fa-chart-line"></i> Отчетность и раскрытие информации фонда</a></li>
                            <li><a href="#"><i class="fas fa-file-contract"></i> Документы фонда</a></li>
                        </ul>
                    </div>

                    <div class="link-card">
                        <h3><i class="fas fa-hard-hat"></i> ЗПИФ недвижимости «Инженер»</h3>
                        <ul class="link-list">
                            <li><a href="#"><i class="fas fa-chart-line"></i> Отчетность и раскрытие информации фонда</a></li>
                            <li><a href="#"><i class="fas fa-file-contract"></i> Документы фонда</a></li>
                        </ul>
                    </div>
                </div>
            </section>

            <section class="info-section">
                <h2 class="section-title"><i class="fas fa-file-alt"></i> Раскрытие информации в отношении управляющей компании</h2>
                
                <form method="GET" class="filters">
                    <div class="filter-group">
                        <label for="start_date"><i class="fas fa-calendar-start"></i> Дата начала:</label>
                        <input type="date" id="start_date" name="start_date" value="<?= htmlspecialchars($_GET['start_date'] ?? '') ?>">
                    </div>
                    
                    <div class="filter-group">
                        <label for="end_date"><i class="fas fa-calendar-end"></i> Дата окончания:</label>
                        <input type="date" id="end_date" name="end_date" value="<?= htmlspecialchars($_GET['end_date'] ?? '') ?>">
                    </div>
                    
                    <div class="filter-group">
                        <label for="search"><i class="fas fa-search"></i> Поиск по заголовку:</label>
                        <input type="text" id="search" name="search" placeholder="Введите заголовок" value="<?= htmlspecialchars($_GET['search'] ?? '') ?>">
                    </div>
                    
                    <div class="filter-group">
                        <div class="filter-buttons">
                            <button type="submit" class="download-btn">
                                <i class="fas fa-filter"></i> Применить фильтры
                            </button>
                            <a href="?" class="download-btn" style="background: #718096;">
                                <i class="fas fa-times"></i> Сбросить
                            </a>
                        </div>
                    </div>
                </form>
                
                <div class="year-filters">
                    <button class="year-filter-btn active" data-year="all">Все годы</button>
                    <?php foreach ($years as $year): ?>
                        <button class="year-filter-btn" data-year="<?= $year ?>"><?= $year ?></button>
                    <?php endforeach; ?>
                </div>
                
                <div class="documents-by-year">
                    <?php if (empty($groupedDocs)): ?>
                        <div class="no-results">
                            <i class="fas fa-info-circle"></i>
                            <h3>Документы не найдены</h3>
                            <p>Попробуйте изменить параметры фильтрации</p>
                        </div>
                    <?php else: ?>
                        <?php foreach ($groupedDocs as $year => $quarters): ?>
                        <div class="year-section" data-year="<?= $year ?>">
                            <div class="year-header">
                                <div class="year-title"><?= $year ?> год</div>
                                <div class="chevron"><i class="fas fa-chevron-down"></i></div>
                            </div>
                            
                            <div class="year-content">
                                <?php 
                                krsort($quarters);
                                foreach ($quarters as $quarter => $documents): ?>
                                <div class="quarter-card">
                                    <div class="quarter-header">
                                        <h3 class="quarter-title"><i class="fas fa-calendar-alt"></i> Квартал <?= $quarter ?></h3>
                                        <div class="chevron"><i class="fas fa-chevron-down"></i></div>
                                    </div>
                                    
                                    <div class="documents-container">
                                        <?php foreach ($documents as $doc): ?>
                                        <div class="document-item">
                                            <div class="doc-header">
                                                <div class="doc-date"><i class="fas fa-calendar-day"></i> Опубликовано: <?= 
                                                    date('d.m.Y H:i', strtotime($doc['published'])) ?></div>
                                                <div class="doc-date"><i class="fas fa-calendar-check"></i> Доступно до: <?= 
                                                    date('d.m.Y', strtotime($doc['availableUntil'])) ?></div>
                                            </div>
                                            <h3 class="doc-title"><?= htmlspecialchars($doc['title']) ?></h3>
                                            <div class="document-meta">
                                                <span class="document-type"><?= htmlspecialchars($doc['type'] ?? 'Отчет') ?></span>
                                                <span><i class="fas fa-file-pdf"></i> PDF, <?= $doc['size'] ?? '1.2' ?> МБ</span>
                                            </div>
                                            <a href="<?= $doc['fileUrl'] ?>" class="download-btn" target="_blank">
                                                <i class="fas fa-download"></i> Скачать документ
                                            </a>
                                        </div>
                                        <?php endforeach; ?>
                                    </div>
                                </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </div>
            </section>

            <div class="disclaimer">
                <h3><i class="fas fa-exclamation-triangle"></i> Важная информация для инвесторов</h3>
                <p>Стоимость инвестиционных паев может увеличиваться и уменьшаться, результаты инвестирования в прошлом
                    не определяют доходов в будущем, государство не гарантирует доходности инвестиций в инвестиционные
                    фонды, перед приобретением инвестиционных паев необходимо внимательно ознакомиться с правилами
                    доверительного управления паевым инвестиционным фондом.</p>
            </div>
        </main>

        <footer>
            <div class="container">
                <div class="footer-content">
                    <div class="footer-section">
                        <h3>О компании</h3>
                        <ul class="footer-links">
                            <li><a href="#"><i class="fas fa-info-circle"></i> О нас</a></li>
                            <li><a href="#"><i class="fas fa-history"></i> История компании</a></li>
                            <li><a href="#"><i class="fas fa-award"></i> Лицензии и сертификаты</a></li>
                            <li><a href="#"><i class="fas fa-user-tie"></i> Команда</a></li>
                        </ul>
                    </div>

                    <div class="footer-section">
                        <h3>Фонды</h3>
                        <ul class="footer-links">
                            <li><a href="#"><i class="fas fa-tractor"></i> Рентный ЗПИФ «Земельные ресурсы»</a></li>
                            <li><a href="#"><i class="fas fa-city"></i> Рентный ЗПИФ «Региональная недвижимость»</a></li>
                            <li><a href="#"><i class="fas fa-hard-hat"></i> ЗПИФ недвижимости «Инженер»</a></li>
                        </ul>
                    </div>

                    <div class="footer-section">
                        <h3>Контакты</h3>
                        <ul class="footer-links">
                            <li><a href="#"><i class="fas fa-map-marker-alt"></i> 125284, г. Москва, шоссе Хорошёвское, дом 32А</a></li>
                            <li><a href="tel:+74997019919"><i class="fas fa-phone"></i> (499) 701-99-19</a></li>
                            <li><a href="mailto:info@trustunionam.ru"><i class="fas fa-envelope"></i> info@trustunionam.ru</a></li>
                            <li><a href="http://www.trustunionam.ru"><i class="fas fa-globe"></i> www.trustunionam.ru</a></li>
                        </ul>
                    </div>
                </div>

                <div class="copyright">
                    <p>&copy; 2008-2025, ООО «ТрастЮнион АйЭм». Информация о структуре и составе участников.</p>
                    <p>Рентный закрытый паевой инвестиционный фонд «Земельные ресурсы» (правила доверительного
                        управления паевым инвестиционным фондом №2308 зарегистрированы 31.01.2012г. ФСФР России).</p>
                    <p>Рентный закрытый паевой инвестиционный фонд «Региональная недвижимость» (правила доверительного
                        управления паевым инвестиционным фондом №2476 зарегистрированы 15.11.2012г. ФСФР России).</p>
                    <p>Закрытый паевой инвестиционный фонд недвижимости «Инженер» (правила доверительного управления
                        паевым инвестиционным фондом №1443-94157038 зарегистрированы 02.06.2009г. ФСФР России).</p>
                </div>
            </div>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Инициализация аккордеонов
            function initAccordions() {
                // Открыть первый год и первый квартал
                const firstYear = document.querySelector('.year-section');
                if (firstYear) {
                    firstYear.classList.add('active');
                    
                    const firstQuarter = firstYear.querySelector('.quarter-card');
                    if (firstQuarter) {
                        firstQuarter.classList.add('active');
                    }
                }
                
                // Обработчики для заголовков годов
                document.querySelectorAll('.year-header').forEach(header => {
                    header.addEventListener('click', function() {
                        const section = this.parentElement;
                        section.classList.toggle('active');
                    });
                });
                
                // Обработчики для заголовков кварталов
                document.querySelectorAll('.quarter-header').forEach(header => {
                    header.addEventListener('click', function() {
                        const card = this.closest('.quarter-card');
                        card.classList.toggle('active');
                    });
                });
            }
            
            // Фильтрация по годам
            function initYearFilters() {
                document.querySelectorAll('.year-filter-btn').forEach(btn => {
                    btn.addEventListener('click', function() {
                        const year = this.dataset.year;
                        
                        // Обновить активную кнопку
                        document.querySelectorAll('.year-filter-btn').forEach(b => {
                            b.classList.remove('active');
                        });
                        this.classList.add('active');
                        
                        // Показать/скрыть секции годов
                        document.querySelectorAll('.year-section').forEach(section => {
                            if (year === 'all' || section.dataset.year === year) {
                                section.style.display = 'block';
                            } else {
                                section.style.display = 'none';
                            }
                        });
                    });
                });
            }
            
            // Установка дат по умолчанию
            function setDefaultDates() {
                const startInput = document.getElementById('start_date');
                const endInput = document.getElementById('end_date');
                
                if (!startInput.value && !endInput.value) {
                    const today = new Date();
                    const oneMonthAgo = new Date();
                    oneMonthAgo.setMonth(today.getMonth() - 1);
                    
                    startInput.value = formatDate(oneMonthAgo);
                    endInput.value = formatDate(today);
                }
            }
            
            // Форматирование даты в YYYY-MM-DD
            function formatDate(date) {
                const d = new Date(date);
                let month = '' + (d.getMonth() + 1);
                let day = '' + d.getDate();
                const year = d.getFullYear();
            
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
            
                return [year, month, day].join('-');
            }
            
            // Инициализация
            initAccordions();
            initYearFilters();
            setDefaultDates();
        });
    </script>
</body>
</html>