<?php
session_start();
$host = 'localhost';
$db = 'trabajadores';
$username = 'root';
$password = 'root';

if (!isset($_SESSION['usuario'])) {
    header("Location: index.html");
    exit;
}

try {
    $conn = new mysqli($host, $username, $password, $db);

    if ($conn->connect_error) {
        die("Conexión fallida: " . $conn->connect_error);
    }

    $usuario = $_SESSION['usuario'];

    $sql = "SELECT NOMBRE, ROL FROM personal WHERE USUARIO = '$usuario'";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        $nombre = $row['NOMBRE'];
        $rol = $row['ROL'];

        // 👉 Agregamos la función para sacar iniciales
        function obtenerIniciales($nombreCompleto)
        {
            $partes = explode(' ', $nombreCompleto);
            $iniciales = '';

            foreach ($partes as $parte) {
                if (!empty($parte)) {
                    $iniciales .= strtoupper($parte[0]);
                }
            }
            return $iniciales;
        }

        // 👉 Ahora creamos las iniciales
        $inicialesUsuario = obtenerIniciales($nombre);
    } else {
        $nombre = "Usuario";
        $rol = "Usuario";
        $inicialesUsuario = "US"; // Algo por defecto
    }

    $conn->close();
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="es" class="layout-navbar-fixed layout-compact layout-menu-fixed" dir="ltr" data-theme="theme-default" data-assets-path="../assets/" data-template="vertical-menu-template">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
    <title>Agregar Producto</title>
    <meta name="description" content="" />
    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="../assets/img/favicon/favicon.ico" />
    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet" />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="../assets/vendor/fonts/boxicons.css" />

    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/estilosdetablas.css">
    <link rel="stylesheet" href="../css/botonesfiltros.css">
    <link rel="stylesheet" href="../css/botonexportar.css">


    <!-- Core CSS -->
    <link rel="stylesheet" href="../assets/vendor/css/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="../assets/vendor/css/theme-default.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="../assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />

    <link rel="stylesheet" href="../assets/vendor/libs/apex-charts/apex-charts.css" />

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="../assets/vendor/js/helpers.js"></script>
    <script src="../assets/js/config.js"></script>
</head>
<style>
    /* Tabla de linea */
    #pais_table_container {
        background-color: white;
        border: 1px solid #099dff;
        max-height: 200px;
        overflow-y: auto;
    }

    #pais_table_body tr {
        cursor: pointer;
    }

    #pais_table_body tr:hover {
        background-color: #f0f0f0;
    }

    /* Moneda */
    #moneda_table_container {
        background-color: white;
        border: 1px solid #099dff;
        max-height: 200px;
        overflow-y: auto;
    }

    #moneda_table_body tr {
        cursor: pointer;
    }

    #moneda_table_body tr:hover {
        background-color: #f0f0f0;
    }

    body {
        display: flex;
        min-height: 100vh;
        flex-direction: column;
    }

    .sidebar {
        flex: 0 0 250px;
    }

    .banner {
        position: fixed;
        top: 0;
        left: 250px;
        width: calc(100% - 250px);
        background-color: #fff;
        padding: 10px;
        color: white;
        z-index: 1000;
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: left 0.3s, width 0.3s;
        border-bottom: 1px solid #cbd0dd;
    }

    .content {
        flex: 1;
        padding: 20px;
        margin-left: 250px;
    }

    /*
        .container {
            max-width: 1000px;
            margin: auto;
        } */
    .collapsed {
        margin-left: 0;
    }

    .user-dropdown {
        display: none;
    }

    .user-dropdown.show {
        display: block;
    }

    /* Contenedor */
    .container {
        padding: 20px;
        width: 100%;

        display: flex;
        align-items: center;
    }

    .row {
        background-color: #fff;
        border-radius: 16px;
    }

    /* General styles for the wizard */
    .vertical-wizard {
        margin: 30px;
    }

    .vertical-wizard .bs-stepper {
        display: flex;
    }

    .vertical-wizard .nav {
        border-right: 1px solid #e4e6ef;
        width: 25%;
        /* Adjust as needed */
        justify-content: center;
    }

    .vertical-wizard .nav-item {
        border-bottom: 1px solid #e4e6ef;
    }

    .vertical-wizard .nav-link {
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        color: #6c757d;
        background: #f8f9fc;
        border-radius: 10px;
        position: relative;
        text-align: center;
        border-left: 4px solid transparent;
        transition: background-color 0.3s, border-color 0.3s;
    }

    .vertical-wizard .nav-link.active {
        background: #fff;
        color: #009dff;
        border-left-color: #009dff;
    }

    .vertical-wizard .nav-link i {
        font-size: 24px;
        margin-bottom: 10px;
        display: inline-block;
        padding: 10px;
        border-radius: 50%;
        background: #e9ecef;
        color: #7367f0;
    }

    .vertical-wizard .nav-link span {
        font-size: 14px;
        font-weight: 600;
        color: #37465A;
    }

    /* Styles for the content area */
    .tab-content {
        background: #fff;
        padding: 30px;
        /* border: 1px solid #e4e6ef; */
        border-left: none;
        border-radius: 0 6px 6px 6px;
        width: 100%;
        /* Adjust as needed */
        height: 92%;
    }

    /* Buttons */
    .btn {
        font-size: 14px;
    }

    .btn-primary:hover {
        background-color: #009DFF;
        border-color: #009DFF;
    }

    .btn-secondary {
        background-color: #009DFF;
        color: #009DFF;
        border-color: #f4f5f7;
    }

    .btn-secondary:hover {
        background-color: #009DFF;
        color: #009DFF;
        border-color: #e9ecef;
    }

    #form-proveedor {
        width: 100%;
    }

    .form-buttons {
        bottom: 0;
        left: 0;
        right: 0;
        background-color: #fff;
        /* Fondo blanco para que los botones sean visibles */
        padding: 10px;
        display: flex;
        justify-content: space-between;
    }

    .nav {
        display: flex;
        width: 100%;
    }

    /*     /* navegación de productos  */
    .nav-link {
        transition: all 0.3s ease-in-out;
    }

    */ .nav-link:hover {
        background-color: #ccc;
        color: #333;
    }

    .bs-stepper .nav-item {
        width: 100%;
        /* Asegura que no exceda el 100% del contenedor */
        text-align: center;
        /* Centra el contenido dentro de cada nav-item */
        padding: 10px;
        box-sizing: border-box;
        /* Incluye el padding en el tamaño total */
    }

    /* Estilo de los radios */
    .radio-list {
        display: flex;
        justify-content: center;
        margin-bottom: 20px;
    }

    .radio-list label {
        margin-right: 20px;
    }

    .a {
        padding: 20px;
        width: 100%;
        display: flex;
        align-items: center;
    }

    /* PRUEBA */
    /* General styles for the wizard */
    .vertical-wizard {
        margin: 30px;
    }

    .vertical-wizard .bs-stepper {
        display: flex;
    }

    .vertical-wizard .nav {
        border-right: 1px solid #e4e6ef;
        width: 25%;
        /* Adjust as needed */
        justify-content: center;
    }

    .vertical-wizard .nav-item {
        border-bottom: 1px solid #e4e6ef;
    }

    .vertical-wizard .nav-link {
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        color: #6c757d;
        background: #f8f9fc;
        border-radius: 10px;
        position: relative;
        text-align: center;
        border-left: 4px solid transparent;
        transition: background-color 0.3s, border-color 0.3s;
    }

    .vertical-wizard .nav-link.active {
        background: #fff;
        color: #009DFF;
        border-left-color: #009DFF;
    }

    .vertical-wizard .nav-link i {
        font-size: 24px;
        margin-bottom: 10px;
        display: inline-block;
        padding: 10px;
        border-radius: 50%;
        background: #e9ecef;
        color: #009DFF;
    }

    .vertical-wizard .nav-link span {
        font-size: 14px;
        font-weight: 600;
        color: #37465A;
    }

    .registros-label {
        font-size: 20px;
        font-weight: bold;
        margin-bottom: 10px;

    }

    .impuestos-label {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 10px;

    }

    .modal-dialog {
        display: flex;
        align-items: center;
        min-height: calc(100vh - 1rem);
    }

    .checkmark-container {
        width: 80px;
        height: 80px;
        display: inline-block;
        position: relative;
    }

    .checkmark {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        position: relative;
        border: 5px solid #28a745;
        box-sizing: border-box;
    }

    .checkmark::after {
        content: '';
        position: absolute;
        width: 25px;
        height: 50px;
        border: solid #28a745;
        border-width: 0 5px 5px 0;
        top: 5px;
        /* Ajuste para centrar verticalmente */
        left: 25px;
        /* Ajuste para centrar horizontalmente */
        transform: rotate(45deg);
        opacity: 0;
        transition: opacity 0.4s ease-in-out;
        /* Más lento */
    }

    .checkmark.draw::after {
        opacity: 1;
    }

    .checkmark.draw {
        animation: scale 0.6s ease-in-out forwards;
        /* Más lento */
    }

    @keyframes scale {
        0% {
            transform: scale(0);
        }

        100% {
            transform: scale(1);
        }
    }

    /* Esquemas */
    #esquemas_table_container {
        background-color: white;
        border: 1px solid #099DFF;
        max-height: 200px;
        overflow-y: auto;
    }

    #esquemas_table_body tr {
        cursor: pointer;
    }

    #esquemas_table_body tr:hover {
        background-color: #f0f0f0;
    }

    #moneda_table_container {
        background-color: white;
        border: 1px solid #099dff;
        max-height: 200px;
        overflow-y: auto;
        width: 300px;
        left: 297px;
        top: 270px;
        z-index: 1000;

    }

    #moneda_table_body tr {
        cursor: pointer;
    }

    #moneda_table_body tr:hover {
        background-color: #f0f0f0;
    }

    .table-custom th {
        background-color: #009DFF;
        /* Color de fondo azul para el encabezado */
        color: white;
        /* Color del texto blanco para el encabezado */
    }

    .col-md-12 .mt-3 {
        box-shadow: none;
        /* Sin sombra para el contenedor */
    }

    .card {
        box-shadow: none;
        /* Sin sombra para la tarjeta */
    }

    .card:hover {
        box-shadow: none;
        /* Sin sombra en hover para la tarjeta */
    }

    h1,
    .mb-4 {
        font-weight: normal;
    }

    .form-buttons .btn {
        background-color: #009DFF;
        /* Color de fondo */
        border: none;
        color: white;
        /* Color del texto */
        padding: 10px 20px;
        border-radius: 5px;
        cursor: pointer;
    }

    .form-buttons .btn:hover {
        background-color: #007BB5;
        /* Color al pasar el ratón */
    }

    h1,
    .mb-4 {
        font-weight: normal;
    }
