@model foundation_system.Models.ConfiguracionSistema
@{
    ViewData["Title"] = "Editar Configuración";
}

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h2 class="mb-1">Editar Parámetro</h2>
        <p class="text-muted small mb-0">Modificando la clave: <code>@Model.Clave</code></p>
    </div>
    <a asp-action="Index" asp-route-categoria="@Model.Categoria" class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-2"></i>Volver
    </a>
</div>

<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card-custom">
            <form asp-action="Edit" method="post">
                @Html.AntiForgeryToken()
                <input type="hidden" asp-for="Id" />
                
                <div class="mb-4">
                    <label class="form-label fw-bold">Descripción</label>
                    <p class="text-muted small">@Model.Descripcion</p>
                </div>

                <div class="mb-4">
                    <label asp-for="Valor" class="form-label fw-bold">Valor</label>
                    
                    @if (Model.TipoDato == "BOOLEANO")
                    {
                        <select asp-for="Valor" class="form-select">
                            <option value="true">Activado (True)</option>
                            <option value="false">Desactivado (False)</option>
                        </select>
                    }
                    else if (Model.TipoDato == "HTML" || Model.TipoDato == "JSON")
                    {
                        <textarea asp-for="Valor" class="form-control" rows="8" style="font-family: monospace;"></textarea>
                    }
                    else if (Model.TipoDato == "NUMERO")
                    {
                        <input asp-for="Valor" class="form-control" type="number" />
                    }
                    else if (Model.TipoDato == "FECHA")
                    {
                        <input asp-for="Valor" class="form-control" type="date" />
                    }
                    else
                    {
                        <input asp-for="Valor" class="form-control" />
                    }
                    <span asp-validation-for="Valor" class="text-danger small"></span>
                </div>

                <div class="d-flex justify-content-between align-items-center mt-5">
                    <div class="small text-muted">
                        <i class="bi bi-info-circle me-1"></i>
                        Tipo: <span class="badge bg-light text-dark border">@Model.TipoDato</span>
                    </div>
                    <button type="submit" class="btn btn-primary-custom">
                        <i class="bi bi-save me-2"></i>Guardar Cambios
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
