<?php

namespace Database\Seeders;

use App\Models\City;
use App\Models\RegulationDocument;
use App\Models\State;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

/**
 * India Regulation Documents Seeder
 *
 * Seeds representative regulation document records (DCR PDFs, building bye-law
 * documents, master plan extracts) for all 28 states + Delhi with realistic
 * pre-extracted zone rules and AI metadata.
 *
 * Documents are seeded as "completed + approved + applied" so the system shows
 * a fully populated document library. Placeholder PDF files are created in
 * storage so the records are consistent.
 */
class IndiaRegulationDocumentsSeeder extends Seeder
{
    public function run(): void
    {
        $admin = User::first();
        $adminId = $admin?->id;
        $total = 0;

        foreach ($this->documentData() as $stateCode => $docs) {
            $state = State::where('code', $stateCode)->first();
            if (! $state) {
                $this->command->warn("State [{$stateCode}] not found — skipping.");
                continue;
            }

            $count = 0;
            foreach ($docs as $doc) {
                $cityId = null;
                if (! empty($doc['city'])) {
                    $city = City::where('state_id', $state->id)
                        ->where('name', $doc['city'])->first();
                    $cityId = $city?->id;
                }

                $slug = Str::slug($doc['title']);
                $ext = $doc['document_type'] ?? 'pdf';
                $filename = $doc['original_filename'] ?? $slug . '.' . $ext;
                $storagePath = 'regulation-documents/' . $slug . '-seed.' . $ext;

                // Create a placeholder file so storage path is valid
                $fullPath = storage_path('app/' . $storagePath);
                if (! file_exists($fullPath)) {
                    $dir = dirname($fullPath);
                    if (! is_dir($dir)) {
                        mkdir($dir, 0755, true);
                    }
                    file_put_contents($fullPath, '%PDF-1.4 placeholder for seeded regulation document: ' . $doc['title']);
                }

                $fileSize = filesize($fullPath);
                $fileHash = hash_file('sha256', $fullPath);

                RegulationDocument::firstOrCreate(
                    ['title' => $doc['title'], 'state_id' => $state->id],
                    [
                        'city_id'              => $cityId,
                        'uploaded_by'          => $adminId,
                        'document_type'        => $ext,
                        'original_filename'    => $filename,
                        'storage_path'         => $storagePath,
                        'file_hash'            => $fileHash,
                        'file_size_bytes'      => $fileSize,
                        'extraction_status'    => 'completed',
                        'extraction_error'     => null,
                        'extracted_text_chunks' => $doc['text_chunks'] ?? $this->defaultTextChunks($doc['title'], $state->name),
                        'extracted_rules'      => $doc['rules'],
                        'ai_metadata'          => [
                            'model'            => 'gpt-4o-2024-05-13',
                            'chunks_processed' => count($doc['rules']),
                            'prompt_tokens'    => rand(2800, 6500),
                            'reply_tokens'     => rand(1200, 3800),
                            'total_tokens'     => rand(4000, 10000),
                            'processing_time'  => round(rand(800, 4500) / 100, 2),
                        ],
                        'review_status'        => 'approved',
                        'reviewed_by'          => $adminId,
                        'reviewed_at'          => now()->subDays(rand(1, 30)),
                        'review_notes'         => 'Verified against official gazette / published document.',
                        'rules_applied'        => true,
                    ]
                );
                $count++;
            }

            $this->command->info("  ✓ {$state->name} ({$stateCode}): {$count} documents");
            $total += $count;
        }

        $this->command->info("Regulation document seeding complete — {$total} documents.");
    }

    private function defaultTextChunks(string $title, string $stateName): array
    {
        return [
            "CHAPTER 1 — PRELIMINARY\n\nThis document titled \"{$title}\" establishes the development control regulations applicable to {$stateName}. These regulations shall come into force from the date of publication in the Official Gazette and shall apply to all development activities within the jurisdictional area.",
            "CHAPTER 3 — GENERAL LAND USE AND ZONING\n\nThe planning area is divided into zones as specified in the Development Plan / Master Plan. Each zone shall have specific regulations regarding Floor Area Ratio (FAR), ground coverage, height, setbacks, parking, and permissible land uses as detailed in the following sections.",
            "CHAPTER 5 — DEVELOPMENT CONTROL REGULATIONS\n\nThe Floor Area Ratio (FAR), ground coverage, building height, and setback requirements shall be as prescribed in the zone-wise table of development control parameters. Road-width-based norms apply for determination of maximum building height and FAR entitlement.",
        ];
    }

    /**
     * Build a single extracted_rule entry.
     */
    private static function rule(
        string $zoneName,
        string $zoneCode,
        float $farMin,
        float $farMax,
        int $coveragePct,
        int $maxFloors,
        float $maxHeightM,
        float $roadWidthM,
        float $frontSetback,
        float $rearSetback,
        float $sideSetback,
        array $permitted,
        array $prohibited,
        string $conditions = '',
        float $confidence = 0.91,
    ): array {
        return [
            'zone_name'            => $zoneName,
            'zone_code'            => $zoneCode,
            'far_min'              => $farMin,
            'far_max'              => $farMax,
            'ground_coverage_pct'  => $coveragePct,
            'max_floors'           => $maxFloors,
            'max_height_m'         => $maxHeightM,
            'road_width_required_m'=> $roadWidthM,
            'front_setback_m'      => $frontSetback,
            'rear_setback_m'       => $rearSetback,
            'side_setback_m'       => $sideSetback,
            'permitted_uses'       => $permitted,
            'prohibited_uses'      => $prohibited,
            'special_conditions'   => $conditions,
            'source_text'          => "Extracted from {$zoneName} ({$zoneCode}) regulations.",
            'confidence'           => $confidence,
        ];
    }

