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

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Listado de Cotizaciones y Pedidos</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <style>
        /* General Styles */
        body {
            background-color: #f4f6f9;
            font-family: 'Roboto', sans-serif;
            color: #343a40;
        }
        .container {
            max-width: 1000px;
            margin-top: 50px;
            background-color: #fff;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
            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: 24px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        h2 .fas {
            color: #004085;
        }
        
        /* Table Styles */
        .table {
            width: 100%;
            margin-bottom: 20px;
            animation: slideIn 0.8s ease-in-out;
        }
        @keyframes slideIn {
            from { opacity: 0; transform: translateX(-20px); }
            to { opacity: 1; transform: translateX(0); }
        }
        .table thead {
            background-color: #007bff;
            color: #fff;
        }
        .table th, .table td {
            text-align: center;
            vertical-align: middle;
        }
        .table tbody tr:hover {
            background-color: #f1f3f5;
            transition: background-color 0.3s;
        }
        
        /* Action Button Styles */
        .btn-view {
            color: #007bff;
            font-size: 14px;
            font-weight: 500;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .btn-view:hover {
            color: #0056b3;
            text-decoration: underline;
            transition: color 0.3s;
        }

        /* Focus Animation */
        input[type="text"]:focus, 
        input[type="email"]:focus, 
        input[type="number"]:focus,
        .btn-view:focus,
        .btn-custom:focus {
            transform: scale(1.05);
            transition: transform 0.3s ease-in-out;
            box-shadow: 0px 4px 12px rgba(0, 123, 255, 0.2);
            outline: none;
        }
        /* Button Focus Style */
        .btn-custom {
            background-color: #004085;
            color: #fff;
            border: none;
            padding: 10px 20px;
            font-size: 16px;
            font-weight: 500;
            border-radius: 8px;
            transition: background-color 0.3s, transform 0.3s;
            box-shadow: 0px 4px 10px rgba(0, 64, 133, 0.2);
        }
        .btn-custom:hover, .btn-custom:focus {
            background-color: #002752;
            transform: translateY(-2px);
        }
    </style>
</head>
<body>
    <div class="container">
        <h2><i class="fas fa-clipboard-list"></i> Listado de Cotizaciones y Pedidos</h2>
        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <th><i class="fas fa-hashtag"></i> ID</th>
                    <th><i class="fas fa-user"></i> Cliente</th>
                    <th><i class="fas fa-envelope"></i> Email</th>
                    <th><i class="fas fa-dollar-sign"></i> Total</th>
                    <th><i class="fas fa-calendar-alt"></i> Fecha</th>
                    <th><i class="fas fa-file-pdf"></i> Acciones</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $conexion = new mysqli($servidor, $nombre, $clave, $base);
                $result = $conexion->query("SELECT * FROM pedidos");
                while ($pedido = $result->fetch_assoc()) {
                    echo "<tr>
                        <td>{$pedido['id']}</td>
                        <td>{$pedido['cliente_nombre']}</td>
                        <td>{$pedido['cliente_email']}</td>
                        <td>S/ " . number_format($pedido['total'], 2) . "</td>
                        <td>" . date("d-m-Y", strtotime($pedido['fecha'])) . "</td>
                        <td><a href='generarpedido_pdf.php?id={$pedido['id']}' target='_blank' class='btn-view'><i class='fas fa-eye'></i> Ver PDF</a></td>
                    </tr>";
                }
                ?>
            </tbody>
        </table>
    </div>

    <script src="https://code.jquery.com/jquery-3.4.1.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>