<style>
  canvas {
    width: 100% !important;
    max-height: 300px;
  }

  .stat-item {
    background-color: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    text-align: center;
  }

  .stat-icon {
    font-size: 2rem;
    color: #0d6efd;
    margin-bottom: 10px;
  }

  .chart-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
  }

  .select2-container .select2-selection--single {
    height: 38px;
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid #ced4da;
  }

  .select2-container .select2-search--inline .select2-search__field {
    min-height: 27px;
    display: flex;
    align-items: center;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    color: #444;
  }


  .chart-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
  }

  .chart-wrapper {
    flex: 1;
    min-width: 300px;
  }

.search-bg {
    background: 
        linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
        url('./assets/img/bg-banner2.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: 300px;
    padding: 20px;
    color: white;                                              
}

  th{
    font-weight: 400;
  }

  /* Light Blue (#DEEBF7) */
/*table td:nth-child(4),*/
/*table td:nth-child(11),*/
/*table td:nth-child(18) {*/
/*  background-color: #DEEBF7;*/
/*}*/

/* Light Yellow (#FFF2CC) */
/*table td:nth-child(n+5):nth-child(-n+6),*/
/*table td:nth-child(n+12):nth-child(-n+13),*/
/*table td:nth-child(n+19):nth-child(-n+20) {*/
/*  background-color: #FFF2CC;*/
/*}*/

/* White (#FFFFFF) */
/*table td:nth-child(n+7):nth-child(-n+8),*/
/*table td:nth-child(n+14):nth-child(-n+15),*/
/*table td:nth-child(n+21):nth-child(-n+22) {*/
/*  background-color: #fff;*/
/*}*/

/* Light Green (#E2F0D9) */
/*table td:nth-child(n+9):nth-child(-n+10),*/
/*table td:nth-child(n+16):nth-child(-n+17),*/
/*table td:nth-child(n+23):nth-child(-n+24) {*/
/*  background-color: #E2F0D9;*/
/*}*/

.hsn-header-yellow {
  background-color: #FFF2CC !important;
}

.hsn-header-blue {
  background-color: #DEEBF7 !important;
}

.hsn-header-green {
  background-color: #E2F0D9 !important;
}

.hsn-header-white {
  background-color: #ffffff !important;
}

#btnreset {
    background-color: #dc3545; 
    border-color: #dc3545;
    color: #fff;
    padding: 0.5rem 2rem;
    border-radius: 50px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#btnreset:hover { 
    background-color: #bb2d3b; 
    border-color: #b02a37;   
}
</style>
<main class="main">
  <!-- Hero Section -->
  <section id="hero" class="hero section pt-0">
    <div class="search-bg">
      <div class="container">
        <div class="row">
          <div class="col-md-12">

            <h5 class="fs-5 fw-bold text-dark-blue">Import from the world by the USA, and India's share of exports to
              the USA in
              both value and percentage.</h5>
          </div>
          
        </div>
        <!-- <div class="text-center mb-5">
          <h2 class="fw-bold text-dark">Import Dashboard usama</h2>
          <p class="text-muted">Imports by Country, Share %, Monthly Trends, and Growth</p>  
        </div> -->
        <div class="mb-2 mt-3">   
          <!-- Your Search Form -->
          <form id="hsn-code" action="hsn-code.php" method="post">
            <div class="row gy-2 align-items-center">
              <!-- HSN Code -->                                                                                                      

              <div class="col-md-2">  
                <label class="text-dark-blue  fw-bold" for="sel_chapeter">Select Chapter:</label>
                <select id="sel_chapeter" name="chapeter_code" class="form-select filter" required>
                  <?=getHSNCodeChapter($chaptercode)?>
                </select>
              </div>                                    


              <div class="col-md-2">
                <label class="text-dark-blue  fw-bold" for="to_country">Import in:</label>
                <select id="to_country" name="to_country" class="form-select filter" required>
                  <?=getToCountry($to_country) ?>
                </select>
              </div>
               
              <div class="col-md-8">
                <label class="text-dark-blue  fw-bold" for="sel_hscncode">Select HSN Code:</label>

                <select id="sel_hscncode" name="hsn_code" class="form-select">
                  <?=getHSNCode($chaptercode,$hsn_code)?>
                </select>
              </div>



              <!-- To Country -->



              <!-- <div class="col-md-4">
                <label class="text-dark-blue  fw-bold" for="to_country">From country:</label>
                <select id="from_country" name="from_country[]" class="form-select" multiple="multiple">
                </select>
              </div> -->

              <!-- Submit Button -->


     
     
        
            </div>  
            
            <div class="col-md-4 text-end ms-auto mt-3">
              <button type="submit" name="btnsearch" id="btnsearch" class="btn btn-primary me-0 me-sm-2 mx-1">
                Search
                <img src="<?= DOC_ROOT ?>assets/img/search.png" alt="Search"
                  style="height: 18px; vertical-align: middle; margin-left: 6px;">
              </button>
              
              <button type="reset" name="btnreset" id="btnreset" class="btn btn-secondary me-0 me-sm-2 mx-1">
                  Reset
                  <img src="<?= DOC_ROOT ?>assets/img/reset.png" alt="Reset"
                    style="height: 18px; vertical-align: middle; margin-left: 6px;">
                </button>

              
            </div>
   

          </form>
        </div>
      </div>
    </div>
    <div class="container py-4">
      <div class="row">

        <div class="col-md-12">

              
                   
          <?php  if($searchdatacount > 0){  ?>
          
              <h6 class="fs-5 fw-bold text-dark-blue"><?=$searchText?> </h6>


              <div class="chart-container">
                <!--<div class="chart-wrapper chart-card">-->
                <!--  <canvas id="barChart"></canvas>-->
                <!--</div>   -->
                 <div class="chart-wrapper chart-card">  
                  <canvas id="lineChart"></canvas>
                <p class="text-center mt-3 fw-bold">2021/2022/2023 HSN Import Value</p>
 
      
                </div>   
                <div class="chart-wrapper chart-card">   
                  <canvas id="pieChart"></canvas>
                  <p class="text-center mt-3 fw-bold">2021/2022/2023 Market Share Distribution (USD Thousands)</p>
    
                </div>
                 
              </div>
                <div class="row">  
                    <?php foreach($imagearray as $image){ ?>
              
                      <div class="col-md-3 mb-2">  
                        <img src="<?php echo $image ?>" width="100%"/>
                        </div>
                      <?php } ?>
     </div>           
              
              <div class="chart-card mb-4">
                <!-- <canvas id="barChart"></canvas> -->
                <div class="table-responsive">
                  <table class="table table-bordered table-sm text-center align-middle small table-hover"
                    style="font-size: 12px;">
    
                    <thead >
    
    
                      <?=$header?>
                    </thead>
                    <tbody>
                      <tr class="table-secondary text-center fw-bold">
                        <td colspan="25" class="p-0">Unit: Thousand US Dollars</td>
                      </tr>
                      <?=$row?>
                    </tbody>
                  </table>
                </div>
              </div>
              
          <?php  }else if(isset($searchdatacount))  { ?>
          <h6 class="fs-5 fw-bold text-dark-blue">Import in <?=$to_country?>, for Chapter <?=$chaptercode?> </h6>


          <h1> No records found for the selected filter.</h1>
          <?php  } ?>
 


        </div>  
      </div>
    </div>
  </section>    
</main>