</style>

<body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
        <div class="layout-container">
            <!-- Menu -->

            <aside id="layout-menu" class="layout-menu menu-vertical menu bg-menu-theme">
                <div class="app-brand demo">
                    <a href="index.html" class="app-brand-link">
                        <span class="app-brand-logo demo">
                            <svg
                                version="1.1"
                                xmlns="http://www.w3.org/2000/svg"
                                xmlns:xlink="http://www.w3.org/1999/xlink"
                                x="0px"
                                y="0px"
                                viewBox="0 0 2000 2000"
                                style="enable-background:new 0 0 2000 2000;"
                                xml:space="preserve"
                                width="100"
                                height="100">
                                <style type="text/css">
                                    .st0 {
                                        display: none;
                                    }

                                    .st1 {
                                        fill: #009DFF;
                                    }
                                </style>
                                <g id="Capa_1" class="st0">
                                    <image style="display:inline;overflow:visible;" width="2550" height="1558" transform="matrix(1 0 0 1 494.3726 289.1373)"></image>
                                </g>
                                <g id="Capa_2">
                                    <g>
                                        <rect x="183.89" y="18.31" class="st1" width="1632.23" height="526.02" />
                                        <polygon class="st1" points="1031.3,1629.99 1031.3,1711.86 1308.44,1711.86 1308.44,1825.3 1031.3,1825.3 1031.3,1907.13 1308.44,1907.13 1308.44,1981.69 691.56,1981.69 691.56,682.4 1308.44,682.4 1308.44,1629.99" />
                                    </g>
                                </g>
                                <g id="Capa_3" class="st0"></g>
                            </svg>
                        </span>
                        <span class="app-brand-text demo menu-text fw-bolder ms-2">Trax</span>
                    </a>

                    <a href="javascript:void(0);" class="layout-menu-toggle menu-link text-large ms-auto d-block d-xl-none">
                        <i class="bx bx-chevron-left bx-sm align-middle"></i>
                    </a>
                </div>

                <div class="menu-inner-shadow"></div>

                <ul class="menu-inner py-1">
                    <!-- Dashboard
            <li class="menu-item active">
              <a href="index.html" class="menu-link">
                <i class="menu-icon tf-icons bx bx-home-circle"></i>
                <div data-i18n="Analytics">Dashboard</div>
              </a>
            </li> -->


                    <!-- Layouts -->
                    <li class="menu-item active open ">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-layout"></i>
                            <div data-i18n="Layouts">Inicio</div>
                        </a>

                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="tablero.php" class="menu-link">
                                    <div data-i18n="Without menu">Tablero</div>
                                </a>
                            </li>
                            <!--
                            <li class="menu-item">
                                <a href="nuevo_cliente.php" class="menu-link">
                                    <div data-i18n="Without navbar">Agregar Cliente</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="nuevo_proveedor.php" class="menu-link">
                                    <div data-i18n="Container">Agregar Proveedor</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="nueva_cotizacion.php" class="menu-link">
                                    <div data-i18n="Fluid">Agregar Cotizacion</div>
                                </a>
                            </li>
                            <li class="menu-item active">
                                <a href="nuevo_producto.php" class="menu-link">
                                    <div data-i18n="Blank">Agregar Producto</div>
                                </a>
                            </li>

                            <li class="menu-item">
                                <a href="nueva_compra.php" class="menu-link">
                                    <div data-i18n="Blank">Agregar Compra</div>
                                </a>
                            </li>

                            <li class="menu-item">
                                <a href="nueva_factura.php" class="menu-link">
                                    <div data-i18n="Blank">Agregar Factura</div>
                                </a>
                            </li>
                                -->
                        </ul>
                    </li>

                    <li class="menu-header small text-uppercase">
                        <span class="menu-header-text">Aspel SAE</span>
                    </li>
                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-line-chart"></i>
                            <div data-i18n="Account Settings">Ventas</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="facturas.php" class="menu-link">
                                    <div data-i18n="Account">Facturas</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="notasdeventa.php" class="menu-link">
                                    <div data-i18n="Notifications">Notas de Venta</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="trasladoscartaporte.php" class="menu-link">
                                    <div data-i18n="Connections">Carta Porte</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="remisiones.php" class="menu-link">
                                    <div data-i18n="Connections">Remisiones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="pedidos.php" class="menu-link">
                                    <div data-i18n="Connections">Pedidos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="cotizaciones.php" class="menu-link">
                                    <div data-i18n="Connections">Cotizaciones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="devoluciones.php" class="menu-link">
                                    <div data-i18n="Connections">Devoluciones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="notasdecredito.php" class="menu-link">
                                    <div data-i18n="Connections">Notas de Crédito</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="parcialidades.php" class="menu-link">
                                    <div data-i18n="Connections">Parcialidades</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="comprobantesdepago.php" class="menu-link">
                                    <div data-i18n="Connections">Comprobantes</div>
                                </a>
                            <li class="menu-item">
                                <a href="estadisticas.php" class="menu-link">
                                    <div data-i18n="Connections">Estadisticas</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="estadisticascli.php" class="menu-link">
                                    <div data-i18n="Connections">Ventas X Cliente</div>
                                </a>
                            </li>
                        </ul>
                    </li>

                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-user"></i>
                            <div data-i18n="Authentications">Clientes</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="clientes.php" class="menu-link">
                                    <div data-i18n="Basic">Clientes</div>
                                </a>
                            </li>
                            <li class="menu-item ">
                                <a href="correos.php" class="menu-link">
                                    <div data-i18n="Basic">Correos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="cuentasxcobrar.php" class="menu-link">
                                    <div data-i18n="Basic">Cuentas X Cobrar</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="clientespoliza.php" class="menu-link">
                                    <div data-i18n="Basic">Clientes con Póliza</div>
                                </a>

                            <li class="menu-item">
                                <a href="clientestimbres.php" class="menu-link">
                                    <div data-i18n="ClientStamps">Clientes Timbres</div>
                                </a>
                            </li>

                            <li class="menu-item">
                                <a href="clientesistemas.php" class="menu-link">
                                    <div data-i18n="ClientSystems">Clientes Sistemas</div>
                                </a>
                            </li>
                        </ul>
                    </li>

                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-package"></i>
                            <div data-i18n="Misc">Inventarios</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="productos.php" class="menu-link">
                                    <div data-i18n="Error">Productos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="existencias.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Existencias</div>
                                </a>
                            </li>
                        </ul>
                    </li>


                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-shopping-bag"></i>
                            <div data-i18n="Misc">Compras</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="compras.php" class="menu-link">
                                    <div data-i18n="Error">Compras</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="recepciones.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Recepciones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="ordenes.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Ordenes</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="requisiciones.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Requisiciones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="devoluciones.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Devoluciones</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="estadisticasprove.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Compras X Proveedor</div>
                                </a>
                            </li>
                        </ul>
                    </li>


                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-group"></i>
                            <div data-i18n="Misc">Proveedores</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="proveedores.php" class="menu-link">
                                    <div data-i18n="Error">Proveedores</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="cuentasxpagar.php" class="menu-link">
                                    <div data-i18n="Under Maintenance">Cuentas X Pagar</div>
                                </a>
                            </li>
                        </ul>
                    </li>


                    <!-- Aspel COI -->
                    <li class="menu-header small text-uppercase"><span class="menu-header-text">Aspel COI</span></li>

                    <!-- Extended components -->
                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-copy"></i>
                            <div data-i18n="Extended UI">Cuentas y Pólizas</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item">
                                <a href="cuentas.php" class="menu-link">
                                    <div data-i18n="Perfect Scrollbar">Cuentas</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="polizas.php" class="menu-link">
                                    <div data-i18n="Text Divider">Pólizas</div>
                                </a>
                            </li>
                            <li class="menu-item ">
                                <a href="activos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Activos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="auxiliares.php" class="menu-link">
                                    <div data-i18n="Text Divider">Auxiliares</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="presupuestos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Presupuestos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="presupuestosPD.php" class="menu-link">
                                    <div data-i18n="Text Divider">Presupuestos DP</div>
                                </a>
                            </li>
                            <li class="menu-item ">
                                <a href="monedas.php" class="menu-link">
                                    <div data-i18n="Text Divider">Monedas</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="departamentos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Departamentos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="otrosimpuestos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Otros Impuestos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="activosgenerales.php" class="menu-link">
                                    <div data-i18n="Text Divider">Activos Generales</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="saldos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Saldos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="saldosDP.php" class="menu-link">
                                    <div data-i18n="Text Divider">Saldos DP</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="rubros.php" class="menu-link">
                                    <div data-i18n="Text Divider">Rubros</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="ccostos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Centro de Costos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="concepto.php" class="menu-link">
                                    <div data-i18n="Text Divider">Conceptos</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="regpol.php" class="menu-link">
                                    <div data-i18n="Text Divider">Registro de Pólizas</div>
                                </a>
                            </li>
                            <li class="menu-item">
                                <a href="impuestos.php" class="menu-link">
                                    <div data-i18n="Text Divider">Impuestos</div>
                                </a>
                            </li>
                            <li class="menu-item ">
                                <a href="timbres.php" class="menu-link">
                                    <div data-i18n="Text Divider">Timbres</div>
                                </a>
                            </li>
                        </ul>
                    </li>

                    <!-- Aspel BANCO -->
                    <li class="menu-header small text-uppercase"><span class="menu-header-text">Aspel BANCO</span></li>
                    <!-- Forms -->
                    <li class="menu-item">
                        <a href="#" class="menu-link menu-toggle">
                            <i class="menu-icon tf-icons bx bx-credit-card"></i>
                            <div data-i18n="Form Elements">Movimientos</div>
                        </a>
                        <ul class="menu-sub">
                            <li class="menu-item ">
                                <a href="movimientos.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Movimientos</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="moneda.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Moneda</div>
                                </a>

                            </li>
                            <li class="menu-item ">
                                <a href="beneficiosxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Beneficios</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="cuentasxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Cuentas ban</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="formadepagoxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Forma de pago</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="parametrosxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Partidas de movimientos</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="comprobantedeldocumentoxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Comprobante del documento</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="centrodecuentasxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Conceptos de movimientos</div>
                                </a>

                            </li>
                            <li class="menu-item">
                                <a href="historialxban.php" class="menu-link">
                                    <div data-i18n="Basic Inputs">Historial</div>
                                </a>

                            </li>
                        </ul>
                    </li>
                </ul>
            </aside>
            <!-- / Menu -->

            <!-- Layout container -->
            <div class="layout-page">
                <!-- Navbar -->
                <nav class="layout-navbar container-xxl navbar-detached navbar navbar-expand-xl align-items-center bg-navbar-theme" id="layout-navbar">
                    <div class="layout-menu-toggle navbar-nav align-items-xl-center me-3 me-xl-0 d-xl-none">
                        <a class="nav-item nav-link px-0 me-xl-4" href="javascript:void(0)">
                            <i class="bx bx-menu bx-sm"></i>
                        </a>
                    </div>

                    <div class="navbar-nav-right d-flex align-items-center" id="navbar-collapse">
                        <!-- Search -->
                        <div class="navbar-nav align-items-center">
                            <div class="nav-item d-flex align-items-center">
                                <i class="bx bx-search fs-4 lh-0"></i>
                                <input
                                    type="text"
                                    class="form-control border-0 shadow-none"
                                    placeholder="Buscar..."
                                    data-bs-toggle="modal"
                                    data-bs-target="#modalBusqueda" />

                                <!-- Resultados -->
                                <ul id="searchResults" class="list-group search-dropdown"></ul>
                            </div>
                        </div>
                        <style>
                            /* Estilos para el desplegable */
                            .search-dropdown {
                                position: absolute;
                                top: 100%;
                                left: 0;
                                right: 0;
                                z-index: 9999;
                                margin-top: 0.2rem;
                                background: white;
                                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
                                border-radius: 0.25rem;
                                overflow-y: auto;
                                max-height: 300px;
                            }

                            .search-dropdown li {
                                cursor: pointer;
                            }

                            .search-dropdown li:hover {
                                background-color: #f0f0f0;
                            }
                        </style>

                        <!-- /Search -->

                        <ul class="navbar-nav flex-row align-items-center ms-auto">



                            <!-- icono de idioma  -->
                            <li class="nav-item dropdown-language dropdown me-2 me-xl-0">
                                <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown" aria-expanded="false">
                                    <i class="icon-base bx bx-globe icon-md"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-end" data-bs-popper="static">
                                    <li>
                                        <a class="dropdown-item active" href="javascript:void(0);" data-language="en" data-text-direction="ltr">
                                            <span>English</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a class="dropdown-item" href="javascript:void(0);" data-language="fr" data-text-direction="ltr">
                                            <span>French</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a class="dropdown-item" href="javascript:void(0);" data-language="ar" data-text-direction="rtl">
                                            <span>Arabic</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a class="dropdown-item" href="javascript:void(0);" data-language="de" data-text-direction="ltr">
                                            <span>German</span>
                                        </a>
                                    </li>
                                </ul>
                            </li>


                            <!-- Icono de modo oscuro -->
                            <li class="nav-item dropdown me-2 me-xl-0">
                                <a class="nav-link dropdown-toggle hide-arrow" id="nav-theme" href="javascript:void(0);" data-bs-toggle="dropdown" aria-label="Toggle theme (light)">
                                    <i class="bx-sun icon-base bx icon-md theme-icon-active"></i>
                                    <span class="d-none ms-2" id="nav-theme-text">Toggle theme</span>
                                </a>


                                <!-- Submenu de modo oscuro -->
                                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="nav-theme-text" data-bs-popper="static">
                                    <li>
                                        <button type="button" class="dropdown-item align-items-center active" data-bs-theme-value="light" aria-pressed="true">
                                            <span>
                                                <i class="icon-base bx bx-sun icon-md me-3" data-icon="sun"></i>Claro
                                            </span>
                                        </button>
                                    </li>

                                    <li>
                                        <button type="button" class="dropdown-item align-items-center" data-bs-theme-value="dark" aria-pressed="false">
                                            <span>
                                                <i class="icon-base bx bx-moon icon-md me-3" data-icon="moon"></i>Oscuro
                                            </span>
                                        </button>
                                    </li>

                                    <li>
                                        <button type="button" class="dropdown-item align-items-center" data-bs-theme-value="system" aria-pressed="false">
                                            <span>
                                                <i class="icon-base bx bx-desktop icon-md me-3" data-icon="desktop"></i>Dispositivo
                                            </span>
                                        </button>
                                    </li>

                                </ul>

                                <!-- Aquí termina submenu -->
                            </li>


                            <li class="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0">
                                <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
                                    <i class="icon-base bx bx-grid-alt icon-md"></i>
                                </a>
                                <!-- submenu -->
                                <div class="dropdown-menu dropdown-menu-end p-0">
                                    <div class="dropdown-menu-header border-bottom">
                                        <div class="dropdown-header d-flex align-items-center py-3">
                                            <h6 class="mb-0 me-auto">Shortcuts</h6>
                                            <a href="javascript:void(0)" class="dropdown-shortcuts-add py-2" data-bs-toggle="tooltip" data-bs-placement="top" aria-label="Add shortcuts" data-bs-original-title="Add shortcuts"><i class="icon-base bx bx-plus-circle text-heading"></i></a>
                                        </div>
                                    </div>
                                    <div class="dropdown-shortcuts-list scrollable-container ps">
                                        <div class="row row-bordered overflow-visible g-0">
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-calendar icon-26px text-heading"></i>
                                                </span>
                                                <a href="app-calendar.html" class="stretched-link">Calendar</a>
                                                <small>Appointments</small>
                                            </div>
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-food-menu icon-26px text-heading"></i>
                                                </span>
                                                <a href="app-invoice-list.html" class="stretched-link">Invoice App</a>
                                                <small>Manage Accounts</small>
                                            </div>
                                        </div>
                                        <div class="row row-bordered overflow-visible g-0">
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-user icon-26px text-heading"></i>
                                                </span>
                                                <a href="app-user-list.html" class="stretched-link">User App</a>
                                                <small>Manage Users</small>
                                            </div>
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-check-shield icon-26px text-heading"></i>
                                                </span>
                                                <a href="app-access-roles.html" class="stretched-link">Role Management</a>
                                                <small>Permission</small>
                                            </div>
                                        </div>
                                        <div class="row row-bordered overflow-visible g-0">
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-pie-chart-alt-2 icon-26px text-heading"></i>
                                                </span>
                                                <a href="index.html" class="stretched-link">Dashboard</a>
                                                <small>User Dashboard</small>
                                            </div>
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-cog icon-26px text-heading"></i>
                                                </span>
                                                <a href="pages-account-settings-account.html" class="stretched-link">Setting</a>
                                                <small>Account Settings</small>
                                            </div>
                                        </div>
                                        <div class="row row-bordered overflow-visible g-0">
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-help-circle icon-26px text-heading"></i>
                                                </span>
                                                <a href="pages-faq.html" class="stretched-link">FAQs</a>
                                                <small>FAQs &amp; Articles</small>
                                            </div>
                                            <div class="dropdown-shortcuts-item col">
                                                <span class="dropdown-shortcuts-icon rounded-circle mb-3">
                                                    <i class="icon-base bx bx-window-open icon-26px text-heading"></i>
                                                </span>
                                                <a href="modal-examples.html" class="stretched-link">Modals</a>
                                                <small>Useful Popups</small>
                                            </div>
                                        </div>
                                        <div class="ps__rail-x" style="left: 0px; bottom: 0px;">
                                            <div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
                                        </div>
                                        <div class="ps__rail-y" style="top: 0px; right: 0px;">
                                            <div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 0px;"></div>
                                        </div>
                                    </div>
                                </div>
                                <!-- aqui termina submenu -->

                            </li>

                            <li class="nav-item dropdown-notifications navbar-dropdown dropdown me-3 me-xl-2">
                                <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
                                    <span class="position-relative">
                                        <i class="icon-base bx bx-bell icon-md"></i>
                                        <span class="badge rounded-pill bg-danger badge-dot badge-notifications border"></span>
                                    </span>
                                </a>

                                <!--empiezan las notificaciones -->
                                <ul class="dropdown-menu dropdown-menu-end p-0">
                                    <li class="dropdown-menu-header border-bottom">
                                        <div class="dropdown-header d-flex align-items-center py-3">
                                            <h6 class="mb-0 me-auto">Notification</h6>
                                            <div class="d-flex align-items-center h6 mb-0">
                                                <span class="badge bg-label-primary me-2">8 New</span>
                                                <a href="javascript:void(0)" class="dropdown-notifications-all p-2" data-bs-toggle="tooltip" data-bs-placement="top" aria-label="Mark all as read" data-bs-original-title="Mark all as read"><i class="icon-base bx bx-envelope-open text-heading"></i></a>
                                            </div>
                                        </div>
                                    </li>


                                    <li class="dropdown-notifications-list scrollable-container ps">
                                        <ul class="list-group list-group-flush">
                                            <li class="list-group-item list-group-item-action dropdown-notifications-item">
                                                <div class="d-flex">
                                                    <div class="flex-shrink-0 me-3">
                                                        <div class="avatar">
                                                            <img src="../../assets/img/avatars/1.png" alt="" class="rounded-circle">
                                                        </div>
                                                    </div>
                                                    <div class="flex-grow-1">
                                                        <h6 class="small mb-0">Congratulation Lettie 🎉</h6>
                                                        <small class="mb-1 d-block text-body">Won the monthly best seller gold badge</small>
                                                        <small class="text-body-secondary">1h ago</small>
                                                    </div>
                                                    <div class="flex-shrink-0 dropdown-notifications-actions">
                                                        <a href="javascript:void(0)" class="dropdown-notifications-read"><span class="badge badge-dot"></span></a>
                                                        <a href="javascript:void(0)" class="dropdown-notifications-archive"><span class="icon-base bx bx-x"></span></a>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="list-group-item list-group-item-action dropdown-notifications-item">
                                                <div class="d-flex">
                                                    <div class="flex-shrink-0 me-3">
                                                        <div class="avatar">
                                                            <span class="avatar-initial rounded-circle bg-label-danger">CF</span>
                                                        </div>
                                                    </div>
                                                    <div class="flex-grow-1">
                                                        <h6 class="small mb-0">Charles Franklin</h6>
                                                        <small class="mb-1 d-block text-body">Accepted your connection</small>
                                                        <small class="text-body-secondary">12hr ago</small>
                                                    </div>
                                                    <div class="flex-shrink-0 dropdown-notifications-actions">
                                                        <a href="javascript:void(0)" class="dropdown-notifications-read"><span class="badge badge-dot"></span></a>
                                                        <a href="javascript:void(0)" class="dropdown-notifications-archive"><span class="icon-base bx bx-x"></span></a>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="list-group-item list-group-item-action dropdown-notifications-item marked-as-read">
                                                <div class="d-flex">
                                                    <div class="flex-shrink-0 me-3">
                                                        <div class="avatar">
                                                            <img src="../../assets/img/avatars/2.png" alt="" class="rounded-circle">
                                                        </div>
                                                    </div>
                                                    <div class="flex-grow-1">
                                                        <h6 class="small mb-0">New Message ✉️</h6>
                                                        <small class="mb-1 d-block text-body">You have new message from Natalie</small>
                                                        <small class="text-body-secondary">1h ago</small>
                                                    </div>
                                                    <div class="flex-shrink-0 dropdown-notifications-actions">
                                                        <a href="javascript:void(0)" class="dropdown-notifications-read"><span class="badge badge-dot"></span></a>
                                                        <a href="javascript:void(0)" class="dropdown-notifications-archive"><span class="icon-base bx bx-x"></span></a>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>

                                        <div class="ps__rail-x" style="left: 0px; bottom: 0px;">
                                            <div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
                                        </div>
                                        <div class="ps__rail-y" style="top: 0px; right: 0px;">
                                            <div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 0px;"></div>
                                        </div>
                                    </li>

                                    <li class="border-top">
                                        <div class="d-grid p-4">
                                            <a class="btn btn-primary btn-sm d-flex" href="javascript:void(0);">
                                                <small class="align-middle">View all notifications</small>
                                            </a>
                                        </div>
                                    </li>
                                </ul> <!-- termina submenu de notificaciones -->
                            </li>




                            <!-- User -->
                            <li class="nav-item navbar-dropdown dropdown-user dropdown">
                                <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown">
                                    <div class="avatar avatar-online">
                                        <span class="avatar-initial rounded-circle bg-label-primary"><?php echo htmlspecialchars($inicialesUsuario); ?></span>
                                    </div>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-end">
                                    <li>
                                        <a class="dropdown-item" href="#">
                                            <div class="d-flex">
                                                <div class="flex-shrink-0 me-3">
                                                    <div class="avatar avatar-online">
                                                        <span class="avatar-initial rounded-circle bg-label-primary"><?php echo htmlspecialchars($inicialesUsuario); ?></span>
                                                    </div>
                                                </div>
                                                <div class="flex-grow-1">
                                                    <span class="fw-semibold d-block"><?php echo htmlspecialchars($nombre); ?></span>
                                                    <small class="text-muted"><?php echo htmlspecialchars($rol); ?></small>
                                                </div>
                                            </div>
                                        </a>
                                    </li>
                                    <li>
                                        <div class="dropdown-divider"></div>
                                    </li>
                                    <li>
                                        <a class="dropdown-item" href="index.html">
                                            <i class="bx bx-power-off me-2"></i>
                                            <span class="align-middle">Cerrar Sesión</span>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <!--/ User -->
                        </ul>
                    </div>
                </nav>
                <!-- / Navbar -->



                <h1 style="font-size: 36px; margin-top: 20px; color: #37465A; font-weight: bold;" class="mb-2 mt-4 text-center">Nuevo Producto</h1>
                <div class="container mt-5">
                    <div class="row">
                        <div class="col-md-12">
                            <!-- Form Wizard with Vertical Icons -->
                            <section class="vertical-wizard">
                                <div class="bs-stepper">
                                    <div class="nav">
                                        <!-- Step 1 -->
                                        <div class="nav-item">
                                            <a class="nav-link active" href="#datos-generales">
                                                <i class="bx bx-user"></i>
                                                <span>Datos Generales</span>
                                            </a>
                                        </div>
                                        <!-- Step 2 -->
                                        <div class="nav-item">
                                            <a class="nav-link" href="#precios-control">
                                                <i class="bx bx-cart"></i>
                                                <span>Precios y control</span>
                                            </a>
                                        </div>
                                        <!-- Step 3 -->
                                        <div class="nav-item">
                                            <a class="nav-link" href="#impuestos">
                                                <i class="bx bx-history"></i>
                                                <span>Impuestos</span>
                                            </a>
                                        </div>
                                        <!-- Step 4 -->
                                        <div class="nav-item">
                                            <a class="nav-link" href="#registro-acumulados">
                                                <i class="bx bx-info-circle"></i>
                                                <span>Registros y acumulados</span>
                                            </a>
                                        </div>
                                        <!-- Step 5 -->
                                        <div class="nav-item">
                                            <a class="nav-link" href="#datos-adicionales">
                                                <i class="bx bx-file"></i>
                                                <span>Datos adicionales</span>
                                            </a>
                                        </div>
                                        <!-- Step 6 -->
                                        <div class="nav-item">
                                            <a class="nav-link" href="#fiscales">
                                                <i class="bx bx-briefcase"></i>
                                                <span>Fiscales</span>
                                            </a>
                                        </div>
                                    </div>

                                    <!-- Form Content -->
                                    <form id="form-proveedor" action="leer_producto.php" method="POST">
                                        <div class="tab-content ">
                                            <div id="datos-generales" class="tab-pane fade show active">
                                                <div class="container">
                                                    <div class="form-row">
                                                        <div class="form-group col-md-8">
                                                            <label for="clave">Clave:</label>
                                                            <input type="text" class="form-control" id="clave" name="clave"
                                                                placeholder="Clave">
                                                        </div>

                                                        <div class="form-group col-md-4 mt-md-4">
                                                            <!-- Boton de DOCTOS tiene el estilo inclido -->
                                                            <button type="button" class="btn btn-info btn-sm"
                                                                style="background-color: #009DFF; color: #ffff;"
                                                                onclick="alert('Asociar documentos')">
                                                                <i class="fas fa-file-alt"></i> Asociar Doctos
                                                            </button>
                                                        </div>

                                                        <div class="col-md-8">
                                                            <div class="form-group">
                                                                <label for="clave_alterna">Clave Alterna:</label>
                                                                <input type="text" class="form-control" id="clave_alterna" name="clave_alterna"
                                                                    placeholder="Clave Alterna">
                                                            </div>
                                                        </div>

                                                        <div class="col-md-4 mt-md-4">
                                                            <!-- Boton de CLAVE ALTERNA tiene el estilo inclido -->
                                                            <div class="form-group">
                                                                <button type="button" class="btn btn-sm"
                                                                    style="background-color: #009DFF; color: #ffff;"
                                                                    onclick="alert('Claves Alternas')">
                                                                    <i class="fas fa-key"></i> Claves Alternas
                                                                </button>
                                                            </div>
                                                        </div>

                                                        <div class="col-md-6">
                                                            <div class="form-group">
                                                                <label for="descripcion">Descripción:</label>
                                                                <textarea id="descripcion" class="form-control"
                                                                    placeholder="Descripción" name="descripcion" rows="1"></textarea>
                                                            </div>
                                                        </div>

                                                        <div class="col-md-6">
                                                            <div class="form-group">
                                                                <label for="imagen">Añadir Imagen:</label>
                                                                <input type="file" class="form-control" id="imagen"
                                                                    name="imagen">
                                                            </div>
                                                        </div>
                                                        <!-- Segunda parte (datos generales) -->
                                                        <div class="col-md-12">
                                                            <div class="font-bold border-b border-gray-400 pb-2">
                                                                <h5>Datos Históticos</h5>
                                                            </div>
                                                        </div>
                                                        <div style="background-color: #ffffff; padding: 30px; border-radius: 10px;">
                                                            <label style="margin-right: 80px;">
                                                                <input type="radio" name="tipo_producto" value="P" checked>
                                                                Producto
                                                            </label>
                                                            <label style="margin-right: 80px;">
                                                                <input type="radio" name="tipo_producto" value="S">
                                                                Servicio
                                                            </label>
                                                            <label style="margin-right: 80px;">
                                                                <input type="radio" name="tipo_producto" value="K">
                                                                Kit
                                                            </label>
                                                            <label style="margin-right: 70px;">
                                                                <input type="radio" name="tipo_producto" value="G">
                                                                Grupo de producto
                                                            </label>
                                                        </div>
                                                        <!-- Contenedor de la Tabla de Lineas -->
                                                        <div class="row">
                                                            <class="col-md-3">
                                                                <div class="form-group">
                                                                    <label for="cve_pais">Linea</label>
                                                                    <div class="input-group">
                                                                        <input type="text" class="form-control" id="cve_pais" name="cve_pais" placeholder="Linea" readonly>
                                                                        <div class="input-group-append">
                                                                            <span class="input-group-text" style="background-color: #009dff; color: #fff; cursor: pointer;" id="pais-dropdown">
                                                                                <i class="fas fa-chevron-down"></i>
                                                                            </span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                        </div>

                                                        <div id="pais_table_container" class="position-absolute" style="display:none; z-index: 1000; width: 300px;">
                                                            <table class="table table-bordered table-striped">
                                                                <thead>
                                                                    <tr>
                                                                        <th>Linea</th>
                                                                        <th>Descripción</th>
                                                                        <th>Cuenta Contable</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody id="pais_table_body">
                                                                    <?php
                                                                    // Conexión a la base de datos Firebird
                                                                    session_start();
                                                                    $host = 'localhost';
                                                                    $database = 'C:\Program Files (x86)\Common Files\Aspel\Sistemas Aspel\SAE7.00\Ejemplos\Ejemplos.fdb';
                                                                    $username = 'SYSDBA';
                                                                    $password = 'masterkey';

                                                                    try {
                                                                        $dbh = new PDO("firebird:host=$host;dbname=$database;charset=UTF8", $username, $password);
                                                                        $query = "SELECT CVE_LIN, DESC_LIN, CUENTA_COI FROM CLIN01";
                                                                        $stmt = $dbh->prepare($query);
                                                                        $stmt->execute();

                                                                        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                                            echo "<tr class='pais-row' data-cve-pais='" . $row['CVE_LIN'] . "' data-descr='" . $row['DESC_LIN'] . "'>";
                                                                            echo "<td>" . $row['CVE_LIN'] . "</td>";
                                                                            echo "<td>" . $row['DESC_LIN'] . "</td>";
                                                                            echo "<td>" . $row['CUENTA_COI'] . "</td>";
                                                                            echo "</tr>";
                                                                        }
                                                                    } catch (PDOException $e) {
                                                                        echo "Error: " . $e->getMessage();
                                                                    }
                                                                    ?>
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="tiempo_surt">Tiempo de surtido:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Tiempo de surtido" id="tiempo_surt"
                                                                    name="tiempo_surt">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="control_alm">Control de Almacen:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Control de Almacen" id="control_alm"
                                                                    name="control_alm">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="volumen">Volumen:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="¿Cual es Volumen?" id="volumen"
                                                                    name="volumen">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="peso">Peso:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="¿Cual es Peso?" id="peso"
                                                                    name="peso">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="uni_entrada">Unidad de entrada:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Unidad de entrad" id="uni_entrada"
                                                                    name="uni_entrada">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="uni_salida">Unidad de salida:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Unidad de salida" id="uni_salida"
                                                                    name="uni_salida">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="fac_unidades">Factor entre unidades:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Factor" id="fac_unidades" name="fac_unidades">
                                                            </div>
                                                        </div>
                                                        <div class="col-md-4">
                                                            <div class="form-group">
                                                                <label for="uni_empaque">Unidad de empaque:</label>
                                                                <input type="text" class="form-control"
                                                                    placeholder="Unidad de empaque" id="uni_empaque"
                                                                    name="uni_empaque">
                                                            </div>
                                                        </div>
                                                        <div style="background-color: #ffffff; padding: 10px; border-radius: 5px;">
                                                            <label style="margin-right: 110px;">
                                                                <input type="checkbox" name="con_serie" value="S"> Números de serie
                                                                <span style="color: #666; cursor: help;" title="Más información sobre números de serie">&#x2754;</span>
                                                            </label>
                                                            <label style="margin-right: 140px;">
                                                                <input type="checkbox" name="con_lote" value="S"> Lotes
                                                                <span style="color: #666; cursor: help;" title="Más información sobre lotes">&#x2754;</span>
                                                            </label>
                                                            <label style="margin-right: 10px;">
                                                                <input type="checkbox" name="con_pedimento" value="S"> Pedimentos aduanales
                                                                <span style="color: #666; cursor: help;" title="Más información sobre pedimentos aduanales">&#x2754;</span>
                                                            </label>
                                                        </div>

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

                                            <!-- Step 2 Content (Datos de Compras) -->
                                            <div id="precios-control" class="tab-pane fade">
                                                <div class="p-4 rounded-lg  flex space-x-4">
                                                    <!-- Precios Section -->
                                                    <div class="p-4 rounded-lg">
                                                        <div class="mb-4">
                                                            <h2 class="font-bold border-b border-gray-400 pb-2">Precios</h2>
                                                            <div class="form-group flex items-center space-x-2 mt-2">
                                                                <label class="w-32" style="color: #37465A; font-weight: normal;">Precio público</label>
                                                                <input type="text" class="form-control border rounded p-1 w-32"
                                                                    value="0.000000" name="precio_pub">
                                                                <button
                                                                    class="px-2 py-1 rounded border"
                                                                    style="background-color: #009DFF; color: white; display: flex; align-items: center; ">
                                                                    <i class="fas fa-tag"></i>
                                                                    <span>Precios</span>
                                                                </button>

                                                            </div>
                                                            <div class="form-group flex items-center space-x-2 mt-2">
                                                                <div class="row">
                                                                    <class="col-md-3">
                                                                        <div class="form-group">
                                                                            <label class="w-32" style="color: #37465A; font-weight: normal;" for="NUMMONED">Moneda</label>
                                                                            <div class="input-group">
                                                                                <input type="text" class="form-control"
                                                                                    id="NUMMONED" name="NUMMONED"
                                                                                    placeholder="Moneda" readonly>
                                                                                <div class="input-group-append">
                                                                                    <span class="input-group-text"
                                                                                        style="background-color: #009dff; color: #fff; cursor: pointer;"
                                                                                        id="moneda-dropdown">
                                                                                        <i class="fas fa-chevron-down"></i>
                                                                                    </span>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                </div>
                                                                <div id="moneda_table_container" class="position-absolute"
                                                                    style="display:none; z-index: 1000; width: 300px;">
                                                                    <table class="table table-bordered table-striped">
                                                                        <thead>
                                                                            <tr>
                                                                                <th>Moneda</th>
                                                                                <th>Descripción</th>
                                                                            </tr>
                                                                        </thead>
                                                                        <tbody id="moneda_table_body">
                                                                            <?php
                                                                            // Conexión a la base de datos Firebird
                                                                            session_start();
                                                                            $host = 'localhost';
                                                                            $database = 'C:\Program Files (x86)\Common Files\Aspel\Sistemas Aspel\SAE7.00\Ejemplos\Ejemplos.fdb';
                                                                            $username = 'SYSDBA';
                                                                            $password = 'masterkey';

                                                                            try {
                                                                                $dbh = new PDO("firebird:host=$host;dbname=$database;charset=UTF8", $username, $password);
                                                                                $query = "SELECT CVE_MONED, DESCR FROM MONED01";
                                                                                $stmt = $dbh->prepare($query);
                                                                                $stmt->execute();

                                                                                while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                                                    echo "<tr class='moneda-row' data-NUMMONED='" . $row['CVE_MONED'] . "' data-descr='" . $row['DESCR'] . "'>";
                                                                                    echo "<td>" . $row['CVE_MONED'] . "</td>";
                                                                                    echo "<td>" . $row['DESCR'] . "</td>";
                                                                                    echo "</tr>";
                                                                                }
                                                                            } catch (PDOException $e) {
                                                                                echo "Error: " . $e->getMessage();
                                                                            }
                                                                            ?>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mb-4">
                                                            <label style="color: #37465A; font-weight: normal;">Cuenta contable</label>
                                                            <input type="text" placeholder="Cuenta Contable"
                                                                class="form-control border rounded p-1 w-full mt-2" name="cuen_contable">
                                                        </div>
                                                        <div class="mb-4">
                                                            <h2 class="font-bold border-b border-gray-400 pb-2">Costeo</h2>
                                                            <div class="form-group flex flex-col mt-2">
                                                                <label class="flex items-center">
                                                                    <input type="radio" name="tipo_costeo" value="U"> UEPS
                                                                </label>
                                                                <label class="flex items-center">
                                                                    <input type="radio" name="tipo_costeo" value="E"> PEPS
                                                                </label>
                                                                <label class="flex items-center">
                                                                    <input type="radio" name="tipo_costeo" value="P"> Promedio
                                                                </label>
                                                                <label class="flex items-center">
                                                                    <input type="radio" name="tipo_costeo" value="S"> Estándar
                                                                </label>
                                                                <label class="flex items-center">
                                                                    <input type="radio" name="tipo_costeo" value="I"> Identificado
                                                                </label>
                                                            </div>
                                                        </div>


                                                        <div>
                                                            <h2 class="font-bold border-b border-gray-400 pb-2">Proveedores
                                                            </h2>
                                                            <div class="form-group flex items-center space-x-2 mt-10">
                                                                <label class="w-32">Proveedor</label>
                                                                <input type="text" placeholder="¿Quien es el Proveedor?"
                                                                    class="form-control border rounded p-1 w-full">
                                                            </div>
                                                            <button
                                                                class="px-2 py-1 rounded border flex items-center mt-2"
                                                                style="background-color: #009DFF; color: white;">
                                                                <i class="fas fa-truck"></i>
                                                                <span>Proveedores</span>
                                                            </button>

                                                        </div>
                                                    </div>


                                                    <!-- Cantidades Section -->
                                                    <div class="p-4 rounded-lg">
                                                        <h2 class="font-bold border-b border-gray-400 pb-2">Cantidades</h2>
                                                        <div class="form-group flex items-center space-x-2 mt-2">
                                                            <label class="w-32">Existencia</label>
                                                            <input type="text" class="form-control border rounded p-2 w-16"
                                                                placeholder="0" name="existencia">
                                                            <i class="fas fa-calendar-alt"></i>
                                                        </div>
                                                        <div class="form-group flex items-center space-x-2 mt-2">
                                                            <label class="w-32">Stock mín.</label>
                                                            <input type="text" class="form-control border rounded p-2 w-16"
                                                                placeholder="0" name="stock_min">
                                                            <i class="fas fa-calendar-alt"></i>
                                                        </div>
                                                        <div class="form-group flex items-center space-x-2 mt-2">
                                                            <label class="w-32">Stock máx.</label>
                                                            <input type="text" class="form-control border rounded p-2 w-16"
                                                                placeholder="0" name="stock_max">
                                                            <i class="fas fa-calendar-alt"></i>
                                                        </div>
                                                        <div class="form-group flex items-center space-x-2 mt-2">
                                                            <label class="w-32">Apartado</label>
                                                            <input type="text" class="form-control border rounded p-2 w-16"
                                                                placeholder="0" name="apart">
                                                            <i class="fas fa-calendar-alt"></i>
                                                        </div>
                                                        <button class="px-2 py-1 rounded border" style="background-color: #009DFF; color: white;" class="flex items-center space-x-1 mt-2">
                                                            <i class="fas fa-warehouse"></i>
                                                            <span>Almacenes</span>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>

                                            <!-- Inicia (Formulario de Impuestos) -->
                                            <div id="datos-historicos" class="tab-pane fade">
                                                <div class="container-fluid">
                                                    <div class="row mb-3">
                                                        <div class="col-md-12">
                                                            <div class="card-body">
                                                                <div class="row">
                                                                    <div class="form-group ">
                                                                        <label for="IMPU01" style="color: #37465A; font-weight: normal;">Esquemas</label>
                                                                        <div class="input-group">
                                                                            <input type="text" class="form-control"
                                                                                id="IMPU01" name="IMPU01"
                                                                                placeholder="Esquemas" readonly>
                                                                            <div class="input-group-append">
                                                                                <span class="input-group-text"
                                                                                    style="background-color: #009dff; color: #fff; cursor: pointer;"
                                                                                    id="esquemas-dropdown">
                                                                                    <i class="fas fa-chevron-down"></i>
                                                                                </span>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div id="esquemas_table_container" class="position-absolute"
                                                                    style="display:none; z-index: 1000; width: 300px;">
                                                                    <table class="table table-bordered table-striped">
                                                                        <thead>
                                                                            <tr>
                                                                                <th>Esquemas</th>
                                                                                <th>Descripción</th>
                                                                            </tr>
                                                                        </thead>
                                                                        <tbody id="esquemas_table_body">
                                                                            <?php
                                                                            // Conexión a la base de datos Firebird
                                                                            session_start();
                                                                            $host = 'localhost';
                                                                            $database = 'C:\Program Files (x86)\Common Files\Aspel\Sistemas Aspel\SAE7.00\Ejemplos\Ejemplos.fdb';
                                                                            $username = 'SYSDBA';
                                                                            $password = 'masterkey';

                                                                            try {
                                                                                $dbh = new PDO("firebird:host=$host;dbname=$database;charset=UTF8", $username, $password);
                                                                                $query = "SELECT CVE_ESQIMPU, DESCRIPESQ FROM IMPU01";
                                                                                $stmt = $dbh->prepare($query);
                                                                                $stmt->execute();

                                                                                while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                                                    echo "<tr class='esquemas-row' data-IMPU01='" . $row['CVE_ESQIMPU'] . "' data-descr='" . $row['DESCRIPESQ'] . "'>";
                                                                                    echo "<td>" . $row['CVE_ESQIMPU'] . "</td>";
                                                                                    echo "<td>" . $row['DESCRIPESQ'] . "</td>";
                                                                                    echo "</tr>";
                                                                                }
                                                                            } catch (PDOException $e) {
                                                                                echo "Error: " . $e->getMessage();
                                                                            }
                                                                            ?>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                                <label class="form-label">16% IVA</label>
                                                            </div>
                                                        </div>
                                                    </div>


                                                    <div class="bg-white p-6 rounded-lg">
                                                        <h4 class="text-center font-semibold mb-12">Configuración adicional para IEPS</h4>
                                                        <div class="flex items-center justify-center mb-9">
                                                            <input type="checkbox" id="numero-serie" name="man_ieps"
                                                                class="mr-3" style="transform: scale(1.6);" onchange="toggleForm(this)">
                                                            <label for="numero-serie" class="text-gray-800">Activar para este producto</label>
                                                        </div>

                                                        <div class="mt-4">
                                                            <label class="block text-gray-400 font-bold">Aplicar configuración a:</label>
                                                            <select id="configuracion" name="aplicar-configuracion"
                                                                class="border border-gray-300 rounded p-2 w-full mt-2" disabled>
                                                                <option value="ieps">I.E.P.S.</option>
                                                                <option value="ret_isr">RET. ISR</option>
                                                                <option value="ret_iva">RET. IVA</option>
                                                                <option value="iva">I.V.A</option>
                                                            </select>
                                                        </div>

                                                        <div class="mt-4">
                                                            <label class="block text-gray-700 font-bold">Tasa de IEPS</label>
                                                            <div class="flex flex-col mt-3">
                                                                <div class="flex items-center">
                                                                    <input type="radio" id="cuota" name="apl_man_ieps" value="C" class="mr-2" disabled>
                                                                    <label for="cuota" class="text-gray-500">Cuota</label>
                                                                </div>
                                                                <div class="flex items-center mt-3">
                                                                    <input type="radio" id="mas_alto" name="apl_man_ieps" value="M" class="mr-2" disabled>
                                                                    <label for="mas_alto" class="text-gray-500">El más alto</label>
                                                                </div>
                                                                <div class="flex items-center mt-3">
                                                                    <input type="radio" id="ambos" name="apl_man_ieps" value="A" class="mr-2" disabled>
                                                                    <label for="ambos" class="text-gray-500">Ambos</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="mt-4 flex items-center">
                                                        <label class="w-32">Cuota</label>
                                                        <input type="text" id="cuota" name="cuota" class="form-control" placeholder="¿Cual es la Cuota?"
                                                            class="border border-gray-300 rounded p-2 ml-4 w-1/2">
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- Step 4 Content (Registros acumulados) -->
                                            <div id="registro-acumulados" class="tab-pane fade">

                                                <div class="row mb-3">
                                                    <div class="row col-lg-12">
                                                        <label class="font-bold border-b border-gray-400 pb-2">Cantidades Pendientes</label>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="pendientes_recibir">Pendientes por recibir:</label>
                                                        <input type="text" class="form-control" id="pendientes_recibir"
                                                            name="pendientes_recibir" placeholder="0">
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="pendientes_surtir">Pendientes por surtir:</label>
                                                        <input type="text" class="form-control" id="pendientes_surtir"
                                                            name="pendientes_surtir" placeholder="0">
                                                    </div>
                                                </div>
                                                <div class="row mb-3">
                                                    <div class="row col-lg-12">
                                                        <label class="font-bold border-b border-gray-400 pb-2">Costos</label>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="promedio_costo">Promedio:</label>
                                                        <input type="text" class="form-control" id="promedio_costo"
                                                            name="promedio_costo" placeholder="0.00000">
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="ultimo_costo">Último:</label>
                                                        <input type="text" class="form-control" id="ultimo_costo"
                                                            name="ultimo_costo" placeholder="0.00000">
                                                    </div>
                                                </div>

                                                <div class="row mb-3">
                                                    <div class="row col-lg-12">
                                                        <label class="font-bold border-b border-gray-400 pb-2">Acumulados anuales de ventas</label>
                                                    </div>
                                                    <div class="col-md-6">

                                                        <label for="cantidad_acumulados">Cantidad:</label>
                                                        <input type="text" class="form-control" id="cantidad_acumulados"
                                                            name="cantidad_acumulados" placeholder="0">
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="monto_acumulados">Monto:</label>
                                                        <input type="text" class="form-control" id="monto_acumulados"
                                                            name="monto_acumulados" placeholder="0.00">
                                                    </div>
                                                </div>
                                                <div class="row mb-3">
                                                    <div class="col-mb-6">
                                                        <label for="fecha_ultima_venta">Fecha de última venta:</label>
                                                        <div style="display: flex; align-items: center;">
                                                            <input type="date" class="form-control" id="fecha_ultima_venta"
                                                                name="fecha_ultima_venta">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="row mb-3">
                                                    <div class="row col-lg-12">

                                                        <label class="font-bold border-b border-gray-400 pb-2">Acumulados anuales de compras</label>
                                                    </div>
                                                    <div class="col-md-6">

                                                        <label for="cantidad_compras">Cantidad:</label>
                                                        <input type="text" class="form-control" id="cantidad_compras"
                                                            name="cantidad_compras" placeholder="0">
                                                    </div>
                                                    <div class="col-md-6">
                                                        <label for="monto_compras">Monto:</label>
                                                        <input type="text" class="form-control" id="monto_compras"
                                                            name="monto_compras" placeholder="0.00">
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-mb-6">
                                                        <label for="fecha_ultima_compra">Fecha de última compra:</label>
                                                        <div style="display: flex; align-items: center;">
                                                            <input type="date" class="form-control" id="fecha_ultima_compra" name="fecha_ultima_compra">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <!-- Step 5 Content (Emisión de Documentos) -->
                                            <div id="datos-adicionales" class="tab-pane fade">
                                                <div class="row">

                                                    <div class="form-group" style="margin-bottom: 20px;">
                                                        <label for="cuenta_correo" style="color: #37465A; font-weight: normal;">Cuenta de Correo
                                                            Electrónico</label>
                                                        <input type="email" class="form-control" id="cuenta_correo"
                                                            placeholder="Cuenta de Correo Electrónico"
                                                            style="border-radius: 4px;">
                                                    </div>

                                                    <div class="form-group" style="margin-bottom: 20px;">
                                                        <label for="descripcion_adicional"
                                                            style="color: #37465A; font-weight: normal;">Descripción Adicional:</label>
                                                        <input type="text" class="form-control" id="descripcion_adicional"
                                                            placeholder="Agrega un descripcion" name="descripcion_adicional"
                                                            style="border-radius: 4px;">
                                                    </div>

                                                    <div class="form-group" style="margin-bottom: 20px;">
                                                        <label for="observaciones"
                                                            style="color: #37465A; font-weight: normal;">Observaciones:</label>
                                                        <textarea class="form-control" id="observaciones" name="observaciones"
                                                            rows="4" style="border-radius: 4px;"></textarea>
                                                    </div>

                                                    <!-- Contenedor de Campos Libres del Usuario -->
                                                    <div class="col-md-12 mt-3">
                                                        <div class="card">
                                                            <div>
                                                                <h5 class="font-bold border-b border-gray-400 pb-2">Campos Libres del Usuario</h5>
                                                            </div>
                                                            <div class="card-body">
                                                                <table class="table table-bordered table-custom">
                                                                    <thead>
                                                                        <tr>
                                                                            <th>Campo Libre</th>
                                                                            <th>Valor</th>
                                                                        </tr>
                                                                    </thead>
                                                                    <tbody>
                                                                        <?php
                                                                        // Conexión a la base de datos Firebird
                                                                        $host = 'localhost';
                                                                        $database = 'C:\Program Files (x86)\Common Files\Aspel\Sistemas Aspel\SAE7.00\Ejemplos\Ejemplos.fdb';
                                                                        $username = 'SYSDBA';
                                                                        $password = 'masterkey';

                                                                        try {
                                                                            $dbh = new PDO("firebird:host=$host;dbname=$database;charset=UTF8", $username, $password);
                                                                            $query = "SELECT CAMPO, ETIQUETA FROM PARAM_CAMPOSLIBRES01 WHERE IDTABLA = 'INVE_CLIB'";
                                                                            $stmt = $dbh->prepare($query);
                                                                            $stmt->execute();

                                                                            // Iterar sobre los campos libres y generar inputs
                                                                            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                                                                echo "<tr>";
                                                                                // Mostrar la etiqueta del campo libre
                                                                                echo "<td>" . htmlspecialchars($row['ETIQUETA']) . "</td>";
                                                                                echo "<td>";
                                                                                // Crear un campo de texto para cada campo libre
                                                                                echo "<input type='text' class='form-control' name='campo_libre_" . htmlspecialchars($row['CAMPO']) . "'>";
                                                                                echo "</td>";
                                                                                echo "</tr>";
                                                                            }
                                                                        } catch (PDOException $e) {
                                                                            echo "Error: " . $e->getMessage();
                                                                        }
                                                                        ?>
                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- Step 6 Content (Datos Fiscales) -->
                                            <div id="fiscales" class="tab-pane fade" style="padding: 20px; border-radius: 4px;">
                                                <h4 class="font-bold border-b border-gray-400 pb-2 mb-3">Datos Fiscales</h4>
                                                <div class="row" style="margin-bottom: 15px;">
                                                    <div class="col-md-12">
                                                        <label for="clave-sat" style="color: #37465A; font-weight: normal;">Clave SAT</label>
                                                        <input class="form-control" id="clave-sat" type="text" style="width: 100%; height: 50px; border-radius: 4px; border: 1px solid #ccc;" />
                                                    </div>
                                                </div>
                                                <div class="row" style="margin-bottom: 15px;">
                                                    <div class="col-md-12">
                                                        <div class="form-group">
                                                            <label for="clave-unidad" style="color: #37465A; font-weight: normal;">Clave unidad</label>
                                                            <input class="form-control id=" clave-unidad type="text" style="width: 100%; height: 50px; border-radius: 4px; border: 1px solid #ccc;" />
                                                        </div>
                                                    </div>
                                                    <div class="col-md-12">
                                                        <div class>
                                                            <h5 class="font-bold border-b border-gray-400 pb-2 mb-3">Claves catalogos complemento</h5>
                                                        </div>
                                                    </div>
                                                    <div class="row" style="margin-bottom: 15px;">
                                                        <div class="col-md-6">
                                                            <div class="form-group">
                                                                <label for="fraccion-arancelaria" style="color: #37465A; font-weight: normal;">Fracción arancelaria</label>
                                                                <input class="form-control" id="fraccion-arancelaria" type="text" style="width: 100%; height: 50px; border-radius: 4px; border: 1px solid #ccc;" />
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <div class="form-group">
                                                                <label for="unidad-aduana" style="color: #37465A; font-weight: normal;">Unidad aduana</label>
                                                                <input class="form-control" id="unidad-aduana" type="text" style="width: 100%; height: 50px; border-radius: 4px; border: 1px solid #ccc;" />
                                                            </div>
                                                        </div>
                                                        <div class="row" style="margin-bottom: 15px;">
                                                            <div class="col-md-6">
                                                                <div class="form-group">
                                                                    <label for="factor-cce" style="color: #37465A; font-weight: normal;">Factor entre unidades CCE</label>
                                                                    <input class="form-control" id="factor-cce" type="text" style="width: 100%; height: 50px; border-radius: 4px; border: 1px solid #ccc;" />
                                                                </div>
                                                            </div>

                                                            <div class="col-md-6" style="display: flex; align-items: center;">
                                                                <button style="padding: 11px 20px; border: none; background-color: #009DFF; color: white; border-radius: 5px; cursor: pointer; margin-right: 10px;">
                                                                    Mercancía CCE
                                                                </button>

                                                                <button style="padding: 11px 20px; border: none; background-color: #009DFF; color: white; border-radius: 5px; cursor: pointer; margin-right: 10px;">
                                                                    Mercancía CCP
                                                                </button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <!-- Fixed Buttons -->
                                        <div class="form-buttons">
                                            <button type="button" class="btn btn-secondary btn-prev" onclick="prevTab()"><i class="fas fa-arrow-left next-icon"></i>Anterior</button>
                                            <button type="submit" class="btn btn-primary">Guardar</button>
                                            <button type="button" class="btn btn-primary btn-next" onclick="nextTab()">Siguiente<i class="fas fa-arrow-right next-icon"></i></button>
                                        </div>
                                    </form>
                                </div>
                            </section>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Modal -->
            <!-- Modal de confirmación -->
            <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="confirmModalLabel">Confirmación</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body text-center">
                            <div class="checkmark-container">
                                <div class="checkmark draw"></div>
                            </div>
                            <p style="margin-top: 10px;">¡El producto se ha agregado correctamente!</p>
                        </div>
                        <div class="modal-footer justify-content-center">
                            <button type="button" class="btn btn-primary" data-dismiss="modal">Cerrar</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- / Content -->



        <div class="content-backdrop fade"></div>
    </div>
    <!-- Content wrapper -->
    </div>


    <!-- Overlay -->
    <div class="layout-overlay layout-menu-toggle"></div>
    </div>
    <!-- / Layout wrapper -->


    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="../assets/vendor/libs/jquery/jquery.js"></script>
    <script src="../assets/vendor/libs/popper/popper.js"></script>
    <script src="../assets/vendor/js/bootstrap.js"></script>
    <script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>

    <script src="../assets/vendor/js/menu.js"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="../assets/vendor/libs/apex-charts/apexcharts.js"></script>

    <!-- Main JS -->
    <script src="../assets/js/main.js"></script>

    <!-- Page JS -->
    <script src="../assets/js/dashboards-analytics.js"></script>

    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>

    <div class="modal fade" id="modalBusqueda" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog modal-xl modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Buscar módulo</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
                </div>
                <div class="modal-body">
                    <div class="input-group mb-4">
                        <span class="input-group-text"><i class="bx bx-search"></i></span>
                        <input type="text" id="modalSearchInput" class="form-control" placeholder="Buscar módulo..." autocomplete="off">
                    </div>

                    <div class="row" id="modulosEstaticos">
                        <!-- Columna 1 -->
                        <div class="col-md-4 mb-4">
                            <!-- Inicio -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-home me-1"></i> Inicio
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1">
                                        <a href="tablero.php"><i class="bx bx-home-smile me-2"></i> Panel principal</a>
                                    </li>
                                </ul>
                            </div>
                            <!-- Ventas -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-money me-1"></i> Ventas
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="facturas.php"><i class="bx bx-file me-2"></i> Facturas</a></li>
                                </ul>
                            </div>
                            <!-- Clientes -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-user me-1"></i> Clientes
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="clientes.php"><i class="bx bx-user-pin me-2"></i> Clientes</a></li>
                                </ul>
                            </div>
                        </div>

                        <!-- Columna 2 -->
                        <div class="col-md-4 mb-4">
                            <!-- Inventario -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-package me-1"></i> Inventario
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="productos.php"><i class="bx bx-cube me-2"></i> Productos</a></li>
                                </ul>
                            </div>
                            <!-- Compras -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-cart me-1"></i> Compras
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="compras.php"><i class="bx bx-purchase-tag me-2"></i> Compras</a></li>
                                </ul>
                            </div>
                        </div>

                        <!-- Columna 3 -->
                        <div class="col-md-4 mb-4">
                            <!-- Proveedores -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-building me-1"></i> Proveedores
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="proveedores.php"><i class="bx bx-user-voice me-2"></i> Proveedores</a></li>
                                </ul>
                            </div>
                            <!-- Cuentas -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-wallet me-1"></i> Cuentas
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="cuentas.php"><i class="bx bx-credit-card me-2"></i> Cuentas</a></li>
                                </ul>
                            </div>
                            <!-- Movimientos -->
                            <div class="mb-3">
                                <small class="text-uppercase text-muted fw-bold d-block mb-2">
                                    <i class="bx bx-transfer me-1"></i> Movimientos
                                </small>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item px-0 py-1"><a href="movimientos.php"><i class="bx bx-transfer-alt me-2"></i> Movimientos</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>

                    <!-- Resultados de búsqueda -->
                    <ul id="modalSearchResults" class="list-group mb-3"></ul>

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

    <style>
        /* Ocultar resultados inicialmente */
        #modalSearchResults {
            display: none;
            max-height: 300px;
            overflow-y: auto;
        }
    </style>





    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <script>
        function toggleForm(checkbox) {
            // Habilitar o deshabilitar el select y los radios según el estado del checkbox
            const configuracionSelect = document.getElementById('configuracion');
            const radios = document.querySelectorAll('input[name="apl_man_ieps"]');

            if (checkbox.checked) {
                configuracionSelect.disabled = false; // Habilitar el select
                radios.forEach(radio => radio.disabled = false); // Habilitar los radios
            } else {
                configuracionSelect.disabled = true; // Deshabilitar el select
                radios.forEach(radio => radio.disabled = true); // Deshabilitar los radios
            }
        }
    </script>
    <script>
        $('#confirmModal').on('show.bs.modal', function() {
            var checkmark = $('.checkmark');
            checkmark.removeClass('draw');
            setTimeout(function() {
                checkmark.addClass('draw');
            }, 10); // Delay para permitir la eliminación de la clase antes de añadirla de nuevo
        });
    </script>
    <script>
        document.getElementById("form-proveedor").addEventListener("submit", function(event) {
            event.preventDefault();

            // Crea un objeto FormData con los datos del formulario
            var formData = new FormData(this);

            // Envía los datos a leer_producto.php utilizando fetch
            fetch('leer_producto.php', {
                    method: 'POST',
                    body: formData
                })
                .then(response => response.json())
                .then(data => {
                    // Si la respuesta es exitosa, muestra la ventana modal
                    if (data.status === 'success') {
                        $('#confirmModal').modal('show');
                        clearForm(); // Limpia el formulario después de mostrar el modal
                    } else {
                        alert(data.message); // Muestra el mensaje de error
                    }
                })
                .catch(error => console.error('Error:', error));
        });

        // Función para limpiar el formulario
        function clearForm() {
            document.getElementById('form-proveedor').reset(); // Limpia el formulario
        }
    </script>



    <!-- script de Formulario -->
    <script>
        // JavaScript for navigating between tabs and updating styles
        let activeIndex = 0; // Index of the active tab

        document.addEventListener('DOMContentLoaded', function() {
            const navLinks = document.querySelectorAll('.bs-stepper .nav-link');
            const tabs = document.querySelectorAll('.tab-pane');
            const prevButton = document.querySelector('.btn-prev');
            const nextButton = document.querySelector('.btn-next');
            const prevIcon = prevButton.querySelector('.fa-arrow-left');

            // Function to update styles on the nav links (tab headers)
            function actualizarEstilos() {
                navLinks.forEach((link, index) => {
                    const icon = link.querySelector('.bx');
                    if (index === activeIndex) {
                        // Styles for the active tab
                        link.classList.add('active');
                        icon.style.backgroundColor = '#009dff';
                        icon.style.color = '#fff';
                        icon.style.borderRadius = '50%';
                        icon.style.padding = '10px';
                    } else {
                        // Reset styles for inactive tabs
                        link.classList.remove('active');
                        icon.style.backgroundColor = '';
                        icon.style.color = '';
                        icon.style.borderRadius = '';
                        icon.style.padding = '';
                    }
                });

                // Update the "Previous" button state
                if (activeIndex === 0) {
                    prevButton.disabled = true;
                    prevButton.style.backgroundColor = '#f8f9fa';
                    prevButton.style.color = '#37465A';
                    prevIcon.style.color = '#37465A';
                } else {
                    prevButton.disabled = false;
                    prevButton.style.backgroundColor = '#009dff';
                    prevButton.style.color = '#fff';
                    prevIcon.style.color = '#fff';
                }
            }

            // Function to activate a tab by index
            function activateTab(index) {
                if (index >= 0 && index < tabs.length) {
                    document.querySelector('.tab-pane.active').classList.remove('active', 'show');
                    tabs[index].classList.add('active', 'show');

                    document.querySelector('.nav-link.active').classList.remove('active');
                    navLinks[index].classList.add('active');

                    activeIndex = index; // Update the active index
                    actualizarEstilos(); // Update styles based on the active tab
                }
            }

            // Go to the next tab
            function nextTab() {
                if (activeIndex < navLinks.length - 1) {
                    activateTab(activeIndex + 1);
                }
            }

            // Go to the previous tab
            function prevTab() {
                if (activeIndex > 0) {
                    activateTab(activeIndex - 1);
                }
            }

            // Add event listeners to the nav links for manual tab navigation
            navLinks.forEach((link, index) => {
                link.addEventListener('click', function(event) {
                    event.preventDefault();
                    activateTab(index); // Activate the clicked tab
                });
            });

            // Add event listeners to the "Next" and "Previous" buttons
            nextButton.addEventListener('click', function(event) {
                event.preventDefault();
                nextTab(); // Move to the next tab
            });

            prevButton.addEventListener('click', function(event) {
                event.preventDefault();
                prevTab(); // Move to the previous tab
            });

            // Initialize styles and button states
            activateTab(activeIndex); // Activate the first tab and apply styles
        });
    </script>
    <script>
        document.getElementById('sidebarCollapse').addEventListener('click', function() {
            var sidebar = document.getElementById('sidebar');
            var content = document.querySelector('.content');
            var banner = document.querySelector('.banner');
            sidebar.classList.toggle('collapsed');
            content.classList.toggle('collapsed');
            banner.classList.toggle('collapsed');
        });

        document.getElementById('userDropdownToggle').addEventListener('click', function() {
            document.getElementById('userDropdown').classList.toggle('show');
        });
    </script>
    <script>
        document.querySelectorAll('[data-toggle="submenu"]').forEach(function(element) {
            element.addEventListener('click', function(e) {
                e.preventDefault();
                var target = document.querySelector(element.getAttribute('data-target'));
                var isOpen = target.style.maxHeight !== '0px';

                document.querySelectorAll('.submenu').forEach(function(submenu) {
                    submenu.style.maxHeight = '0px';
                });

                document.querySelectorAll('[data-toggle="submenu"]').forEach(function(el) {
                    el.classList.remove('submenu-open');
                });

                if (!isOpen) {
                    target.style.maxHeight = target.scrollHeight + 'px';
                    element.classList.add('submenu-open');
                }
            });
        });
    </script>


    <!-- SCRIPT PARA LISTA DE Lista  -->
    <script>
        // Mostrar/Ocultar la tabla de selección de países
        document.getElementById('pais-dropdown').addEventListener('click', function() {
            let paisTable = document.getElementById('pais_table_container');
            paisTable.style.display = paisTable.style.display === 'none' ? 'block' : 'none';
        });

        // Selección del país en la tabla
        document.querySelectorAll('.pais-row').forEach(function(row) {
            row.addEventListener('click', function() {
                let cvePais = this.getAttribute('data-cve-pais');

                // Llenar el campo con el valor seleccionado
                document.getElementById('cve_pais').value = cvePais;

                // Ocultar la tabla después de seleccionar
                document.getElementById('pais_table_container').style.display = 'none';
            });
        });
    </script>

    <script>
        // esquemas
        fetch('obtener_esquemas.php')
            .then(response => response.json())
            .then(data => {
                const selectEsquema = document.getElementById('esquema');
                selectEsquema.innerHTML = '<option value="" disabled selected>Seleccionar esquemas...</option>';
                data.forEach(esquema => {
                    selectEsquema.innerHTML += `<option value="${esquema.CVE_ESQIMPU}">${esquema.CVE_ESQIMPU}, ${esquema.DESCRIPESQ} </option>`;
                });

                // Remove this line if you don't want to set a default value
                document.getElementById('esquema').value = '1';
            })
            .catch(error => console.error('Error al obtener los esquemas:', error));
    </script>

    <!-- SCRIPT de Esquemas -->
    <script>
        // Mostrar/Ocultar la tabla de selección de esquemas
        document.getElementById('esquemas-dropdown').addEventListener('click', function() {
            let paisTable = document.getElementById('esquemas_table_container');
            paisTable.style.display = paisTable.style.display === 'none' ? 'block' : 'none';
        });

        // Selección del esquemas en la tabla
        document.querySelectorAll('.esquemas-row').forEach(function(row) {
            row.addEventListener('click', function() {
                let IMPU01 = this.getAttribute('data-IMPU01');

                // Llenar el campo con el valor seleccionado
                document.getElementById('IMPU01').value = IMPU01;

                // Ocultar la tabla después de seleccionar
                document.getElementById('esquemas_table_container').style.display = 'none';
            });
        });
    </script>

    <!-- SCRIPT PARA LISTA DE Moneda -->
    <script>
        // Mostrar/Ocultar la tabla de selección de moneda
        document.getElementById('moneda-dropdown').addEventListener('click', function() {
            let paisTable = document.getElementById('moneda_table_container');
            paisTable.style.display = paisTable.style.display === 'none' ? 'block' : 'none';
        });

        // Selección del país en la tabla
        document.querySelectorAll('.moneda-row').forEach(function(row) {
            row.addEventListener('click', function() {
                let NUMMONED = this.getAttribute('data-NUMMONED');

                // Llenar el campo con el valor seleccionado
                document.getElementById('NUMMONED').value = NUMMONED;

                // Ocultar la tabla después de seleccionar
                document.getElementById('moneda_table_container').style.display = 'none';
            });
        });
    </script>


    <script>
        document.getElementById("modalSearchInput").addEventListener("input", function() {
            const query = this.value.trim();
            const results = document.getElementById("modalSearchResults");
            const modulos = document.getElementById("modulosEstaticos");

            results.innerHTML = "";

            if (query.length < 2) {
                // Mostrar módulos estáticos y ocultar resultados
                modulos.style.display = "flex"; // o "block" si prefieres
                results.style.display = "none";
                return;
            }

            // Ocultar módulos estáticos y mostrar resultados
            modulos.style.display = "none";
            results.style.display = "block";

            fetch("buscar_archivos.php?q=" + encodeURIComponent(query))
                .then(response => response.json())
                .then(data => {
                    if (data.length === 0) {
                        results.innerHTML = `<li class="list-group-item text-muted">No se encontraron resultados</li>`;
                        return;
                    }

                    data.forEach(item => {
                        const li = document.createElement("li");
                        li.className = "list-group-item list-group-item-action";
                        li.innerHTML = `<i class="bx bx-link-alt me-2"></i> ${item.titulo}`;
                        li.addEventListener("click", () => {
                            window.location.href = item.archivo;
                        });
                        results.appendChild(li);
                    });
                })
                .catch(error => {
                    console.error("Error al buscar:", error);
                });
        });
    </script>

</body>