<?php $__env->startSection('title', 'Dashboard'); ?>
<?php $__env->startSection('page-title', 'Dashboard'); ?>
<?php $__env->startSection('breadcrumb'); ?>
    <li class="breadcrumb-item active">Dashboard</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>


<div class="row">
    <div class="col-lg-3 col-6">
        <div class="small-box bg-success">
            <div class="inner">
                <h3><?php echo e($habitacionesDisp); ?></h3>
                <p>Habitaciones Disponibles</p>
            </div>
            <div class="icon"><i class="fas fa-bed"></i></div>
            <a href="<?php echo e(route('habitaciones.index')); ?>" class="small-box-footer">
                Ver <i class="fas fa-arrow-circle-right"></i>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-danger">
            <div class="inner">
                <h3><?php echo e($habitacionesOcupadas); ?></h3>
                <p>Habitaciones Ocupadas</p>
            </div>
            <div class="icon"><i class="fas fa-door-open"></i></div>
            <a href="<?php echo e(route('habitaciones.index')); ?>" class="small-box-footer">
                Ver <i class="fas fa-arrow-circle-right"></i>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-info">
            <div class="inner">
                <h3><?php echo e($porcentajeOcupacion); ?>%</h3>
                <p>Ocupación (<?php echo e($habitacionesOcupadas); ?>/<?php echo e($totalHabitaciones); ?>)</p>
            </div>
            <div class="icon"><i class="fas fa-chart-pie"></i></div>
            <a href="<?php echo e(route('reportes.ocupacion')); ?>" class="small-box-footer">
                Reporte <i class="fas fa-arrow-circle-right"></i>
            </a>
        </div>
    </div>
    <div class="col-lg-3 col-6">
        <div class="small-box bg-warning">
            <div class="inner">
                <h3><?php echo e($habitacionesMant); ?></h3>
                <p>En Mantenimiento</p>
            </div>
            <div class="icon"><i class="fas fa-tools"></i></div>
            <a href="<?php echo e(route('habitaciones.index')); ?>" class="small-box-footer">
                Ver <i class="fas fa-arrow-circle-right"></i>
            </a>
        </div>
    </div>
</div>


<div class="row">
    <div class="col-md-3 col-sm-6">
        <div class="info-box">
            <span class="info-box-icon bg-success elevation-1"><i class="fas fa-sign-in-alt"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Check-ins Hoy</span>
                <span class="info-box-number"><?php echo e($checkinsHoy); ?></span>
                <span class="progress-description text-muted">Llegadas del día</span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="info-box">
            <span class="info-box-icon bg-danger elevation-1"><i class="fas fa-sign-out-alt"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Check-outs Hoy</span>
                <span class="info-box-number"><?php echo e($checkoutsHoy); ?></span>
                <span class="progress-description text-muted">Salidas del día</span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="info-box">
            <span class="info-box-icon bg-primary elevation-1"><i class="fas fa-users"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Total Huéspedes</span>
                <span class="info-box-number"><?php echo e($totalHuespedes); ?></span>
                <span class="progress-description text-muted">Registrados en el sistema</span>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="info-box">
            <span class="info-box-icon bg-warning elevation-1"><i class="fas fa-calendar-check"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Reservas este Mes</span>
                <span class="info-box-number"><?php echo e($reservasMes); ?></span>
                <span class="progress-description text-muted"><?php echo e(now()->locale('es')->isoFormat('MMMM')); ?></span>
            </div>
        </div>
    </div>
</div>


<div class="row">
    
    <div class="col-md-8">

        
        <div class="card">
            <div class="card-header border-0">
                <h3 class="card-title"><i class="fas fa-chart-bar mr-2 text-success"></i>Ocupación Últimos 7 Días</h3>
                <div class="card-tools">
                    <span class="text-muted small">Habitaciones ocupadas por día</span>
                </div>
            </div>
            <div class="card-body pt-0">
                <canvas id="chartOcupacion" height="90"></canvas>
            </div>
        </div>

        
        <div class="card">
            <div class="card-header border-0">
                <h3 class="card-title"><i class="fas fa-chart-line mr-2 text-primary"></i>Ingresos Últimos 6 Meses</h3>
                <div class="card-tools">
                    <span class="badge badge-success px-3 py-1">Total S/ <?php echo e(number_format($ingresosTotales, 0)); ?></span>
                </div>
            </div>
            <div class="card-body pt-0">
                <canvas id="chartIngresos" height="90"></canvas>
            </div>
        </div>

    </div>

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

        
        <div class="card" style="background: linear-gradient(135deg,#1e7e34,#28a745); color:#fff">
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div style="font-size:.85rem;opacity:.85">Ingresos del Mes</div>
                        <div style="font-size:1.9rem;font-weight:700">S/ <?php echo e(number_format($ingresosMes, 2)); ?></div>
                    </div>
                    <i class="fas fa-money-bill-wave fa-2x" style="opacity:.5"></i>
                </div>
                <hr style="border-color:rgba(255,255,255,.3);margin:10px 0">
                <a href="<?php echo e(route('reportes.ingresos')); ?>" class="text-white small">
                    <i class="fas fa-chart-line mr-1"></i>Ver reporte completo
                </a>
            </div>
        </div>

        
        <div class="card" style="background: linear-gradient(135deg,#b55e00,#fd7e14); color:#fff">
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <div style="font-size:.85rem;opacity:.85">Facturas Pendientes</div>
                        <div style="font-size:1.9rem;font-weight:700"><?php echo e($facturasPendientes); ?></div>
                    </div>
                    <i class="fas fa-file-invoice-dollar fa-2x" style="opacity:.5"></i>
                </div>
                <hr style="border-color:rgba(255,255,255,.3);margin:10px 0">
                <a href="<?php echo e(route('facturas.index')); ?>" class="text-white small">
                    <i class="fas fa-arrow-right mr-1"></i>Ver facturas pendientes
                </a>
            </div>
        </div>

        
        <div class="card">
            <div class="card-header py-2">
                <h3 class="card-title"><i class="fas fa-bolt mr-1 text-warning"></i>Acciones Rápidas</h3>
            </div>
            <div class="card-body p-2">
                <a href="<?php echo e(route('reservas.create')); ?>" class="btn btn-primary btn-block mb-2">
                    <i class="fas fa-calendar-plus mr-2"></i>Nueva Reserva
                </a>
                <a href="<?php echo e(route('huespedes.create')); ?>" class="btn btn-success btn-block mb-2">
                    <i class="fas fa-user-plus mr-2"></i>Nuevo Huésped
                </a>
                <a href="<?php echo e(route('calendario.disponibilidad')); ?>" class="btn btn-info btn-block mb-2">
                    <i class="fas fa-th mr-2"></i>Ver Disponibilidad
                </a>
                <a href="<?php echo e(route('reportes.ingresos')); ?>" class="btn btn-secondary btn-block">
                    <i class="fas fa-chart-bar mr-2"></i>Reportes
                </a>
            </div>
        </div>

    </div>
