<?php include_once "encabezado1.php"; ?>

<!DOCTYPE html>
<html lang="es">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500&display=swap" rel="stylesheet">
    <title>Formulario Registro de Gastos</title>
    <style>

                body {
            font-family: 'Poppins', sans-serif;
            color: #333;
        }

        /* Estilos del chat box */
        .chat-box {
            position: fixed;
            bottom: 0;
            right: 20px;
            width: 300px;
            background-color: #ffffff;
            border: 1px solid #ccc;
            border-radius: 8px 8px 0 0;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            display: none;
            flex-direction: column;
            z-index: 1000;
        }

        .chat-header {
            background-color: #81d4fa;
            color: #01579b;
            padding: 10px;
            border-radius: 8px 8px 0 0;
            text-align: center;
            font-weight: bold;
            cursor: pointer;
        }

        .chat-messages {
            padding: 10px;
            height: 200px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .chat-input {
            display: flex;
            border-top: 1px solid #ccc;
        }

        .chat-input input {
            flex: 1;
            padding: 10px;
            border: none;
            border-radius: 0 0 0 8px;
        }

        .chat-input button {
            padding: 10px;
            background-color: #81d4fa;
            color: #01579b;
            border: none;
            border-radius: 0 0 8px 0;
            cursor: pointer;
        }

        .chat-toggle {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #81d4fa;
            color: #01579b;
            border: none;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            cursor: pointer;
            font-size: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        /* Fondo de la página con imagen */
        body {
            font-family: 'Poppins', sans-serif;
            background: url('desk.jpg') no-repeat center center fixed;
            background-size: cover;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #333;
        }

        /* Contenedor principal con fondo semitransparente */
        .container {
            background-color: rgba(255, 255, 255, 0.85); /* Fondo blanco semitransparente */
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
            max-width: 600px;
            width: 100%;
            text-align: center;
            animation: fadeIn 1s ease-in-out;
        }

        /* Título con icono emoji */
        h2 {
            font-size: 26px;
            color: #4e4e4e;
            font-weight: 600;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        h2::before {
            content: "💸 ";
            font-size: 32px;
            margin-right: 8px;
        }

        /* Animación de aparición */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Estilos de los campos de entrada */
        .form-group input,
        .form-group select {
            background-color: rgba(255, 255, 255, 0.8); /* Fondo blanco semitransparente para inputs */
            border: 1px solid #cfd8dc;
            border-radius: 8px;
            padding: 10px;
            font-size: 14px;
            width: 100%;
            margin-bottom: 15px;
            transition: background-color 0.3s ease, box-shadow 0.3s ease;
        }

        .form-group input:focus,
        .form-group select:focus {
            background-color: rgba(255, 255, 255, 1);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
            outline: none;
            border-color: #81d4fa;
        }

        /* Botón principal */
        .btn-responsive {
            background-color: #81d4fa;
            color: #ffffff;
            font-size: 16px;
            padding: 12px 25px;
            border-radius: 8px;
            border: none;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-responsive:hover {
            background-color: #64b5f6;
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
            transform: scale(1.03);
        }

        .btn-responsive::before {
            content: "💼 ";
            font-size: 20px;
            margin-right: 8px;
        }

        /* Botones Agregar y Borrar */
        #addRow, #removeRow {
            margin-top: 10px;
            background-color: #a5d6a7;
            color: white;
            padding: 8px 15px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #addRow:hover, #removeRow:hover {
            background-color: #81c784;
        }
        
        /* Iconos en etiquetas */
        label::before {
            margin-right: 8px;
        }

        label[for="Tipo_documento"]::before {
            content: "📄";
        }

        label[for="Serie-correlativo"]::before {
            content: "🔢";
        }

        label[for="Fecha_emision"]::before {
            content: "📅";
        }

        label[for="dni_ruc"]::before {
            content: "🆔";
        }

        label[for="proveedor"]::before {
            content: "👤";
        }

        label[for="direccion"]::before {
            content: "📍";
        }
        
        label[for="producto"]::before {
            content: "📦";
        }

        label[for="Cantidad"]::before {
            content: "🔢";
        }

        label[for="sub_total"]::before {
            content: "💲";
        }

        label[for="igv"]::before {
            content: "💸";
        }

        label[for="importe_total"]::before {
            content: "💰";
        }
    </style>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>

<body>
    <div class="container" id="advanced-search-form">
        <h2>Registro de compras</h2>
        <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" name="enviarcero" method="post" autocomplete="off">
            <div class="form-group">
                <label for="Tipo_documento">Tipo documento</label>
                <select class="form-select" size="3" aria-label="size 3 select example" id="Tipo_documento" name="Tipo_documento">
                    <option>FACTURA</option>
                    <option>BOLETA</option>
                    <option>DECLARACION JURADA</option>
                </select>
            </div>
            <div class="form-group">
                <label for="Serie-correlativo">Serie-correlativo</label>
                <input type="text" class="form-control" placeholder="Serie-correlativo" id="Serie-correlativo" name="Serie-correlativo">
            </div>
            <div class="form-group">
                <label for="Fecha_emision">Fecha emision</label>
                <input type="date" class="form-control" placeholder="Fecha emision" id="Fecha_emision" name="Fecha_emision">
            </div>
            <div class="form-group">
                <label for="dni_ruc">Dni o Ruc del proveedor</label>
                <input type="text" class="form-control" placeholder="Dni o Ruc del proveedor" id="dni_ruc" name="dni_ruc">
            </div>
            <div class="form-group">
                <label for="proveedor">Nombre del proveedor</label>
                <input type="text" class="form-control" placeholder="Nombre del proveedor" id="proveedor" name="proveedor">
            </div>
            <div class="form-group">
                <label for="direccion">Direccion</label>
                <input type="text" class="form-control" placeholder="Direccion" id="direccion" name="direccion">
            </div>

            <div id="newRow"></div>
            <button id="addRow" type="button">➕ Agregar Producto/Servicio</button>

            <script type="text/javascript">
                $("#addRow").click(function () {
                    var html = '';
                    html += '<div id="inputFormRow">';
                    html += '<label for="producto">Código Producto/Servicio</label>';
                    html += '<input type="text" class="form-control" placeholder="Producto/servicio" name="producto[]">';
                    html += '<label for="Cantidad">Cantidad</label>';
                    html += '<input type="text" class="form-control" placeholder="Cantidad" name="Cantidad[]">';
                    html += '<label for="sub_total">Sub total</label>';
                    html += '<input type="text" class="form-control" placeholder="Sub total" name="sub_total[]">';
                    html += '<label for="igv">Igv</label>';
                    html += '<input type="text" class="form-control" placeholder="Igv" name="igv[]">';
                    html += '<label for="importe_total">Importe total</label>';
                    html += '<input type="text" class="form-control" placeholder="Importe total" name="importe_total[]">';
                    html += '<button id="removeRow" type="button">❌ Borrar</button>';
                    html += '</div>';
                    $('#newRow').append(html);
                });

                $(document).on('click', '#removeRow', function () {
                    $(this).closest('#inputFormRow').remove();
                });
            </script>

            <button type="submit" class="btn btn-info btn-lg btn-responsive" id="boton1">Registrar Gastos</button>
        </form>
    </div>

    <!-- Chat box -->
<div class="chat-box" id="chatBox">
    <div class="chat-header" onclick="toggleChat()">Ayuda</div>
    <div class="chat-messages" id="chatMessages">
        <p><strong>Asistente:</strong> Hola, ¿cómo puedo ayudarte?</p>
    </div>
    <div class="chat-input">
        <input type="text" id="userInput" placeholder="Escribe tu mensaje...">
        <button onclick="sendMessage()">Enviar</button>
    </div>
</div>
<button class="chat-toggle" onclick="toggleChat()">
    <i class="fas fa-comments"></i>
</button>

<script>
    function toggleChat() {
        var chatBox = document.getElementById("chatBox");
        chatBox.style.display = chatBox.style.display === "none" ? "flex" : "none";
    }

    function sendMessage() {
        var userInput = document.getElementById("userInput").value;
        var chatMessages = document.getElementById("chatMessages");

        if (userInput.trim() !== "") {
            // Añadir el mensaje del usuario
            var userMessage = document.createElement("p");
            userMessage.innerHTML = "<strong>Tú:</strong> " + userInput;
            chatMessages.appendChild(userMessage);

            // Limpiar el campo de entrada
            document.getElementById("userInput").value = "";

            // Añadir una respuesta del asistente
            var assistantMessage = document.createElement("p");
            assistantMessage.innerHTML = "<strong>Asistente:</strong> Aqui registras tus compras, detalladamente.";
            chatMessages.appendChild(assistantMessage);

            // Desplazar hacia abajo el chat
            chatMessages.scrollTop = chatMessages.scrollHeight;
        }
    }

    // Inicializar el chat box oculto
    document.addEventListener("DOMContentLoaded", function() {
        document.getElementById("chatBox").style.display = "none";
    });
</script>

</body>

</html>