<?php
include 'views/header.php'; ?>

<div class="container-div">
    <h2>Marcas</h2>
    <p>En este catálogo puedes ver, editar y eliminar marcas de productos.</p>
    <div class="project-actions">
        <button class="btn btn-add" data-bs-toggle="modal" data-bs-target="#addMarcaModal">Agregar marca</button>
    </div>
    <table id="marcasTable" class="display">
        <thead>
            <tr>
                <th>#</th>
                <th>Logo</th>
                <th>Nombre</th>
                <th>Destacado</th>
                <th>Status</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

<div class="modal fade" id="addMarcaModal" tabindex="-1" aria-labelledby="addMarcaModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addMarcaModalLabel">Añadir Marca</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="addMarcaForm">
                    <input type="hidden" id="id_marca" name="id" value="">
                    <input type="hidden" id="logo" name="logo" value="">
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-12">
                                <label for="nombre" class="form-label">Nombre de la Marca</label>
                                <input type="text" class="form-control" id="nombre" name="nombre" required>
                            </div>
                        </div>
                    </div>
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-6">
                                <label for="destacado" class="form-label">Destacado</label>
                                <select class="form-select" id="destacado" name="destacado" required>
                                    <option value="">Selecciona una opción</option>
                                    <option value="1">Sí</option>
                                    <option value="0">No</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-12">
                                <label class="form-label">Logo de la marca (máx. 1MB)</label>
                                <div id="logoDropzone" class="dropzone">
                                    <div class="dz-message needsclick">
                                        Arrastra una imagen aquí o haz clic para seleccionar<br>
                                        <span class="note needsclick">Tamaño recomendado: 400x200 px</span>
                                    </div>
                                </div>
                                <div id="logo-preview" class="mt-2 d-none">
                                    <div class="position-relative">
                                        <img src="" alt="Vista previa" class="img-thumbnail w-100">
                                        <button type="button" id="remove-logo" class="btn btn-danger btn-sm position-absolute top-0 end-0">
                                            <i class="fa-solid fa-times"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
                <button type="button" id="btn-save-marca" class="btn btn-primary">Guardar marca</button>
            </div>
        </div>
    </div>
</div>

<?php include 'views/footer.php'; ?>