    // ================================================================
    //  DOCUMENT DATA — per state
    // ================================================================

    private function documentData(): array
    {
        return [
            // ── Andhra Pradesh ──────────────────────────────────────
            'AP' => [
                [
                    'title'             => 'AP Building Rules GO Ms No 119 - 2017',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'AP_Building_Rules_GO_119_2017.pdf',
                    'rules'             => [
                        self::rule('Residential General', 'R1', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial', 'warehousing'],
                            'RWH mandatory for plots > 200 sqm', 0.93),
                        self::rule('Residential High Density', 'R2', 2.0, 2.5, 50, 8, 27, 12.0, 4.5, 3.0, 3.0,
                            ['residential', 'group housing'], ['industrial', 'hazardous'],
                            'Fire NOC required above 15m height', 0.91),
                        self::rule('Commercial General', 'C', 2.5, 3.0, 60, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['commercial', 'retail', 'office'], ['residential only', 'heavy industry'],
                            'Parking @ 1 ECS per 50 sqm built-up', 0.92),
                        self::rule('Industrial', 'IND', 1.0, 1.5, 50, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse', 'logistics'], ['residential', 'educational'],
                            'EIA clearance for units > 500 sqm plot', 0.89),
                        self::rule('Agricultural Zone', 'AG', 0.3, 0.5, 20, 2, 7, 6.0, 3.0, 2.0, 2.0,
                            ['farmhouse', 'agro-processing'], ['commercial', 'industrial', 'group housing'],
                            'NA conversion required for non-agri use', 0.90),
                    ],
                ],
                [
                    'title'             => 'VMRDA Master Plan Visakhapatnam 2041',
                    'city'              => 'Visakhapatnam',
                    'document_type'     => 'pdf',
                    'original_filename' => 'VMRDA_Master_Plan_Vizag_2041.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'parks'], ['industrial'],
                            'CRZ restrictions apply for coastal plots', 0.90),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 60, 12, 42, 15.0, 5.0, 3.0, 3.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Airport funnel zone height restrictions apply', 0.88),
                        self::rule('IT/ITES Zone', 'IT', 2.5, 3.5, 55, 15, 50, 18.0, 6.0, 4.0, 4.0,
                            ['IT office', 'data centre', 'R&D'], ['residential', 'manufacturing'],
                            'SEZ norms may override for designated IT parks', 0.87),
                    ],
                ],
            ],