</div>


<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header border-0">
                <h3 class="card-title"><i class="fas fa-clock mr-2 text-info"></i>Reservas Recientes</h3>
                <div class="card-tools">
                    <a href="<?php echo e(route('reservas.index')); ?>" class="btn btn-sm btn-outline-secondary">Ver todas</a>
                </div>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover table-sm mb-0">
                        <thead class="thead-light">
                            <tr>
                                <th>Código</th>
                                <th>Huésped</th>
                                <th>Habitación</th>
                                <th>Entrada</th>
                                <th>Salida</th>
                                <th>Total</th>
                                <th>Estado</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $reservasRecientes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><small class="text-muted"><?php echo e($r->codigo); ?></small></td>
                                <td>
                                    <strong><?php echo e($r->huesped->apellido); ?></strong>, <?php echo e($r->huesped->nombre); ?>

                                </td>
                                <td><span class="badge badge-secondary">Hab. <?php echo e($r->habitacion->numero); ?></span></td>
                                <td><?php echo e($r->fecha_entrada->format('d/m/Y')); ?></td>
                                <td><?php echo e($r->fecha_salida->format('d/m/Y')); ?></td>
                                <td><strong>S/ <?php echo e(number_format($r->total, 2)); ?></strong></td>
                                <td>
                                    <span class="badge badge-<?php echo e($r->estado_badge); ?>"><?php echo e(ucfirst($r->estado)); ?></span>
                                </td>
                                <td>
                                    <a href="<?php echo e(route('reservas.show', $r)); ?>" class="btn btn-xs btn-outline-primary">
                                        <i class="fas fa-eye"></i>
                                    </a>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr><td colspan="8" class="text-center text-muted py-4">Sin reservas registradas</td></tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
// ── Gráfico Ocupación 7 días ──────────────────────────────────────────────
const ocupData = <?php echo json_encode($ocupacionSemanal, 15, 512) ?>;
new Chart(document.getElementById('chartOcupacion'), {
    type: 'bar',
    data: {
        labels: ocupData.map(d => d.fecha),
        datasets: [{
            label: 'Habitaciones Ocupadas',
            data: ocupData.map(d => d.ocupadas),
            backgroundColor: ocupData.map((d, i) =>
                i === ocupData.length - 1 ? 'rgba(40,167,69,0.9)' : 'rgba(40,167,69,0.55)'
            ),
            borderColor: '#28a745',
            borderWidth: 1,
            borderRadius: 5,
        }]
    },
    options: {
        responsive: true,
        plugins: {
            legend: { display: false },
            tooltip: {
                callbacks: { label: ctx => ' ' + ctx.raw + ' habitaciones' }
            }
        },
        scales: {
            y: { beginAtZero: true, ticks: { stepSize: 1 }, max: <?php echo e($totalHabitaciones); ?> },
            x: { grid: { display: false } }
        }
    }
});

// ── Gráfico Ingresos 6 meses ──────────────────────────────────────────────
const ingData = <?php echo json_encode($ingresosMensuales, 15, 512) ?>;
new Chart(document.getElementById('chartIngresos'), {
    type: 'line',
    data: {
        labels: ingData.map(d => d.mes),
        datasets: [{
            label: 'Ingresos S/',
            data: ingData.map(d => parseFloat(d.total)),
            fill: true,
            backgroundColor: 'rgba(0,123,255,0.1)',
            borderColor: '#007bff',
            borderWidth: 2.5,
            tension: 0.4,
            pointRadius: 5,
            pointBackgroundColor: '#007bff',
            pointBorderColor: '#fff',
            pointBorderWidth: 2,
        }]
    },
    options: {
        responsive: true,
        plugins: {
            legend: { display: false },
            tooltip: {
                callbacks: {
                    label: ctx => ' S/ ' + parseFloat(ctx.raw).toLocaleString('es-PE', {minimumFractionDigits: 2})
                }
            }
        },
        scales: {
            y: {
                beginAtZero: true,
                ticks: { callback: val => 'S/ ' + val.toLocaleString() }
            },
            x: { grid: { display: false } }
        }
    }
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Webs\PHP\sistema-hospedaje\resources\views/dashboard/index.blade.php ENDPATH**/ ?>