<?php require __DIR__ . '/../../includes/navBar.php'; ?>

<div class="container my-5">

    <div class="row justify-content-center">
        <div class="col-xl-16 col-lg-16">
            <div class="card card-rounded card-shadow border-0">

                <!-- HEADER -->
                 
                <div class="card-header header-dark px-4 py-3">
                    <div class="d-flex justify-content-between align-items-center flex-wrap">

                        <!-- IZQUIERDA -->

                        <div class="d-flex align-items-center gap-4">
                            <h4 class="mb-0 tittle-shadow" id="tituloInforme">
                                <i class="fas fa-chart-line me-2"></i> Balance Anual
                            </h4>

                            <div class="d-flex align-items-center gap-3">

                                <!-- AÑO -->

                                <div class="d-flex align-items-center gap-2 select-group">
                                    <i class="fas fa-calendar-alt text-light"></i>
                                    <select id="anio" class="form-select custom-select select-informe">
                                        <?php for ($i = date('Y'); $i >= 2020; $i--): ?>
                                            <option value="<?= $i ?>" <?= $i == date('Y') ? 'selected' : '' ?>>
                                                <?= $i ?>
                                            </option>
                                        <?php endfor; ?>
                                    </select>
                                </div>

                                <!-- TIPO INFORME -->

                                <div class="d-flex align-items-center gap-2 select-group">
                                    <i class="fas fa-chart-pie text-light"></i>
                                    <select id="tipoInforme" class="form-select custom-select select-informe">
                                        <option value="balance">Balance Anual</option>
                                        <option value="flujo">Dinero a Cobrar</option>
                                    </select>
                                </div>

                            </div>
                        </div>

                        <!-- DERECHA -->

                        <div class="d-flex gap-2">

                            <!-- BOTÓN FANTASMA (mantiene el layout) -->

                            <a class="btn btn-success invisible">
                                <i class="fas fa-plus me-1"></i>
                            </a>

                            <a href="index.php?opt=inicio_operador" class="btn btn-soft-secondary text-white">
                                <i class="fas fa-arrow-left me-1"></i> Volver
                            </a>
                            
                        </div>

                    </div>
                </div>

                <!-- BODY -->

                <div class="card-body p-4 bg-white">

                    <!-- KPI ROW -->

                    <div class="row mb-4 g-3">
                        <div class="col-md-3">
                            <div class="card shadow-sm border-0 text-center p-3">
                                <h6 class="text-muted mb-1">Ingresos</h6>
                                <h4 class="fw-bold text-success" id="kpiIngresos">$0</h4>
                            </div>
                        </div>

                        <div class="col-md-3">
                            <div class="card shadow-sm border-0 text-center p-3">
                                <h6 class="text-muted mb-1">Egresos</h6>
                                <h4 class="fw-bold text-danger" id="kpiEgresos">$0</h4>
                            </div>
                        </div>

                        <div class="col-md-3">
                            <div class="card shadow-sm border-0 text-center p-3">
                                <h6 class="text-muted mb-1">Resultado Neto</h6>
                                <h4 class="fw-bold" id="kpiResultado">$0</h4>
                            </div>
                        </div>

                        <div class="col-md-3">
                            <div class="card shadow-sm border-0 text-center p-3">
                                <h6 class="text-muted mb-1">Mejor Mes</h6>
                                <h4 class="fw-bold text-primary" id="kpiMejorMes">-</h4>
                            </div>
                        </div>
                    </div>

                    <!-- GRÁFICO -->
                     
                    <canvas id="graficoBalance" height="90"></canvas>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="js/informes.js"></script>