            // ── Arunachal Pradesh ───────────────────────────────────
            'AR' => [
                [
                    'title'             => 'Itanagar Capital Region Building Bye-Laws 2019',
                    'city'              => 'Itanagar',
                    'document_type'     => 'pdf',
                    'original_filename' => 'Itanagar_Building_ByeLaws_2019.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 45, 3, 10, 6.0, 2.5, 2.0, 1.5,
                            ['residential', 'small shop'], ['heavy industry'],
                            'Earthquake Zone V — IS 1893 compliance mandatory', 0.88),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office'], ['large factory'],
                            'Slope stability certificate required for gradient > 30°', 0.86),
                        self::rule('Green Belt', 'GB', 0.1, 0.2, 10, 1, 4, 6.0, 6.0, 6.0, 6.0,
                            ['eco-tourism', 'plantation'], ['construction', 'mining'],
                            'Forest clearance required under FC Act 1980', 0.90),
                    ],
                ],
            ],

            // ── Assam ───────────────────────────────────────────────
            'AS' => [
                [
                    'title'             => 'GMDA Building Construction Rules 2021',
                    'city'              => 'Guwahati',
                    'document_type'     => 'pdf',
                    'original_filename' => 'GMDA_Building_Rules_2021.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Flood zone restrictions — plinth min 1.5m above HFL', 0.91),
                        self::rule('Residential High Density', 'R2', 2.0, 2.5, 50, 7, 24, 12.0, 4.5, 3.0, 3.0,
                            ['group housing', 'residential'], ['industrial', 'hazardous'],
                            'Hill zone — max cut/fill 3m from natural ground', 0.89),
                        self::rule('Commercial Zone', 'C', 2.5, 3.0, 60, 8, 30, 12.0, 5.0, 3.0, 3.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'CRZ compliance for Brahmaputra riverfront plots', 0.90),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 50, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['factory', 'warehouse'], ['residential'],
                            'PCBA consent required for all industrial operations', 0.88),
                    ],
                ],
            ],

            // ── Bihar ───────────────────────────────────────────────
            'BR' => [
                [
                    'title'             => 'Bihar Building Bye Laws 2014',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Bihar_Building_ByeLaws_2014.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 55, 4, 15, 7.5, 3.0, 2.0, 1.5,
                            ['residential', 'parks'], ['industrial'],
                            'Mandatory RWH for plots > 300 sqm', 0.92),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 60, 8, 27, 12.0, 4.5, 3.0, 3.0,
                            ['retail', 'office', 'bank'], ['heavy industry'],
                            'Parking: 1 ECS per 50 sqm for commercial', 0.90),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 50, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse'], ['residential', 'school'],
                            'BSPCB NOC required for all categories', 0.88),
                    ],
                ],
                [
                    'title'             => 'Patna Master Plan 2031 Development Control Rules',
                    'city'              => 'Patna',
                    'document_type'     => 'pdf',
                    'original_filename' => 'PRDA_Master_Plan_Patna_2031.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Ganga River flood zone — min FFP as per PRDA notification', 0.91),
                        self::rule('Mixed Use Zone', 'MU', 2.0, 2.75, 55, 7, 24, 12.0, 4.0, 3.0, 2.5,
                            ['residential', 'retail', 'office'], ['heavy industry'],
                            'Ground floor commercial allowed on designated roads', 0.89),
                    ],
                ],
            ],

            // ── Chhattisgarh ────────────────────────────────────────
            'CG' => [
                [
                    'title'             => 'Chhattisgarh Bhavan Nirmaan Niyam 2019',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'CG_Building_ByeLaws_2019.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.25, 1.75, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Solar water heating mandatory for > 500 sqm built-up', 0.90),
                        self::rule('Commercial Zone', 'C', 2.0, 2.5, 55, 7, 24, 12.0, 4.5, 3.0, 3.0,
                            ['commercial', 'retail', 'office'], ['heavy industry'],
                            'Parking: ground/basement mandatory for > 300 sqm', 0.88),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 50, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'processing'], ['residential', 'education'],
                            'CPCB consent required for red/orange category', 0.87),
                    ],
                ],
            ],

            // ── Delhi ───────────────────────────────────────────────
            'DL' => [
                [
                    'title'             => 'Unified Building Bye Laws for Delhi 2016',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Delhi_Unified_Building_ByeLaws_2016.pdf',
                    'rules'             => [
                        self::rule('Residential Plotted', 'R1', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'professional office'], ['industrial', 'godown'],
                            'FAR premium up to 50% on payment for plots > 500 sqm', 0.94),
                        self::rule('Residential Group Housing', 'R2', 2.0, 3.5, 35, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['group housing', 'EWS/LIG flats'], ['industrial', 'warehouse'],
                            'GRIHA/IGBC rating mandatory for > 5000 sqm BUA', 0.93),
                        self::rule('Commercial', 'C', 2.0, 3.5, 40, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['retail', 'commercial', 'office', 'hotel'], ['heavy industry'],
                            'Fire NOC mandatory above 15m; helipad for > 60m', 0.92),
                        self::rule('Mixed Use', 'MU', 2.0, 3.0, 45, 10, 36, 12.0, 6.0, 3.0, 3.0,
                            ['residential', 'retail', 'office', 'clinic'], ['heavy industry'],
                            'Mixed use as per Master Plan designated categories', 0.91),
                        self::rule('Industrial', 'IND', 1.5, 2.0, 55, 4, 15, 12.0, 6.0, 4.5, 4.5,
                            ['manufacturing', 'warehouse', 'IT'], ['residential except caretaker'],
                            'DPCC consent required; flatted factory FAR 2.5', 0.90),
                    ],
                ],
                [
                    'title'             => 'Master Plan for Delhi 2041 - Land Use and Zoning',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'MPD_2041_Land_Use_Zoning.pdf',
                    'rules'             => [
                        self::rule('Transit Oriented Development (TOD)', 'TOD', 3.0, 4.0, 40, 20, 70, 24.0, 9.0, 6.0, 6.0,
                            ['residential', 'commercial', 'transit facility'], ['heavy industry'],
                            'Applicable within 500m of MRTS stations; FAR incentive linked to public transport integration', 0.89),
                        self::rule('Green Belt / Ridge', 'GB', 0.0, 0.0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0,
                            ['forestry', 'conservation'], ['all construction'],
                            'No construction — protected under Delhi Ridge notification', 0.95),
                    ],
                ],
            ],

            // ── Goa ────────────────────────────────────────────────
            'GA' => [
                [
                    'title'             => 'Goa Land Development and Building Construction Regulations 2010',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Goa_LDBCR_2010_amended_2022.pdf',
                    'rules'             => [
                        self::rule('Settlement Zone', 'R1', 0.75, 1.2, 40, 3, 11, 7.5, 2.5, 2.0, 1.5,
                            ['residential', 'guest house < 12 rooms'], ['industrial'],
                            'Panchayat NOC required; eco-sensitive zone restrictions', 0.90),
                        self::rule('Commercial Zone', 'C', 1.0, 2.0, 45, 5, 17, 12.0, 4.0, 3.0, 2.5,
                            ['retail', 'hotel', 'restaurant'], ['heavy industry', 'mining'],
                            'Tourism dept clearance for hotels > 20 rooms', 0.88),
                        self::rule('Industrial Zone', 'IND', 0.75, 1.0, 50, 2, 10, 12.0, 5.0, 3.0, 3.0,
                            ['manufacturing', 'warehouse'], ['residential', 'hotel'],
                            'GPCB consent required; no red category in RPG area', 0.87),
                        self::rule('No Development Zone', 'GB', 0.0, 0.0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0,
                            ['forestry', 'agriculture'], ['all construction'],
                            'Western Ghats ESA and Wildlife corridor protection', 0.94),
                    ],
                ],
            ],

            // ── Gujarat ─────────────────────────────────────────────
            'GJ' => [
                [
                    'title'             => 'Gujarat General Development Control Regulations GDCR 2017',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Gujarat_GDCR_2017.pdf',
                    'rules'             => [
                        self::rule('Residential R1 Zone', 'R1', 1.2, 1.8, 45, 4, 15, 9.0, 3.0, 2.5, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Affordable housing incentive FSI: additional 0.4 for EWS component', 0.93),
                        self::rule('Residential R2 Zone', 'R2', 1.8, 2.5, 40, 7, 24, 12.0, 4.5, 3.0, 3.0,
                            ['group housing', 'residential'], ['industrial'],
                            'TOD zones within 200m of BRTS/Metro: additional FAR 1.0', 0.91),
                        self::rule('Commercial Zone', 'C', 1.8, 4.0, 55, 14, 45, 15.0, 6.0, 4.5, 4.5,
                            ['retail', 'office', 'hotel', 'multiplex'], ['heavy industry'],
                            'Premium FSI (chargeable) up to 4.0; road > 30m no height limit', 0.92),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.8, 60, 3, 12, 12.0, 6.0, 4.5, 4.5,
                            ['factory', 'warehouse', 'logistics'], ['residential'],
                            'GIDC plot-specific norms may override GDCR', 0.88),
                        self::rule('Agricultural Zone', 'AG', 0.25, 0.45, 15, 2, 7, 6.0, 3.0, 2.0, 2.0,
                            ['farmhouse', 'agro-processing'], ['commercial complex', 'group housing'],
                            'NA permission from Collector mandatory; max 1500 sqm BUA', 0.90),
                    ],
                ],
                [
                    'title'             => 'AUDA Ahmedabad Development Plan 2021 DCR',
                    'city'              => 'Ahmedabad',
                    'document_type'     => 'pdf',
                    'original_filename' => 'AUDA_DP_2021_DCR.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.7, 45, 7, 24, 12.0, 4.0, 3.0, 2.0,
                            ['residential', 'home office'], ['industrial'],
                            'TP scheme final plot norms supersede general GDCR', 0.91),
                        self::rule('Heritage Zone — Walled City', 'HZ', 0.8, 1.5, 60, 3, 12, 6.0, 0.0, 1.5, 0.0,
                            ['residential', 'heritage hotel', 'craft workshop'], ['high-rise', 'industrial'],
                            'UNESCO World Heritage Site — AMC Heritage Conservation Committee approval required', 0.93),
                        self::rule('GIFT City Special Zone', 'IT', 3.0, 5.5, 35, 30, 120, 24.0, 12.0, 9.0, 9.0,
                            ['fintech', 'IFSC', 'office', 'residential'], ['heavy industry'],
                            'GIFT SEZ autonomous building rules — IFSCA regulations override', 0.87),
                    ],
                ],
            ],

            // ── Haryana ─────────────────────────────────────────────
            'HR' => [
                [
                    'title'             => 'Haryana Building Code 2017',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Haryana_Building_Code_2017.pdf',
                    'rules'             => [
                        self::rule('Residential Plotted', 'R1', 1.5, 2.25, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'professional office'], ['industrial'],
                            'CLU (Change of Land Use) permission from TCP for non-residential', 0.92),
                        self::rule('Residential Group Housing', 'R2', 2.0, 3.5, 35, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['group housing', 'residential'], ['industrial'],
                            'Min 15% for EWS/LIG component in group housing > 2 acres', 0.90),
                        self::rule('Commercial Zone', 'C', 2.0, 3.5, 40, 14, 45, 15.0, 7.5, 4.5, 4.5,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'License under 1975 Act required for commercial colonies', 0.91),
                        self::rule('IT/Cyber Zone', 'IT', 2.5, 3.75, 40, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['IT office', 'R&D', 'data centre'], ['manufacturing'],
                            'Cyber City/Park specific norms per license conditions', 0.88),
                    ],
                ],
                [
                    'title'             => 'Gurugram Master Plan 2031 Sector Norms',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Gurugram_MP_2031_Sector_Norms.pdf',
                    'rules'             => [
                        self::rule('Mixed Use Zone', 'MU', 2.0, 3.25, 45, 12, 42, 15.0, 6.0, 4.0, 4.0,
                            ['residential', 'commercial', 'retail'], ['heavy industry'],
                            'SPR/Dwarka Expressway corridor: elevated FAR norms', 0.89),
                    ],
                ],
            ],

            // ── Himachal Pradesh ────────────────────────────────────
            'HP' => [
                [
                    'title'             => 'HP Town and Country Planning Rules Building Bye Laws 2014',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'HP_TCP_Building_ByeLaws_2014.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 40, 3, 11, 6.0, 2.5, 2.0, 1.5,
                            ['residential', 'guest house'], ['industrial'],
                            'Seismic Zone IV-V compliance; max 4 storeys including parking', 0.91),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['commercial', 'retail', 'hotel'], ['heavy industry'],
                            'Slope > 45° — no construction; slope-based setback calculation', 0.89),
                        self::rule('Green Belt', 'GB', 0.1, 0.2, 10, 1, 4, 6.0, 6.0, 6.0, 6.0,
                            ['forestry', 'eco-tourism'], ['construction', 'mining'],
                            'Forest clearance under FC Act 1980; S.118 land transfer restrictions', 0.92),
                    ],
                ],
            ],

            // ── Jharkhand ───────────────────────────────────────────
            'JH' => [
                [
                    'title'             => 'Jharkhand Building Bye Laws 2016',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Jharkhand_Building_ByeLaws_2016.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial', 'mining'],
                            'CNT/SPT Act restrictions on tribal land transfer', 0.91),
                        self::rule('Commercial Zone', 'C', 2.0, 2.5, 55, 7, 24, 12.0, 4.5, 3.0, 3.0,
                            ['retail', 'commercial', 'office'], ['heavy industry'],
                            'Mining subsidence zone — structural stability certificate required', 0.88),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 50, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'mining-related'], ['residential', 'educational'],
                            'JSPCB consent; Adivasi land — S.49 CNT Act clearance', 0.87),
                    ],
                ],
                [
                    'title'             => 'RRDA Ranchi Building Permission Rules 2018',
                    'city'              => 'Ranchi',
                    'document_type'     => 'pdf',
                    'original_filename' => 'RRDA_Ranchi_Building_Rules_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'RRDA development area norms; online permission via ABPAS', 0.90),
                        self::rule('Mixed Use Zone', 'MU', 2.0, 2.5, 50, 7, 24, 12.0, 4.0, 3.0, 2.5,
                            ['residential', 'retail', 'office'], ['heavy industry'],
                            'Main Road/Circular Road frontage: commercial on ground floor', 0.87),
                    ],
                ],
            ],

            // ── Karnataka ───────────────────────────────────────────
            'KA' => [
                [
                    'title'             => 'Karnataka Revised Master Plan 2031 Zonal Regulations Bangalore',
                    'city'              => 'Bengaluru',
                    'document_type'     => 'pdf',
                    'original_filename' => 'BDA_RMP_2031_Zonal_Regulations.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.75, 2.25, 55, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'BBMP Sakala approval; RWH mandatory all plots', 0.93),
                        self::rule('Residential High Density', 'R2', 2.5, 3.25, 45, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['group housing', 'residential'], ['industrial'],
                            'BWSSB water availability certificate required', 0.91),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 55, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['retail', 'office', 'hotel', 'hospital'], ['heavy industry'],
                            'Parking: min 1 ECS per 40 sqm for commercial BUA', 0.92),
                        self::rule('IT/BT Zone', 'IT', 2.5, 3.5, 50, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['IT office', 'biotech', 'R&D', 'data centre'], ['residential only', 'retail only'],
                            'Electronic City / Whitefield / ORR special area plan applicable', 0.89),
                        self::rule('Green Belt', 'GB', 0.1, 0.3, 10, 1, 4, 6.0, 6.0, 6.0, 6.0,
                            ['parks', 'nursery'], ['all construction'],
                            'Lake buffer zone: 75m from lake boundary — no construction', 0.94),
                    ],
                ],
            ],

            // ── Kerala ──────────────────────────────────────────────
            'KL' => [
                [
                    'title'             => 'Kerala Municipality Building Rules KMBR 2019',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'KMBR_2019.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 4, 14, 7.5, 2.5, 1.5, 1.5,
                            ['residential', 'home industry'], ['industrial'],
                            'Mandatory RWH and STP for > 20 units', 0.92),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 55, 8, 27, 10.0, 3.0, 2.5, 2.5,
                            ['commercial', 'retail', 'hotel'], ['heavy industry'],
                            'Occupancy Group 7 categories apply', 0.90),
                        self::rule('Mixed Residential', 'MU', 1.75, 2.5, 50, 6, 21, 9.0, 3.0, 2.0, 2.0,
                            ['residential', 'retail', 'clinic'], ['heavy industry'],
                            'Ground floor commercial on >10m road frontage only', 0.88),
                    ],
                ],
                [
                    'title'             => 'GCDA Master Plan Kochi 2031 Building Regulations',
                    'city'              => 'Kochi',
                    'document_type'     => 'pdf',
                    'original_filename' => 'GCDA_Kochi_MP_2031.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.5, 45, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'parks'], ['industrial'],
                            'CRZ Zone II applies to Fort Kochi / Mattancherry — 50m setback', 0.89),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 55, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['commercial', 'retail', 'office'], ['heavy industry'],
                            'Kochi Metro TOD zone — 500m radius enhanced FAR', 0.87),
                    ],
                ],
            ],

            // ── Madhya Pradesh ──────────────────────────────────────
            'MP' => [
                [
                    'title'             => 'MP Bhumi Vikas Niyam Land Development Rules 2012',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'MP_Bhumi_Vikas_Niyam_2012.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.25, 1.75, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Online permission via MP e-Nagar portal', 0.91),
                        self::rule('Residential Group Housing', 'R2', 1.75, 2.5, 40, 8, 27, 12.0, 6.0, 4.0, 4.0,
                            ['group housing', 'residential'], ['industrial'],
                            'Min 5% EWS component in group housing > 1 acre', 0.89),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 55, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['commercial', 'retail', 'office'], ['heavy industry'],
                            'TDA/ADA/local body DA specific conditions may apply', 0.90),
                        self::rule('Agricultural Zone', 'AG', 0.25, 0.4, 15, 2, 7, 6.0, 3.0, 2.0, 2.0,
                            ['farmhouse', 'agricultural'], ['commercial', 'group housing'],
                            'Diversion from agricultural use — Collector approval S.59', 0.88),
                    ],
                ],
            ],

            // ── Maharashtra ─────────────────────────────────────────
            'MH' => [
                [
                    'title'             => 'Unified DCPR Maharashtra 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Maharashtra_UDCPR_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone R1', 'R1', 1.0, 1.5, 40, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Base FSI + TDR/Premium FSI applicable. Fungible FSI: 35% for residential', 0.94),
                        self::rule('Residential Zone R2', 'R2', 1.5, 2.5, 35, 14, 51, 15.0, 6.0, 4.5, 4.5,
                            ['group housing'], ['industrial', 'godown'],
                            'Affordable housing: additional 50% FSI on payment of premium', 0.92),
                        self::rule('Commercial Zone', 'C', 1.5, 3.0, 40, 14, 51, 15.0, 6.0, 4.5, 4.5,
                            ['retail', 'office', 'hotel', 'hospital'], ['heavy industry'],
                            'Road >30m: no height limit. TDR permissible. Premium FSI for additional BUA.', 0.93),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 60, 3, 12, 12.0, 6.0, 4.5, 4.5,
                            ['manufacturing', 'warehouse', 'IT'], ['residential'],
                            'MPCB consent required. IT/BPO exempted from industrial norms.', 0.90),
                        self::rule('Green Belt / No Development Zone', 'GB', 0.0, 0.0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0,
                            ['forestry', 'agriculture'], ['all construction'],
                            'NDZ / Conservation Zone per DP. No NA conversion.', 0.95),
                    ],
                ],
                [
                    'title'             => 'DCPR for Greater Mumbai 2034',
                    'city'              => 'Mumbai',
                    'document_type'     => 'pdf',
                    'original_filename' => 'Mumbai_DCPR_2034.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 3.0, 35, 20, 70, 18.0, 6.0, 4.5, 4.5,
                            ['residential', 'group housing'], ['industrial'],
                            'Island city base FSI 1.0 + premium up to 3.0; suburbs base 1.0/1.33 + premium', 0.94),
                        self::rule('Commercial Zone', 'C', 1.5, 5.0, 40, 30, 100, 24.0, 9.0, 6.0, 6.0,
                            ['commercial', 'office', 'hotel'], ['residential only'],
                            'SRA, MHADA, NTC mill land special provisions apply', 0.91),
                        self::rule('CRZ II Zone', 'CRZ', 0.5, 1.0, 33, 2, 9, 9.0, 0.0, 0.0, 0.0,
                            ['repair', 'reconstruction'], ['new construction expansion'],
                            'CRZ-II: only repair/reconstruction of existing authorized structures', 0.93),
                    ],
                ],
            ],

            // ── Manipur ─────────────────────────────────────────────
            'MN' => [
                [
                    'title'             => 'Manipur Building Bye Laws 2018',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Manipur_Building_ByeLaws_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 50, 3, 10, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Seismic Zone V compliance — IS 1893; flood zone plinth level norms', 0.88),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office'], ['heavy industry'],
                            'Imphal Valley specific; hill district HQ separate rules', 0.86),
                    ],
                ],
            ],

            // ── Meghalaya ───────────────────────────────────────────
            'ML' => [
                [
                    'title'             => 'Shillong Building Bye Laws Amended 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Shillong_Building_ByeLaws_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 45, 4, 14, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Seismic Zone V; ADC (Khasi Hills) NOC for non-tribal land transfer', 0.88),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 5, 17, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Heritage zone around Ward\'s Lake/Colonial structures — height cap 12m', 0.86),
                    ],
                ],
            ],

            // ── Mizoram ─────────────────────────────────────────────
            'MZ' => [
                [
                    'title'             => 'Aizawl Development Authority Building Bye Laws 2018',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'ADA_Aizawl_Building_ByeLaws_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 45, 3, 10, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Seismic Zone V; retaining wall certification for slope > 20°', 0.87),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office'], ['heavy industry'],
                            'ADA master plan area only; outer areas under village council', 0.85),
                    ],
                ],
            ],

            // ── Nagaland ────────────────────────────────────────────
            'NL' => [
                [
                    'title'             => 'Nagaland Building Bye Laws and Regulations 2011',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Nagaland_Building_ByeLaws_2011.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 50, 3, 10, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Art 371(A) customary land law — urban patta areas only; village council land not covered', 0.89),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office'], ['heavy industry'],
                            'Seismic Zone V; Kohima/Dimapur town area only', 0.86),
                    ],
                ],
            ],

            // ── Odisha ──────────────────────────────────────────────
            'OD' => [
                [
                    'title'             => 'Odisha CDP Building Regulations 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Odisha_CDP_Building_Regs_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'professional use'], ['industrial'],
                            'Cyclone-prone area — NDMA guidelines compliance mandatory', 0.91),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 55, 8, 27, 12.0, 5.0, 3.0, 3.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Online approval via SUJOG portal', 0.89),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 55, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse'], ['residential'],
                            'OSPCB consent; OSATIP restrictions in scheduled areas', 0.87),
                    ],
                ],
                [
                    'title'             => 'BDA Bhubaneswar CDP Building Rules 2020',
                    'city'              => 'Bhubaneswar',
                    'document_type'     => 'pdf',
                    'original_filename' => 'BDA_Bhubaneswar_CDP_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Temple heritage zone — ASI/State Archaeology clearance for proximity to Lingaraj', 0.90),
                        self::rule('IT Zone', 'IT', 2.5, 3.5, 45, 12, 42, 18.0, 6.0, 4.5, 4.5,
                            ['IT office', 'R&D', 'data centre'], ['residential only'],
                            'Infocity/Chandaka IT corridor: special development norms', 0.88),
                    ],
                ],
            ],

            // ── Punjab ──────────────────────────────────────────────
            'PB' => [
                [
                    'title'             => 'Punjab Building Rules 2018',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Punjab_Building_Rules_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'professional office'], ['industrial'],
                            'Controlled area (1963 Act) permission from TCP required', 0.91),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 55, 8, 27, 12.0, 5.0, 3.0, 3.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Focal Point industrial area: PSIEC/PUDA norms apply', 0.89),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 55, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['factory', 'warehouse'], ['residential'],
                            'PPCB consent; green belt of 10m mandatory along approach', 0.87),
                    ],
                ],
            ],

            // ── Rajasthan ───────────────────────────────────────────
            'RJ' => [
                [
                    'title'             => 'Rajasthan Nagar Vikas Niyam Building Regulations 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Rajasthan_Nagar_Vikas_Niyam_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.33, 1.75, 50, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Semi-arid zone: mandatory RWH for all construction', 0.92),
                        self::rule('Commercial Zone', 'C', 2.0, 3.0, 60, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['retail', 'commercial', 'office', 'hotel'], ['heavy industry'],
                            'JDA/UIT area-specific norms may override state rules', 0.90),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 55, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse'], ['residential'],
                            'RIICO industrial area: scheme-specific development norms apply', 0.88),
                        self::rule('Heritage Zone', 'HZ', 0.5, 1.0, 50, 2, 9, 6.0, 0.0, 1.5, 0.0,
                            ['restoration', 'heritage hotel', 'craft'], ['high-rise', 'industry'],
                            'Walled City Jaipur UNESCO zone: max 9m height, pink facade, INTACH NOC', 0.93),
                    ],
                ],
                [
                    'title'             => 'JDA Jaipur Building Bye Laws 2020',
                    'city'              => 'Jaipur',
                    'document_type'     => 'pdf',
                    'original_filename' => 'JDA_Jaipur_Building_ByeLaws_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.33, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'JDA final development plan area norms', 0.91),
                    ],
                ],
            ],

            // ── Sikkim ──────────────────────────────────────────────
            'SK' => [
                [
                    'title'             => 'Sikkim Building Construction Rules 2011',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Sikkim_Building_Rules_2011.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 45, 3, 11, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Seismic Zone IV; landslide-prone zone CA mandatory; Bhutia-Lepcha land restriction', 0.89),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 50, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'hotel', 'office'], ['heavy industry'],
                            'Gangtok town area only; green building norms for eco-tourism', 0.87),
                    ],
                ],
            ],

            // ── Tamil Nadu ──────────────────────────────────────────
            'TN' => [
                [
                    'title'             => 'TNCDBR Tamil Nadu Combined Development and Building Rules 2019',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'TNCDBR_2019.pdf',
                    'rules'             => [
                        self::rule('Residential Use Zone', 'R1', 1.5, 2.0, 55, 4, 14, 9.0, 3.0, 1.5, 1.5,
                            ['residential', 'professional office'], ['industrial'],
                            'Mandatory RWH & SWH for all buildings', 0.93),
                        self::rule('Residential High Density', 'R2', 2.0, 3.0, 45, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['group housing', 'residential'], ['industrial'],
                            'Solar energy system mandatory for BUA > 500 sqm', 0.91),
                        self::rule('Commercial Use Zone', 'C', 2.0, 3.0, 60, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['retail', 'office', 'hotel', 'hospital'], ['heavy industry'],
                            'Parking: 1 ECS per 65 sqm BUA; basement parking mandatory > 4 floors', 0.92),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 55, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse'], ['residential'],
                            'TNPCB consent required; SIPCOT area norms may differ', 0.89),
                        self::rule('IT Corridor Zone', 'IT', 2.0, 3.5, 50, 12, 42, 18.0, 6.0, 4.5, 4.5,
                            ['IT/ITES office', 'data centre'], ['residential-only', 'heavy industry'],
                            'OMR/GST Road IT Corridor: DTCP special building rules apply', 0.88),
                    ],
                ],
                [
                    'title'             => 'CMDA Chennai Second Master Plan Development Regulations 2026',
                    'city'              => 'Chennai',
                    'document_type'     => 'pdf',
                    'original_filename' => 'CMDA_SMP_Chennai_2026.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.5, 50, 6, 21, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'CRZ-II for East Coast Road plots — 50m HTL setback', 0.90),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 60, 12, 42, 15.0, 5.0, 3.0, 3.0,
                            ['commercial', 'hotel', 'office'], ['heavy industry'],
                            'Airport funnel zone: AAI NOC for height > 30m within funnel area', 0.88),
                    ],
                ],
            ],

            // ── Telangana ───────────────────────────────────────────
            'TS' => [
                [
                    'title'             => 'TS-bPASS Building Permission Rules Telangana 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'TS_bPASS_Rules_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 55, 4, 15, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'Plots ≤600 sqm: instant self-certification approval. Medium risk: 21-day timeline.', 0.94),
                        self::rule('Residential Group Housing', 'R2', 2.0, 3.0, 45, 12, 42, 15.0, 6.0, 4.0, 4.0,
                            ['group housing', 'residential'], ['industrial'],
                            'TS-RERA registration required for projects ≥ 500 sqm or ≥ 8 units', 0.91),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 55, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'HMDA Outer Ring Road corridor: enhanced FAR norms', 0.92),
                        self::rule('IT Zone - HITECH City', 'IT', 2.5, 4.0, 50, 20, 70, 18.0, 9.0, 6.0, 6.0,
                            ['IT office', 'data centre', 'R&D'], ['residential-only', 'manufacturing'],
                            'Cyberabad/Genome Valley/Pharma City: sector-specific development norms', 0.89),
                    ],
                ],
                [
                    'title'             => 'HMDA Hyderabad Zoning Regulations 2021',
                    'city'              => 'Hyderabad',
                    'document_type'     => 'pdf',
                    'original_filename' => 'HMDA_Hyderabad_Zoning_2021.pdf',
                    'rules'             => [
                        self::rule('Heritage Zone — Old City', 'HZ', 0.75, 1.25, 60, 3, 12, 6.0, 1.5, 1.0, 1.0,
                            ['residential', 'heritage commerce', 'craft'], ['high-rise', 'industry'],
                            'Charminar/Old City precinct: max 12m height, HMDA Heritage Committee approval', 0.90),
                        self::rule('Mixed Use Zone', 'MU', 2.0, 3.0, 50, 10, 36, 12.0, 5.0, 3.0, 3.0,
                            ['residential', 'commercial', 'retail'], ['heavy industry'],
                            'Main road frontage mixed use as per HMDA master plan notification', 0.88),
                    ],
                ],
            ],

            // ── Tripura ─────────────────────────────────────────────
            'TR' => [
                [
                    'title'             => 'Tripura Building Construction Rules 2018',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Tripura_Building_Rules_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.5, 50, 3, 10, 6.0, 2.5, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'Seismic Zone V compliance; TTAADC area — tribal land NOC required', 0.88),
                        self::rule('Commercial Zone', 'C', 1.5, 2.0, 55, 4, 15, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office'], ['heavy industry'],
                            'Agartala MC area specific; outline scheme norms apply', 0.86),
                    ],
                ],
            ],

            // ── Uttar Pradesh ───────────────────────────────────────
            'UP' => [
                [
                    'title'             => 'UP Combined Building Bye Laws 2021',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'UP_Building_Bye_Laws_2021.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.25, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential', 'home office'], ['industrial'],
                            'NIVESH MITRA portal approval; RWH mandatory for all plots', 0.92),
                        self::rule('Residential Group Housing', 'R2', 2.0, 3.5, 35, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['group housing', 'residential'], ['industrial'],
                            'UP-RERA registration mandatory for projects ≥500 sqm/8 units', 0.91),
                        self::rule('Commercial Zone', 'C', 2.0, 3.5, 45, 14, 51, 15.0, 7.5, 4.5, 4.5,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Green building for BUA > 5000 sqm; fire NOC above 15m', 0.90),
                        self::rule('Industrial Zone', 'IND', 1.5, 2.0, 55, 4, 15, 12.0, 6.0, 4.5, 4.5,
                            ['factory', 'warehouse', 'IT'], ['residential'],
                            'UPPCB consent; UPSIDC/EPIP area-specific norms', 0.88),
                    ],
                ],
                [
                    'title'             => 'NOIDA Building Regulations 2019',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'NOIDA_Building_Regulations_2019.pdf',
                    'rules'             => [
                        self::rule('Residential Group Housing', 'R2', 2.75, 3.5, 30, 20, 70, 18.0, 9.0, 6.0, 6.0,
                            ['group housing'], ['industrial'],
                            'NOIDA sector-based allotment norms; lease conditions apply', 0.91),
                        self::rule('IT/ITES Zone', 'IT', 3.0, 3.75, 40, 20, 70, 24.0, 9.0, 6.0, 6.0,
                            ['IT office', 'data centre', 'tech park'], ['residential-only'],
                            'Sector 62/135/142 IT zones: NOIDA Authority specific building norms', 0.89),
                        self::rule('Commercial Zone', 'C', 2.5, 3.5, 40, 14, 51, 18.0, 9.0, 6.0, 6.0,
                            ['retail', 'office', 'hotel', 'convention'], ['heavy industry'],
                            'Green building mandatory for BUA > 10,000 sqm; GRIHA rating', 0.88),
                    ],
                ],
            ],

            // ── Uttarakhand ─────────────────────────────────────────
            'UK' => [
                [
                    'title'             => 'Uttarakhand Building Bye Laws 2018',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'Uttarakhand_Building_ByeLaws_2018.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.0, 1.75, 45, 3, 11, 6.0, 2.5, 2.0, 1.5,
                            ['residential', 'guest house'], ['industrial'],
                            'Seismic Zone IV-V; slope-based setback calculation; S.154 land transfer restriction for non-locals', 0.91),
                        self::rule('Commercial Zone', 'C', 1.5, 2.5, 50, 5, 18, 9.0, 3.0, 2.0, 2.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'MDDA/HDDA area specific; eco-sensitive zone buffer compliance', 0.89),
                        self::rule('Green / Forest Zone', 'GB', 0.1, 0.2, 10, 1, 4, 6.0, 6.0, 6.0, 6.0,
                            ['eco-tourism', 'forest rest house'], ['construction', 'mining'],
                            'FC Act 1980 clearance; Bhagirathi Eco-Sensitive Zone notification', 0.92),
                    ],
                ],
            ],

            // ── West Bengal ─────────────────────────────────────────
            'WB' => [
                [
                    'title'             => 'WB Building Rules 2020',
                    'city'              => null,
                    'document_type'     => 'pdf',
                    'original_filename' => 'WB_Building_Rules_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 1.5, 2.0, 50, 5, 18, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'e-Nagar Sewa portal building permission; RWH mandatory', 0.91),
                        self::rule('Residential Group Housing', 'R2', 2.0, 3.5, 40, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['group housing'], ['industrial'],
                            'Min 10% EWS component for projects > 2000 sqm', 0.89),
                        self::rule('Commercial Zone', 'C', 2.5, 4.0, 55, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'Parking: min 1 ECS per 40 sqm BUA', 0.90),
                        self::rule('Industrial Zone', 'IND', 1.0, 1.5, 55, 3, 12, 12.0, 6.0, 4.0, 4.0,
                            ['manufacturing', 'warehouse'], ['residential'],
                            'WBPCB consent; S.4A/4C land conversion for non-agricultural use', 0.87),
                    ],
                ],
                [
                    'title'             => 'KMC Kolkata Municipal Building Rules 2020',
                    'city'              => 'Kolkata',
                    'document_type'     => 'pdf',
                    'original_filename' => 'KMC_Kolkata_Building_Rules_2020.pdf',
                    'rules'             => [
                        self::rule('Residential Zone', 'R1', 2.0, 3.0, 50, 8, 27, 9.0, 3.0, 2.0, 1.5,
                            ['residential'], ['industrial'],
                            'KMC area enhanced FAR; heritage conservation for BBD Bagh/Park Street', 0.91),
                        self::rule('Commercial Zone', 'C', 3.0, 4.0, 55, 14, 51, 15.0, 6.0, 4.0, 4.0,
                            ['retail', 'office', 'hotel'], ['heavy industry'],
                            'EM Bypass/Salt Lake IT corridor: enhanced FAR norms', 0.89),
                        self::rule('Heritage Zone', 'HZ', 0.75, 1.5, 60, 3, 12, 6.0, 0.0, 1.5, 0.0,
                            ['restoration', 'heritage hotel', 'gallery'], ['high-rise', 'industry'],
                            'Heritage Commission approval; Dalhousie Square/Writers Building precinct', 0.92),
                    ],
                ],
            ],
        ];
    }
}
