
<?php include_once "encabezado1.php"; ?>
<?php include 'conexion1.php'; ?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Listado de Pedidos</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            background-color: #f7f8fa;
            font-family: 'Roboto', sans-serif;
            color: #333;
        }
        .container {
            max-width: 900px;
            margin-top: 50px;
            background-color: #fff;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
            animation: fadeIn 0.8s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        h2 {
            color: #004085;
            font-weight: 700;
            font-size: 28px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        h2 .fas {
            color: #004085;
        }
        .table thead th {
            background-color: #004085;
            color: #fff;
            font-weight: 600;
            text-align: center;
        }
        .table tbody tr:hover {
            background-color: #e9f5ff;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .btn-custom {
            background-color: #17a2b8;
            color: white;
            transition: 0.3s;
            box-shadow: 0px 4px 10px rgba(23, 162, 184, 0.2);
        }
        .btn-custom:hover {
            background-color: #138496;
            transform: translateY(-2px);
        }
        .table-container {
            overflow-x: auto;
            animation: slideIn 1s ease-in-out;
        }
        @keyframes slideIn {
            from { opacity: 0; transform: translateX(-20px); }
            to { opacity: 1; transform: translateX(0); }
        }
        .actions {
            display: flex;
            justify-content: center;
            gap: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2><i class="fas fa-clipboard-list"></i> Listado de Pedidos</h2>
        <div class="table-container">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Cliente</th>
                        <th>Fecha</th>
                        <th>Total</th>
                        <th>Acciones</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $conexion = new mysqli($servidor, $nombre, $clave, $base);
                    $result = $conexion->query("SELECT p.id, pr.cliente_nombre, p.fecha, p.total 
                                                FROM pedidospre p 
                                                JOIN presupuestos pr ON p.presupuesto_id = pr.id");
                    while ($pedido = $result->fetch_assoc()) {
                        echo "<tr>
                            <td>{$pedido['id']}</td>
                            <td>{$pedido['cliente_nombre']}</td>
                            <td>{$pedido['fecha']}</td>
                            <td>S/. {$pedido['total']}</td>
                            <td class='actions'>
                                <a href='ver_detalle_pedido.php?id={$pedido['id']}' class='btn btn-custom'><i class='fas fa-eye'></i> Ver Detalles</a>
                            </td>
                        </tr>";
                    }
                    ?>
                </tbody>
            </table>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>
</html>