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

<div class="container-div">
    <h2>Colores</h2>
    <p>En este catálogo puedes ver, editar y eliminar colores de productos.</p>
    <div class="project-actions">
        <button class="btn btn-add" data-bs-toggle="modal" data-bs-target="#addColorModal">Agregar color</button>
    </div>
    <table id="marcasTable" class="display">
        <thead>
            <tr>
                <th>#</th>
                <th>Nombre</th>
                <th>Código Hex</th>
                <th>Vista previa</th>
                <th>Status</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

<div class="modal fade" id="addColorModal" tabindex="-1" aria-labelledby="addColorModalLabel" 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="addColorModalLabel">Añadir Color <i class="fa-solid fa-palette"></i></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="addColor">
                    <input type="hidden" id="id_color" name="id_color">
                    <div class="mb-3">
                        <div class="row">
                            <div class="col-md-8">
                                <label for="nombre" class="form-label">Nombre del Color</label>
                                <input type="text" class="form-control" id="nombre" name="nombre" required placeholder="Ej: Azul, Rojo, Verde">
                            </div>
                            <div class="col-md-4">
                                <label for="codigo_hex" class="form-label">Código Hex</label>
                                <div class="input-group">
                                    <input type="text" class="form-control" id="codigo_hex" name="codigo_hex" required placeholder="#FF0000" maxlength="7">
                                    <input type="color" class="form-control form-control-color" id="color_picker" title="Seleccionar color">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Vista previa del color:</label>
                        <div id="color_preview" style="width: 100%; height: 50px; border: 2px solid #ddd; border-radius: 5px; background-color: #ffffff; display: flex; align-items: center; justify-content: center; color: #666;">
                            Selecciona un color
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
                <button type="submit" form="addColor" class="btn btn-add" id="btn-save-color">Guardar color</button>
            </div>
        </div>
    </div>
</div>

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